Skip to content

Commit

Permalink
fixing bug in verbose test command instrumentation when theres args
Browse files Browse the repository at this point in the history
  • Loading branch information
emarteca committed Jul 11, 2023
1 parent 83d2179 commit a6bb111
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/TestInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def called_in_command( str_comm, command, manager):
return( True)
if command.find( "cross-env CI=true " + check_comm) > -1:
return( True)
if command.find( "cross-env TZ=utc " + check_comm) > -1:
return( True)
if command.find( "opener " + check_comm) > -1:
return( True)
if command.find( "gulp " + check_comm) > -1:
Expand Down
26 changes: 20 additions & 6 deletions src/test_JS_repo_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,30 @@ def instrument_test_command_for_verbose(test_script, test_infra, infra_verbosity
# split into sub-commands
command_split_chars = [ "&&", ";"]
infra_calls = test_script.split(test_infra)
instrumented_test_command = []
for i, infra_call in enumerate(infra_calls):
real_calls = []
for maybe_call in infra_calls:
# if the last char in the string is not whitespace and not a command delimiter,
# and it's not the last string in the split
# then it's a string that is appended to the front of the name of the infra (e.g., "\"jest\"")
# and not a call
if i < len(infra_calls) - 1 and infra_call != "" and (not infra_call[-1].isspace()) and (not any([infra_call.endswith(s) for s in command_split_chars])):
instrumented_test_command += [ infra_call ]
continue

# rebuild it
if i < len(infra_calls) - 1 and maybe_call != "" and (not maybe_call[-1].isspace()) and (not any([maybe_call.endswith(s) for s in command_split_chars])):
if len(real_calls) > 0:
real_calls[-1] += test_infra + maybe_call
continue
# if the first char in the string is not whitespace and not a command delimiter,
# and it's not the first string in the split
# then it's a string that is appended to the back of the name of the infra (e.g., jest".config.js")
# and not a call either
# rebuild it
if i > 0 and maybe_call != "" and (not maybe_call[0].isspace()) and (not any([maybe_call.startswith(s) for s in command_split_chars])):
if len(real_calls) > 0:
real_calls[-1] += test_infra + maybe_call
continue
real_calls += [ maybe_call ]
infra_calls = real_calls
instrumented_test_command = []
for i, infra_call in enumerate(infra_calls):
# if the current call is empty string
# then this is the call to the testing infra and the next is the arguments
# so, skip this one
Expand Down

0 comments on commit a6bb111

Please sign in to comment.