66import { expect , use } from 'chai' ;
77import * as chaiAsPromised from 'chai-as-promised' ;
88import { CancellationTokenSource } from 'vscode' ;
9- import { BufferDecoder } from '../../../client/common/process/decoder' ;
109import { ProcessService } from '../../../client/common/process/proc' ;
1110import { StdErrError } from '../../../client/common/process/types' ;
1211import { OSType } from '../../../client/common/utils/platform' ;
@@ -26,7 +25,7 @@ suite('ProcessService Observable', () => {
2625 teardown ( initialize ) ;
2726
2827 test ( 'exec should output print statements' , async ( ) => {
29- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
28+ const procService = new ProcessService ( ) ;
3029 const printOutput = '1234' ;
3130 const result = await procService . exec ( pythonPath , [ '-c' , `print("${ printOutput } ")` ] ) ;
3231
@@ -42,7 +41,7 @@ suite('ProcessService Observable', () => {
4241 return this . skip ( ) ;
4342 }
4443
45- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
44+ const procService = new ProcessService ( ) ;
4645 const printOutput = 'öä' ;
4746 const result = await procService . exec ( pythonPath , [ '-c' , `print("${ printOutput } ")` ] ) ;
4847
@@ -53,7 +52,7 @@ suite('ProcessService Observable', () => {
5352
5453 test ( 'exec should wait for completion of program with new lines' , async function ( ) {
5554 this . timeout ( 5000 ) ;
56- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
55+ const procService = new ProcessService ( ) ;
5756 const pythonCode = [
5857 'import sys' ,
5958 'import time' ,
@@ -79,7 +78,7 @@ suite('ProcessService Observable', () => {
7978
8079 test ( 'exec should wait for completion of program without new lines' , async function ( ) {
8180 this . timeout ( 5000 ) ;
82- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
81+ const procService = new ProcessService ( ) ;
8382 const pythonCode = [
8483 'import sys' ,
8584 'import time' ,
@@ -105,7 +104,7 @@ suite('ProcessService Observable', () => {
105104
106105 test ( 'exec should end when cancellationToken is cancelled' , async function ( ) {
107106 this . timeout ( 15000 ) ;
108- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
107+ const procService = new ProcessService ( ) ;
109108 const pythonCode = [
110109 'import sys' ,
111110 'import time' ,
@@ -133,7 +132,7 @@ suite('ProcessService Observable', () => {
133132
134133 test ( 'exec should stream stdout and stderr separately and filter output using conda related markers' , async function ( ) {
135134 this . timeout ( 7000 ) ;
136- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
135+ const procService = new ProcessService ( ) ;
137136 const pythonCode = [
138137 'print(">>>PYTHON-EXEC-OUTPUT")' ,
139138 'import sys' ,
@@ -176,7 +175,7 @@ suite('ProcessService Observable', () => {
176175
177176 test ( 'exec should merge stdout and stderr streams' , async function ( ) {
178177 this . timeout ( 7000 ) ;
179- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
178+ const procService = new ProcessService ( ) ;
180179 const pythonCode = [
181180 'import sys' ,
182181 'import time' ,
@@ -210,29 +209,29 @@ suite('ProcessService Observable', () => {
210209 } ) ;
211210
212211 test ( 'exec should throw an error with stderr output' , async ( ) => {
213- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
212+ const procService = new ProcessService ( ) ;
214213 const pythonCode = [ 'import sys' , 'sys.stderr.write("a")' , 'sys.stderr.flush()' ] ;
215214 const result = procService . exec ( pythonPath , [ '-c' , pythonCode . join ( ';' ) ] , { throwOnStdErr : true } ) ;
216215
217216 await expect ( result ) . to . eventually . be . rejectedWith ( StdErrError , 'a' , 'Expected error to be thrown' ) ;
218217 } ) ;
219218
220219 test ( 'exec should throw an error when spawn file not found' , async ( ) => {
221- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
220+ const procService = new ProcessService ( ) ;
222221 const result = procService . exec ( Date . now ( ) . toString ( ) , [ ] ) ;
223222
224223 await expect ( result ) . to . eventually . be . rejected . and . to . have . property ( 'code' , 'ENOENT' , 'Invalid error code' ) ;
225224 } ) ;
226225
227226 test ( 'exec should exit without no output' , async ( ) => {
228- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
227+ const procService = new ProcessService ( ) ;
229228 const result = await procService . exec ( pythonPath , [ '-c' , 'import sys' , 'sys.exit()' ] ) ;
230229
231230 expect ( result . stdout ) . equals ( '' , 'stdout is invalid' ) ;
232231 expect ( result . stderr ) . equals ( undefined , 'stderr is invalid' ) ;
233232 } ) ;
234233 test ( 'shellExec should be able to run python and filter output using conda related markers' , async ( ) => {
235- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
234+ const procService = new ProcessService ( ) ;
236235 const printOutput = '1234' ;
237236 const result = await procService . shellExec (
238237 `"${ pythonPath } " -c "print('>>>PYTHON-EXEC-OUTPUT');print('${ printOutput } ');print('<<<PYTHON-EXEC-OUTPUT')"` ,
@@ -243,12 +242,12 @@ suite('ProcessService Observable', () => {
243242 expect ( result . stdout . trim ( ) ) . to . be . equal ( printOutput , 'Invalid output' ) ;
244243 } ) ;
245244 test ( 'shellExec should fail on invalid command' , async ( ) => {
246- const procService = new ProcessService ( new BufferDecoder ( ) ) ;
245+ const procService = new ProcessService ( ) ;
247246 const result = procService . shellExec ( 'invalid command' ) ;
248247 await expect ( result ) . to . eventually . be . rejectedWith ( Error , 'a' , 'Expected error to be thrown' ) ;
249248 } ) ;
250249 test ( 'variables can be changed after the fact' , async ( ) => {
251- const procService = new ProcessService ( new BufferDecoder ( ) , process . env ) ;
250+ const procService = new ProcessService ( process . env ) ;
252251 let result = await procService . exec ( pythonPath , [ '-c' , `import os;print(os.environ.get("MY_TEST_VARIABLE"))` ] , {
253252 extraVariables : { MY_TEST_VARIABLE : 'foo' } ,
254253 } ) ;
0 commit comments