@@ -8,54 +8,55 @@ Deno.test("exec", { sanitizeResources: false, sanitizeOps: false }, async () =>
88
99 const useRunSpy = spy ( useRunInternals , "nativeRun" )
1010 try {
11- await run ( [ "node" , "--version" ] )
11+ await run ( [ "node" , "--version" ] )
1212 } finally {
1313 useRunSpy . restore ( )
1414 }
1515
16- assertEquals ( useRunSpy . calls [ 0 ] . args [ 0 ] . cmd , [ "node" , "--version" ] , "should have run node --version" )
16+ const foo = [ useRunSpy . calls [ 0 ] . args [ 0 ] , ...useRunSpy . calls [ 0 ] . args [ 1 ] . args ! ]
17+ assertEquals ( foo , [ "node" , "--version" ] , "should have run node --version" )
1718} )
1819
19- Deno . test ( "forward env to exec" , { sanitizeResources : false , sanitizeOps : false } , async ( ) => {
20+ Deno . test ( "forward env to exec" , { sanitizeResources : false , sanitizeOps : false } , async ( ) => {
2021 const { run, TEA_PREFIX , useRunInternals } = await createTestHarness ( )
2122
2223 const useRunSpy = spy ( useRunInternals , "nativeRun" )
2324 try {
24- await run ( [ "sh" , "-c" , "echo $TEA_PREFIX" ] )
25+ await run ( [ "sh" , "-c" , "echo $TEA_PREFIX" ] )
2526 } finally {
2627 useRunSpy . restore ( )
2728 }
2829
29- assertEquals ( useRunSpy . calls [ 0 ] . args [ 0 ] . env ?. [ "TEA_PREFIX" ] , TEA_PREFIX . string )
30+ assertEquals ( useRunSpy . calls [ 0 ] . args [ 1 ] . env ?. [ "TEA_PREFIX" ] , TEA_PREFIX . string )
3031} )
3132
3233Deno . test ( "exec run errors" , { sanitizeResources : false , sanitizeOps : false } , async test => {
3334 const tests = [
3435 {
3536 name : "exit error" ,
36- procStatus : ( ) : Promise < Deno . ProcessStatus > => Promise . resolve ( { success : false , code : 123 } ) ,
37+ procStatus : ( ) : Promise < Deno . CommandStatus > => Promise . resolve ( { success : false , code : 123 , signal : null } ) ,
3738 expectedErr : "exiting with code: 123" ,
38- } ,
39+ } ,
3940 {
4041 name : "normal error" ,
41- procStatus : ( ) : Promise < Deno . ProcessStatus > => Promise . reject ( new Error ( "test error" ) ) ,
42+ procStatus : ( ) : Promise < Deno . CommandStatus > => Promise . reject ( new Error ( "test error" ) ) ,
4243 expectedErr : "exiting with code: 1" ,
43- } ,
44+ } ,
4445 {
4546 name : "tea error" ,
46- procStatus : ( ) : Promise < Deno . ProcessStatus > => Promise . reject ( new TeaError ( "confused: interpreter" , { } ) ) ,
47+ procStatus : ( ) : Promise < Deno . CommandStatus > => Promise . reject ( new TeaError ( "confused: interpreter" , { } ) ) ,
4748 expectedErr : "exiting with code: 1" ,
48- } ,
49+ } ,
4950 {
5051 name : "not found" ,
51- procStatus : ( ) : Promise < Deno . ProcessStatus > => Promise . reject ( new Deno . errors . NotFound ( ) ) ,
52+ procStatus : ( ) : Promise < Deno . CommandStatus > => Promise . reject ( new Deno . errors . NotFound ( ) ) ,
5253 expectedErr : "exiting with code: 127" ,
53- } ,
54+ } ,
5455 {
5556 name : "permission denied" ,
56- procStatus : ( ) : Promise < Deno . ProcessStatus > => Promise . reject ( new Deno . errors . PermissionDenied ( ) ) ,
57+ procStatus : ( ) : Promise < Deno . CommandStatus > => Promise . reject ( new Deno . errors . PermissionDenied ( ) ) ,
5758 expectedErr : "exiting with code: 127" ,
58- } ,
59+ } ,
5960 ]
6061
6162 for ( const { name, procStatus, expectedErr } of tests ) {
@@ -66,7 +67,7 @@ Deno.test("exec run errors", { sanitizeResources: false, sanitizeOps: false }, a
6667 const useRunStub = stub ( useRunInternals , "nativeRun" , returnsNext ( [ mockProc ] ) )
6768 await assertRejects ( async ( ) => {
6869 try {
69- await run ( [ "node" , "--version" ] )
70+ await run ( [ "node" , "--version" ] )
7071 } finally {
7172 useRunStub . restore ( )
7273 }
@@ -76,7 +77,7 @@ Deno.test("exec run errors", { sanitizeResources: false, sanitizeOps: false }, a
7677} )
7778
7879Deno . test ( "exec forkbomb protector" , { sanitizeResources : false , sanitizeOps : false } , async ( ) => {
79- const { run } = await createTestHarness ( )
80+ const { run } = await createTestHarness ( )
8081 await assertRejects (
8182 ( ) => run ( [ "sh" , "-c" , "echo $TEA_PREFIX" ] , { env : { TEA_FORK_BOMB_PROTECTOR : "21" } } ) ,
8283 "FORK BOMB KILL SWITCH ACTIVATED" )
0 commit comments