Skip to content

Commit cd7272a

Browse files
committed
fix tests
1 parent 043e08f commit cd7272a

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

.vscode/launch.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@
149149
"--ui=tdd",
150150
"--recursive",
151151
"--colors",
152-
"--grep",
153-
"ProcessLogger suite",
152+
//"--grep", "<suite name>",
154153
"--timeout=300000"
155154
],
156155
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],

src/test/common/process/logger.unit.test.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,55 @@ suite('ProcessLogger suite', () => {
109109

110110
test('Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path', async () => {
111111
const options = { cwd: path.join('debug', 'path') };
112-
logger.logProcess(path.join('net', untildify('~'), 'test'), ['--foo', '--bar'], options);
112+
const untildifyStr = untildify('~');
113+
114+
let p1 = path.join('net', untildifyStr, 'test');
115+
if (p1.startsWith('.')) {
116+
if (getOSType() === OSType.Windows) {
117+
p1 = p1.replace(/^\.\\+/, '');
118+
} else {
119+
p1 = p1.replace(/^\.\\/, '');
120+
}
121+
}
122+
logger.logProcess(p1, ['--foo', '--bar'], options);
113123

114-
sinon.assert.calledWithExactly(traceLogStub, `> ${path.join('net', '~', 'test')} --foo --bar`);
124+
const path1 = path.join('.', 'net', '~', 'test');
125+
sinon.assert.calledWithExactly(traceLogStub, `> ${path1} --foo --bar`);
115126
sinon.assert.calledWithExactly(traceLogStub, `cwd: ${options.cwd}`);
116127
});
117128

118129
test('Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path but another arg contains other ref to home folder', async () => {
119130
const options = { cwd: path.join('debug', 'path') };
120-
logger.logProcess(
121-
path.join('net', untildify('~'), 'test'),
122-
['--foo', path.join(untildify('~'), 'boo')],
123-
options,
124-
);
131+
let p1 = path.join('net', untildify('~'), 'test');
132+
if (p1.startsWith('.')) {
133+
if (getOSType() === OSType.Windows) {
134+
p1 = p1.replace(/^\.\\+/, '');
135+
} else {
136+
p1 = p1.replace(/^\.\\/, '');
137+
}
138+
}
139+
logger.logProcess(p1, ['--foo', path.join(untildify('~'), 'boo')], options);
125140

126141
sinon.assert.calledWithExactly(
127142
traceLogStub,
128-
`> ${path.join('net', '~', 'test')} --foo ${path.join('~', 'boo')}`,
143+
`> ${path.join('.', 'net', '~', 'test')} --foo ${path.join('~', 'boo')}`,
129144
);
130145
sinon.assert.calledWithExactly(traceLogStub, `cwd: ${options.cwd}`);
131146
});
132147

133148
test('Logger replaces the path/to/home with ~ in the command path where the home path IS NOT at the beginning of the path between doble quotes', async () => {
134149
const options = { cwd: path.join('debug', 'path') };
135-
logger.logProcess(`"${path.join('net', untildify('~'), 'test')}" "--foo" "--bar"`, undefined, options);
150+
let p1 = path.join('net', untildify('~'), 'test');
151+
if (p1.startsWith('.')) {
152+
if (getOSType() === OSType.Windows) {
153+
p1 = p1.replace(/^\.\\+/, '');
154+
} else {
155+
p1 = p1.replace(/^\.\\/, '');
156+
}
157+
}
158+
logger.logProcess(`"${p1}" "--foo" "--bar"`, undefined, options);
136159

137-
sinon.assert.calledWithExactly(traceLogStub, `> "${path.join('net', '~', 'test')}" "--foo" "--bar"`);
160+
sinon.assert.calledWithExactly(traceLogStub, `> "${path.join('.', 'net', '~', 'test')}" "--foo" "--bar"`);
138161
sinon.assert.calledWithExactly(traceLogStub, `cwd: ${options.cwd}`);
139162
});
140163

0 commit comments

Comments
 (0)