|
1 | 1 | import * as vscode from 'vscode'; |
2 | 2 | import SpecRunnerConfig, { TerminalClear } from '../SpecRunnerConfig'; |
3 | | -import { cmdJoin, quote, remapPath, stringifyEnvs, teeCommand } from '../util'; |
| 3 | +import { cdCommands, cmdJoin, quote, remapPath, stringifyEnvs, teeCommand } from '../util'; |
4 | 4 | import SpecResultPresenter from '../SpecResultPresenter'; |
5 | 5 | import { RubyDebugger, RunRspecOrMinitestArg } from '../types'; |
6 | 6 |
|
@@ -122,21 +122,33 @@ export class MinitestRunner { |
122 | 122 | } |
123 | 123 | const minitestArgs = [quote(testFile), testNameFilter].filter(Boolean).join(' -- '); |
124 | 124 |
|
125 | | - const cdCommand = this.buildChangeDirectoryToWorkspaceRootCommand(); |
| 125 | + const [cdCommand, returnCommand] = this.buildChangeDirectoryToWorkspaceRootCommand(); |
126 | 126 | const minitestCommand = [stringifyEnvs(this.config.minitestEnv), this.config.minitestCommand, minitestArgs].filter(Boolean).join(' '); |
127 | 127 |
|
128 | 128 | const lineNumber = lines.length ? JSON.stringify(lines) : 'ALL'; |
129 | 129 | const saveRunOptions = cmdJoin(`echo ${fileName} > ${this.outputFilePath}`, `echo ${quote(lineNumber)} >> ${this.outputFilePath}`); |
130 | 130 | const outputRedirect = `| ${teeCommand(this.outputFilePath, true, this.config.usingBashInWindows)}`; |
| 131 | + |
| 132 | + let fullCommand; |
131 | 133 | if (this.config.minitestDecorateEditorWithResults) { |
132 | | - return cmdJoin(cdCommand, saveRunOptions, [minitestCommand, outputRedirect].filter(Boolean).join(' ')); |
| 134 | + fullCommand = cmdJoin(cdCommand, saveRunOptions, [minitestCommand, outputRedirect].filter(Boolean).join(' ')); |
| 135 | + } else { |
| 136 | + fullCommand = cmdJoin(cdCommand, minitestCommand); |
133 | 137 | } |
134 | 138 |
|
135 | | - return cmdJoin(cdCommand, minitestCommand); |
| 139 | + if (returnCommand === false) { |
| 140 | + return `(${fullCommand})`; |
| 141 | + } else { |
| 142 | + return cmdJoin(fullCommand, returnCommand); |
| 143 | + } |
136 | 144 | } |
137 | 145 |
|
138 | 146 | private buildChangeDirectoryToWorkspaceRootCommand() { |
139 | | - return this.config.changeDirectoryToWorkspaceRoot ? `cd ${quote(this.config.projectPath)}` : ''; |
| 147 | + if (!this.config.changeDirectoryToWorkspaceRoot) { |
| 148 | + return ['', '']; |
| 149 | + } |
| 150 | + |
| 151 | + return cdCommands(this.config.projectPath, this.config.usingBashInWindows); |
140 | 152 | } |
141 | 153 |
|
142 | 154 | private remappedPath(filePath: string) { |
|
0 commit comments