@@ -123,16 +123,12 @@ def test_sub_and_quote(self):
123123 ('' , {}, "''" , []),
124124 # No substitutions
125125 ('a' , {}, 'a' , []),
126- # Unused builtin substitutions are fine
126+ # Unused substitition (ok here but error in generate_script)
127127 ('a' , {'FOO' :'foo' }, 'a' , []),
128- # Unused user substitition (ok here but error in generate_script)
129128 ('a' , {'_FOO' :'_foo' }, 'a' , []),
130129 # Defined builtin substitution
131130 ('a$FOOb' , {'FOO' :'foo' }, 'afoob' , ['FOO' ]),
132131 ('a${FOO}b' , {'FOO' :'foo' }, 'afoob' , ['FOO' ]),
133- # Undefined builtin substitution
134- ('a$FOOb' , {}, 'ab' , ['FOO' ]),
135- ('a${FOO}b' , {}, 'ab' , ['FOO' ]),
136132 # Defined user substitution
137133 ('a$_FOOb' , {'_FOO' :'_foo' }, 'a_foob' , ['_FOO' ]),
138134 ('a${_FOO}b' , {'_FOO' :'_foo' }, 'a_foob' , ['_FOO' ]),
@@ -153,6 +149,9 @@ def test_sub_and_quote(self):
153149 self .assertEqual (used , set (expected_used ))
154150
155151 invalid_cases = (
152+ # Undefined builtin substitution
153+ ('a$FOOb' , {}),
154+ ('a${FOO}b' , {}),
156155 # Undefined user substitution
157156 ('a$_FOOb' , {}),
158157 ('a${_FOO}b' , {}),
@@ -293,8 +292,8 @@ def test_generate_command(self):
293292 self .assertIn ("'a builtin substitution'" , command )
294293
295294 step = base_step ._replace (name = 'a $UNSET_BUILTIN substitution' )
296- command = local_cloudbuild . generate_command ( step , subs , set ())
297- self . assertIn ( "'a substitution'" , command )
295+ with self . assertRaises ( ValueError ):
296+ command = local_cloudbuild . generate_command ( step , subs , set () )
298297
299298 step = base_step ._replace (name = 'a $_USER substitution' )
300299 command = local_cloudbuild .generate_command (step , subs , set ())
@@ -308,6 +307,10 @@ def test_generate_command(self):
308307 command = local_cloudbuild .generate_command (step , subs , set ())
309308 self .assertIn ("'a curly brace builtin substitution'" , command )
310309
310+ step = base_step ._replace (name = 'an escaped $$ or $$$$ or $$BUILTIN or $${BUILTIN} is unescaped' )
311+ command = local_cloudbuild .generate_command (step , subs , set ())
312+ self .assertIn ("'an escaped $ or $$ or $BUILTIN or ${BUILTIN} is unescaped'" , command )
313+
311314 def test_generate_script_golden (self ):
312315 config_name = 'cloudbuild_ok.yaml'
313316 config = os .path .join (self .testdata_dir , config_name )
0 commit comments