Skip to content

Commit

Permalink
merge new upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
emarteca committed Aug 21, 2023
2 parents 98a8bda + e9e9860 commit e3195b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/TestInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ class TestInfo:
}
# extra args, their position in the arg list, and any post-processing required
# post-processing is a function that takes 2 arguments: input file and output file
# CAUTION: DO NOT PUT ANY MORE ARGS AFTER PLACEHOLDER_OUTPUT_FILE_NAME. THE CODE THAT
# PARSES THE OUTPUT RELIES ON THIS BEING THE *LAST* ARGUMENT
VERBOSE_TESTS_EXTRA_ARGS = {
"jest": {
"args": " --verbose --json --outputFile=$PLACEHOLDER_OUTPUT_FILE_NAME$",
"args": " --verbose --json -i --outputFile=$PLACEHOLDER_OUTPUT_FILE_NAME$",
"position": -1,
"post_processing": TestOutputProc.parse_jest_json_to_csv
},
Expand Down Expand Up @@ -116,6 +118,8 @@ def __init__(self, success, error_stream, output_stream, manager, VERBOSE_MODE):
self.timed_out = False
self.VERBOSE_MODE = VERBOSE_MODE
self.test_verbosity_output = None
self.startTime = 0
self.endTime = 0

def set_test_command( self, test_command):
self.test_command = test_command
Expand Down Expand Up @@ -194,6 +198,8 @@ def get_json_rep( self):
if self.test_verbosity_output:
json_rep["test_verbosity_output"] = self.test_verbosity_output
json_rep["timed_out"] = self.timed_out
json_rep["start_time"] = self.start_time
json_rep["end_time"] = self.end_time
return( json_rep)

def __str__(self):
Expand Down
11 changes: 11 additions & 0 deletions src/test_JS_repo_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import json
import os
import time
from TestInfo import *

def run_command( commands, timeout=None):
Expand Down Expand Up @@ -117,6 +118,9 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
test_command = pkg_json.get("scripts", {})[t]
test_infras = TestInfo.get_test_infras_list(test_command, manager)
test_verbosity_output = {}
# initialize these variables for timing; they'll be set before/after running test commands (resp)
start_time = 0
end_time = 0
# 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)
Expand Down Expand Up @@ -145,7 +149,10 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
with open("package.json", 'w') as f:
json.dump( pkg_json, f)
print("Running verbosity: " + manager + infra_verbosity_command)
# time how long the next line takes
start_time = time.time()
error, output, retcode = run_command( manager + verbosity_script_name, crawler.TEST_TIMEOUT)
end_time = time.time()
# 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 @@ -163,12 +170,16 @@ def run_tests( manager, pkg_json, crawler, repo_name, cur_dir="."):
run_command( "mv TEMP_package.json_TEMP package.json")
# not verbose test mode -- just run the normal test command
else:
start_time = time.time()
error, output, retcode = run_command( manager + t, crawler.TEST_TIMEOUT)
end_time = time.time()
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)
test_info.start_time = start_time
test_info.end_time = end_time
# 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()
Expand Down

0 comments on commit e3195b3

Please sign in to comment.