1- import { stripGclVariableEnvVars , injectGclVariableEnvVars } from "../../../src/argv.js" ;
1+ import { stripGclVariableEnvVars , injectGclVariableEnvVars , Argv } from "../../../src/argv.js" ;
22import { execFile } from "child_process" ;
33import { promisify } from "util" ;
4+ import { WriteStreamsMock } from "../../../src/write-streams.js" ;
45
56const execFileAsync = promisify ( execFile ) ;
67
@@ -23,11 +24,11 @@ describe("stripGclVariableEnvVars", () => {
2324 expect ( env [ "GCL_CWD" ] ) . toBe ( "/tmp" ) ;
2425 } ) ;
2526
26- test ( "skips GCL_VARIABLE_ with empty name" , ( ) => {
27+ test ( "strips GCL_VARIABLE_ with empty name from env but does not return it " , ( ) => {
2728 const env : Record < string , string | undefined > = { "GCL_VARIABLE_" : "empty" } ;
2829 const stripped = stripGclVariableEnvVars ( env ) ;
2930 expect ( stripped ) . toEqual ( { } ) ;
30- expect ( env [ "GCL_VARIABLE_" ] ) . toBe ( "empty" ) ;
31+ expect ( env [ "GCL_VARIABLE_" ] ) . toBeUndefined ( ) ;
3132 } ) ;
3233
3334 test ( "skips null/undefined values" , ( ) => {
@@ -92,6 +93,28 @@ describe("injectGclVariableEnvVars", () => {
9293 } ) ;
9394} ) ;
9495
96+ describe ( "Argv.ignorePredefinedVars" , ( ) => {
97+ test ( "returns empty array by default" , async ( ) => {
98+ const argv = await Argv . build ( { cwd : "tests/test-cases/gcl-variable-env" } , new WriteStreamsMock ( ) ) ;
99+ expect ( argv . ignorePredefinedVars ) . toEqual ( [ ] ) ;
100+ } ) ;
101+
102+ test ( "handles array input" , async ( ) => {
103+ const argv = await Argv . build ( { cwd : "tests/test-cases/gcl-variable-env" , ignorePredefinedVars : [ "VAR1" , "VAR2" ] } , new WriteStreamsMock ( ) ) ;
104+ expect ( argv . ignorePredefinedVars ) . toEqual ( [ "VAR1" , "VAR2" ] ) ;
105+ } ) ;
106+
107+ test ( "splits comma-separated values in array elements" , async ( ) => {
108+ const argv = await Argv . build ( { cwd : "tests/test-cases/gcl-variable-env" , ignorePredefinedVars : [ "VAR1,VAR2" ] } , new WriteStreamsMock ( ) ) ;
109+ expect ( argv . ignorePredefinedVars ) . toEqual ( [ "VAR1" , "VAR2" ] ) ;
110+ } ) ;
111+
112+ test ( "handles string input for backwards compatibility" , async ( ) => {
113+ const argv = await Argv . build ( { cwd : "tests/test-cases/gcl-variable-env" , ignorePredefinedVars : "VAR1,VAR2" } , new WriteStreamsMock ( ) ) ;
114+ expect ( argv . ignorePredefinedVars ) . toEqual ( [ "VAR1" , "VAR2" ] ) ;
115+ } ) ;
116+ } ) ;
117+
95118test ( "GCL_VARIABLE_* env vars are injected into job output via CLI" , async ( ) => {
96119 const { stdout} = await execFileAsync ( "bun" , [ "src/index.ts" , "test-job" , "--cwd" , "tests/test-cases/gcl-variable-env" ] , {
97120 env : {
0 commit comments