Skip to content

Commit 4267ad3

Browse files
authored
Fix unicode unit test (#400)
Fixes #393 * remove encoding property from spawn options
1 parent 713c6eb commit 4267ad3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/client/common/process/proc.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export class ProcessService implements IProcessService {
1515
constructor( @inject(IBufferDecoder) private decoder: IBufferDecoder) { }
1616
public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult<string> {
1717
const encoding = options.encoding = typeof options.encoding === 'string' && options.encoding.length > 0 ? options.encoding : DEFAULT_ENCODING;
18+
delete options.encoding;
1819
const spawnOptions = { ...options };
1920
if (!spawnOptions.env || Object.keys(spawnOptions).length === 0) {
20-
spawnOptions.env = process.env;
21+
spawnOptions.env = { ...process.env };
2122
}
2223

2324
// Always ensure we have unbuffered output.
@@ -74,9 +75,10 @@ export class ProcessService implements IProcessService {
7475
}
7576
public async exec(file: string, args: string[], options: SpawnOptions = {}): Promise<ExecutionResult<string>> {
7677
const encoding = options.encoding = typeof options.encoding === 'string' && options.encoding.length > 0 ? options.encoding : DEFAULT_ENCODING;
78+
delete options.encoding;
7779
const spawnOptions = { ...options };
7880
if (!spawnOptions.env || Object.keys(spawnOptions).length === 0) {
79-
spawnOptions.env = process.env;
81+
spawnOptions.env = { ...process.env };
8082
}
8183

8284
// Always ensure we have unbuffered output.

src/test/common/process/proc.exec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ suite('ProcessService', () => {
3535
test('exec should output print unicode characters', async () => {
3636
const procService = new ProcessService(new BufferDecoder());
3737
const printOutput = 'öä';
38-
const result = await procService.exec(pythonPath, ['-c', `print(u"${printOutput}")`]);
38+
const result = await procService.exec(pythonPath, ['-c', `print("${printOutput}")`]);
3939

4040
expect(result).not.to.be.an('undefined', 'result is undefined');
4141
expect(result.stdout.trim()).to.be.equal(printOutput, 'Invalid output');

0 commit comments

Comments
 (0)