Resolve #3654 Don't enforce -cd on latexmk

This commit is contained in:
James Yu 2023-01-19 21:46:48 +08:00
parent e9c84cc0e7
commit 12f4c9daca
5 changed files with 8 additions and 30 deletions

View File

@ -237,10 +237,9 @@ export class Builder {
* the io handling is performed in {@link monitorProcess}.
*
* @param step The {@link Step} to be executed.
* @param cwd The current working directory.
* @returns The process environment passed to the spawned process.
*/
private spawnProcess(step: Step, cwd?: string): ProcessEnv {
private spawnProcess(step: Step): ProcessEnv {
const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? vscode.Uri.file(step.rootFile) : undefined)
if (step.index === 0 || configuration.get('latex.build.clearLog.everyRecipeStep.enabled') as boolean) {
logger.clearCompilerMessage()
@ -268,13 +267,9 @@ export class Builder {
this.process = cs.spawn(step.command, args, {cwd: path.dirname(step.rootFile), env})
}
} else if (!step.isExternal) {
let cwd = path.dirname(step.rootFile)
if (step.command === 'latexmk' && step.rootFile === lw.manager.localRootFile && lw.manager.rootDir) {
cwd = lw.manager.rootDir
if (step.args && !step.args.includes('-cd')) {
step.args.push('-cd')
}
} else {
cwd = path.dirname(step.rootFile)
}
logger.log(`cwd: ${cwd}`)
this.process = cs.spawn(step.command, step.args, {cwd, env})

View File

@ -1,5 +1,5 @@
\documentclass[../main.tex]{subfiles}
\begin{document}
sub sub
\input{./subsub/infile}
\input{./sub/subsub/infile}
\end{document}

View File

@ -186,7 +186,7 @@ suite('Build TeX files test suite', () => {
{src: 'subfile_subsub.tex', dst: 'sub/s.tex'},
{src: 'plain.tex', dst: 'sub/subsub/infile.tex'}
])
await test.assert.build(fixture, 'sub/s.tex', 'sub/out/s.pdf')
await test.assert.build(fixture, 'sub/s.tex', 'out/s.pdf')
})
test.run(suiteName, fixtureName, 'basic build with makeindex', async () => {
@ -201,7 +201,7 @@ suite('Build TeX files test suite', () => {
{src: 'subfile_base.tex', dst: 'main.tex'},
{src: 'makeindex_subfile.tex', dst: 'sub/s.tex'}
])
await test.assert.build(fixture, 'sub/s.tex', 'sub/out/s.pdf')
await test.assert.build(fixture, 'sub/s.tex', 'out/s.pdf')
})
test.run(suiteName, fixtureName, 'test q/.../ with spaces in outdir on Windows', async () => {

View File

@ -227,7 +227,7 @@ suite('Intellisense test suite', () => {
assert.ok(!snippet.value.includes('${1:'))
})
test.only(suiteName, fixtureName, 'command intellisense with config `intellisense.command.user`', async () => {
test.run(suiteName, fixtureName, 'command intellisense with config `intellisense.command.user`', async () => {
await vscode.workspace.getConfiguration('latex-workshop').update('intellisense.command.user', {'mycommand[]{}': 'notsamecommand[${2:option}]{$TM_SELECTED_TEXT$1}', 'parbox{}{}': 'defchanged', 'overline{}': ''})
await test.load(fixture, [
{src: 'intellisense/base.tex', dst: 'main.tex'},
@ -309,24 +309,7 @@ suite('Intellisense test suite', () => {
assert.ok(labels.includes('sec:1'))
assert.ok(labels.includes('sec:2'))
assert.ok(labels.includes('alt-sec:1'))
}, undefined, undefined, true)
test.run(suiteName, fixtureName, 'reference intellisense with `xr` package', async () => {
await test.load(fixture, [
{src: 'intellisense/xr_base.tex', dst: 'main.tex'},
{src: 'intellisense/xr_sub.tex', dst: 'sub.tex'},
{src: 'intellisense/xr_dup.tex', dst: 'dup.tex'}
])
const result = await test.open(fixture, 'main.tex')
const items = test.suggest(result.doc, new vscode.Position(6, 5))
assert.ok(items)
assert.ok(items.length > 0)
const labels = items.map(item => item.label.toString())
assert.ok(labels.includes('sec:1'))
assert.ok(labels.includes('sec:2'))
assert.ok(labels.includes('alt-sec:1'))
}, undefined, undefined, true)
})
test.run(suiteName, fixtureName, 'environment intellisense', async () => {
await test.load(fixture, [

View File

@ -41,7 +41,7 @@ export function run(suiteName: string, fixtureName: string, testName: string, cb
}
testCounter++
const testFunction = (process.env['LATEXWORKSHOP_CLI'] || !runonly) ? test : test.only
const testFunction = (process.env['LATEXWORKSHOP_CLI'] || !runonly) ? test : test.run
const counterString = testCounter.toLocaleString('en-US', {minimumIntegerDigits: 3, useGrouping: false})
testFunction(`[${counterString}] ${suiteName}: ${testName}`, async () => {