Skip to content

Commit c022e7e

Browse files
committed
fix command bug
1 parent 8a0923b commit c022e7e

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "PHPUnit Test Explorer",
55
"icon": "img/icon.png",
66
"publisher": "recca0120",
7-
"version": "3.7.8",
7+
"version": "3.7.9",
88
"private": true,
99
"license": "MIT",
1010
"repository": {

src/PHPUnit/CommandBuilder/Builder.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('Builder Test', () => {
125125
expect(runtime).toEqual('php');
126126
expect(args).toEqual([
127127
'vendor/bin/pest',
128-
`--filter="^.*::(it has user's email)(( with (data set )?.*)?)?$"`,
128+
`--filter=^.*::(it has user's email)(( with (data set )?.*)?)?$`,
129129
phpUnitProject('tests/AssertionsTest.php'),
130130
'--colors=never',
131131
'--teamcity',
@@ -184,7 +184,7 @@ describe('Builder Test', () => {
184184
[
185185
'php',
186186
'vendor/bin/paratest',
187-
`--filter=^.*::(test_passed)( with data set .*)?$`,
187+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
188188
`--colors=never`,
189189
`--teamcity`,
190190
`--functional`,
@@ -263,7 +263,7 @@ describe('Builder Test', () => {
263263
'php',
264264
'artisan',
265265
'test',
266-
`--filter=^.*::(test_passed)( with data set .*)?$`,
266+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
267267
`--colors=never`,
268268
`--teamcity`,
269269
].join(' '),
@@ -292,7 +292,7 @@ describe('Builder Test', () => {
292292
'php',
293293
'artisan',
294294
'test',
295-
`--filter=^.*::(test_passed)( with data set .*)?$`,
295+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
296296
'--colors=never',
297297
'--teamcity',
298298
].join(' '),
@@ -394,7 +394,7 @@ describe('Builder Test', () => {
394394
'php',
395395
'artisan',
396396
'test',
397-
`--filter=^.*::(test_passed)( with data set .*)?$`,
397+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
398398
`--colors=never`,
399399
`--teamcity`,
400400
].join(' '),
@@ -418,7 +418,7 @@ describe('Builder Test', () => {
418418
[
419419
'php',
420420
'vendor/bin/phpunit',
421-
`--filter=^.*::(test_passed)( with data set .*)?$`,
421+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
422422
'--colors=never',
423423
'--teamcity',
424424
].join(' '),

src/PHPUnit/CommandBuilder/Builder.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,26 @@ export class Builder {
162162
const pattern = new RegExp('^(--filter)=(.*)');
163163

164164
return input.replace(pattern, (_m, ...matched) => {
165-
const value = btoa(matched[1]);
165+
const value = Buffer.from(matched[1], 'utf-8').toString('base64');
166166

167167
return `${matched[0]}='${value}'`;
168168
});
169169
});
170170
}
171171

172172
private decodeFilter(args: string[]) {
173+
const command = args.join(' ');
174+
const needsQuote = isSSH(command) || isShellCommand(command);
175+
173176
return args.map((input) => {
174177
const pattern = new RegExp('(--filter)=["\'](.+)?["\']');
175178

176179
return input.replace(pattern, (_m, ...matched) => {
177-
const value = atob(matched[1]);
178-
const quote = value.includes('\'') ? '"' : '';
180+
const value = Buffer.from(matched[1], 'base64').toString('utf-8');
181+
const quote = value.includes('\'') ? '"' : '\'';
182+
const filter = `${matched[0]}=${value}`;
179183

180-
return `${matched[0]}=${quote}${value}${quote}`;
184+
return needsQuote ? `${quote}${filter}${quote}` : filter;
181185
});
182186
});
183187
}

src/PHPUnit/TestRunner.test.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,6 @@ describe('TestRunner Test', () => {
346346

347347
await shouldRunTestFailed(expected, builder, projectPath, appPath);
348348
});
349-
350-
it('should run test failed with phpvfscomposer for Docker', async () => {
351-
const expected = [
352-
'php',
353-
appPath('vendor/bin/phpunit'),
354-
`--configuration=${appPath('phpunit.xml')}`,
355-
`--filter=^.*::(test_passed|test_failed)( with data set .*)?$`,
356-
appPath('tests/AssertionsTest.php'),
357-
'--colors=never',
358-
'--teamcity',
359-
];
360-
361-
await shouldRunTestFailed(expected, builder, projectPath, appPath, true);
362-
});
363349
});
364350

365351
describe('SSH', () => {
@@ -441,7 +427,7 @@ describe('TestRunner Test', () => {
441427
'php',
442428
'vendor/bin/phpunit',
443429
`--configuration=${appPath('phpunit.xml')}`,
444-
`--filter=^.*::(test_passed)( with data set .*)?$`,
430+
`'--filter=^.*::(test_passed)( with data set .*)?$'`,
445431
appPath('tests/AssertionsTest.php'),
446432
`--colors=never`,
447433
`--teamcity`,
@@ -467,7 +453,7 @@ describe('TestRunner Test', () => {
467453
'php',
468454
'vendor/bin/phpunit',
469455
`--configuration=${appPath('phpunit.xml')}`,
470-
`--filter=^.*::(test_passed|test_failed)( with data set .*)?$`,
456+
`'--filter=^.*::(test_passed|test_failed)( with data set .*)?$'`,
471457
appPath('tests/AssertionsTest.php'),
472458
`--colors=never`,
473459
`--teamcity`,
@@ -493,7 +479,7 @@ describe('TestRunner Test', () => {
493479
'php',
494480
'vendor/bin/phpunit',
495481
`--configuration=${appPath('phpunit.xml')}`,
496-
`--filter=^.*::(test_passed|test_failed)( with data set .*)?$`,
482+
`'--filter=^.*::(test_passed|test_failed)( with data set .*)?$'`,
497483
appPath('tests/AssertionsTest.php'),
498484
`--colors=never`,
499485
`--teamcity`,

0 commit comments

Comments
 (0)