Skip to content

Commit

Permalink
stop running the non-verbose-instrumented version of test commands if…
Browse files Browse the repository at this point in the history
… we are also running the verbose-instrumented version
  • Loading branch information
emarteca committed Aug 21, 2023
1 parent 265471a commit 98a8bda
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
9 changes: 7 additions & 2 deletions src/TestInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,19 @@ def set_test_command( self, test_command):
def set_test_verbosity_output( self, verbose_output):
self.test_verbosity_output = verbose_output

def get_test_infras_list( test_command, manager):
test_infras = []
test_infras += [ ti for ti in TestInfo.TRACKED_INFRAS if called_in_command(ti, test_command, manager) ]
test_infras += [ ri for ri in TestInfo.TRACKED_RUNNERS if called_in_command(ri, test_command, manager) ]
return( test_infras)

def compute_test_infras( self):
self.test_infras = []
self.test_covs = []
self.test_lints = []
self.nested_test_commands = []
if self.test_command:
self.test_infras += [ ti for ti in TestInfo.TRACKED_INFRAS if called_in_command(ti, self.test_command, self.manager) ]
self.test_infras += [ ri for ri in TestInfo.TRACKED_RUNNERS if called_in_command(ri, self.test_command, self.manager) ]
self.test_infras += TestInfo.get_test_infras_list(self.test_command, self.manager)
self.test_covs += [ TestInfo.TRACKED_COVERAGE[ti] for ti in TestInfo.TRACKED_COVERAGE if called_in_command(ti, self.test_command, self.manager) ]
self.test_lints += [ TestInfo.TRACKED_LINTERS[ti] for ti in TestInfo.TRACKED_LINTERS if called_in_command(ti, self.test_command, self.manager) ]
self.test_infras = list(set(self.test_infras))
Expand Down
34 changes: 21 additions & 13 deletions src/test_JS_repo_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,16 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
for test_rep_index in range(crawler.TEST_COMMAND_REPEATS):
test_rep_id = "" if crawler.TEST_COMMAND_REPEATS == 1 else "testrep_" + str(test_rep_index)
print("Running rep " + str(test_rep_index) + " of " + str(crawler.TEST_COMMAND_REPEATS - 1) + ": " + manager + t)
error, output, retcode = run_command( manager + t, crawler.TEST_TIMEOUT)
test_info = TestInfo( (retcode == 0), error, output, manager, crawler.VERBOSE_MODE)
test_info.set_test_command( pkg_json.get("scripts", {})[t])
test_info.compute_test_infras()
test_info.compute_nested_test_commands( test_scripts)
test_info.compute_test_stats()
test_command = pkg_json.get("scripts", {})[t]
test_infras = TestInfo.get_test_infras_list(test_command, manager)
test_verbosity_output = {}
# if we're in verbose testing mode (i.e. getting all timing info for each test, etc)
# then, we rerun the test commands with all the commands for adding verbose_mode to
# each of the test infras involved (individually)
if crawler.TEST_VERBOSE_ALL_OUTPUT:
# we're gonna be adding our new custom scripts for verbosity testing
run_command( "mv package.json TEMP_package.json_TEMP")
test_verbosity_output = {}
for verbosity_index, test_infra in enumerate(test_info.test_infras):
for verbosity_index, test_infra in enumerate(test_infras):
verbose_test_json = crawler.output_dir + "/" \
+ "repo_" + repo_name + "_" \
+ "test_" + str(test_index) + "_"\
Expand All @@ -142,14 +138,14 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
infra_verbosity_args = infra_verbosity_config.get("args", "")
infra_verbosity_args_pos = infra_verbosity_config.get("position", -1) # default position is at the end
infra_verbosity_post_proc = infra_verbosity_config.get("post_processing", None)
infra_verbosity_command, out_files = instrument_test_command_for_verbose(test_info.test_command, test_infra, infra_verbosity_args,
infra_verbosity_command, out_files = instrument_test_command_for_verbose(test_command, test_infra, infra_verbosity_args,
verbose_test_json, infra_verbosity_args_pos)
verbosity_script_name = "instrumented_verbosity_command_" + str(verbosity_index)
pkg_json["scripts"][verbosity_script_name] = infra_verbosity_command
with open("package.json", 'w') as f:
json.dump( pkg_json, f)
print("Running verbosity: " + manager + infra_verbosity_command)
verb_error, verb_output, verb_retcode = run_command( manager + verbosity_script_name, crawler.TEST_TIMEOUT)
error, output, retcode = run_command( manager + verbosity_script_name, crawler.TEST_TIMEOUT)
# if there's post-processing to be done
if not infra_verbosity_post_proc is None:
for out_file_obj in out_files:
Expand All @@ -160,12 +156,24 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
test_verbosity_infra["command"] = infra_verbosity_command
test_verbosity_infra["output_files"] = out_files
if crawler.VERBOSE_MODE:
test_verbosity_infra["test_debug"] = "\nError output: " + verb_error.decode('utf-8') \
+ "\nOutput stream: " + verb_output.decode('utf-8')
test_verbosity_infra["test_debug"] = "\nError output: " + error.decode('utf-8') \
+ "\nOutput stream: " + output.decode('utf-8')
test_verbosity_output[test_infra] = test_verbosity_infra
test_info.set_test_verbosity_output(test_verbosity_output)
# put the package.json back
run_command( "mv TEMP_package.json_TEMP package.json")
# not verbose test mode -- just run the normal test command
else:
error, output, retcode = run_command( manager + t, crawler.TEST_TIMEOUT)
test_info = TestInfo( (retcode == 0), error, output, manager, crawler.VERBOSE_MODE)
# the below info on the test infras etc is independent of verbose mode: just based on the command itself
test_info.set_test_command( test_command)
test_info.compute_test_infras()
test_info.compute_nested_test_commands( test_scripts)
# note: if we're running in verbose mode, then the stats will be that of the last executed verbose mode
# instrumented version of the test command
test_info.compute_test_stats()
if crawler.TEST_VERBOSE_ALL_OUTPUT:
test_info.set_test_verbosity_output(test_verbosity_output)
# if we're not doing any repeats then don't make another layer of jsons
if crawler.TEST_COMMAND_REPEATS == 1:
test_output_rep = test_info.get_json_rep()
Expand Down

0 comments on commit 98a8bda

Please sign in to comment.