Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove sys.exit statement in invocation to buildtest build #1677

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions buildtest/builders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ def run(self, cmd, timeout=None):
if not self._retry or ret == 0:
return command

console.print(f"[red]{self} failed to submit job with returncode: {ret}")
console.print(f"[red]{self}: failed to submit job with returncode: {ret}")
console.rule(f"[red]Error Message for {self}")
console.print(f"[red]{' '.join(err_msg)}")

########## Retry for failed tests ##########

print(
f"{self}: Detected failure in running test, will attempt to retry test: {self._retry} times"
console.print(
f"[red]{self}: Detected failure in running test, will attempt to retry test: {self._retry} times"
)
for run in range(1, self._retry + 1):
print(f"{self}: Run - {run}/{self._retry}")
Expand Down Expand Up @@ -515,7 +515,6 @@ def _build_setup(self):

msg = f"Creating test directory: {self.test_root}"
self.logger.debug(msg)
console.print(f"[blue]{self}:[/] {msg}")

self.metadata["testroot"] = self.test_root

Expand All @@ -526,8 +525,6 @@ def _build_setup(self):
msg = f"Creating the stage directory: {self.stage_dir}"
self.logger.debug(msg)

console.print(f"[blue]{self}:[/] {msg}")

self.metadata["stagedir"] = self.stage_dir

# Derive the path to the test script
Expand All @@ -552,6 +549,8 @@ def _build_setup(self):
elif fname.is_file():
shutil.copy2(fname, self.stage_dir)

console.print(f"[blue]{self}[/]: Creating Test Directory: {self.test_root}")

def _write_build_script(self, modules=None, modulepurge=None, unload_modules=None):
"""This method will write the content of build script that is run for when invoking
the builder run method. Upon creating file we set permission of builder script to 755
Expand Down Expand Up @@ -626,7 +625,7 @@ def _write_build_script(self, modules=None, modulepurge=None, unload_modules=Non
self.build_script = dest
self.metadata["build_script"] = self.build_script

console.print(f"[blue]{self}:[/] Writing build script: {self.build_script}")
# console.print(f"[blue]{self}:[/] Writing build script: {self.build_script}")

def _write_test(self):
"""This method is responsible for invoking ``generate_script`` that
Expand Down Expand Up @@ -976,10 +975,7 @@ def post_run_steps(self):

# need these lines after self.copy_stage_files()
console.print(
f"[blue]{self}[/]: Test completed in {self.metadata['result']['runtime']} seconds"
)
console.print(
f"[blue]{self}[/]: Test completed with returncode: {self.metadata['result']['returncode']}"
f"[blue]{self}[/]: Test completed in {self.metadata['result']['runtime']} seconds with returncode: {self.metadata['result']['returncode']}"
)
console.print(
f"[blue]{self}[/]: Writing output file - [green1]{self.metadata['outfile']}"
Expand Down
20 changes: 11 additions & 9 deletions buildtest/buildsystem/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ def comparison_check(builder, comparison_type):
"""

COMPARISON_OPERATIONS = {
"ge": (lambda x, y: x >= y, ">=", "Greater Equal Check"),
"gt": (lambda x, y: x > y, ">", "Greater Check"),
"le": (lambda x, y: x <= y, "<=", "Less Than Equal Check"),
"lt": (lambda x, y: x < y, "<", "Less Than Check"),
"eq": (lambda x, y: x == y, "==", "Equality Check"),
"ne": (lambda x, y: x != y, "!=", "Not Equal Check"),
"ge": (lambda x, y: x >= y, ">="),
"gt": (lambda x, y: x > y, ">"),
"le": (lambda x, y: x <= y, "<="),
"lt": (lambda x, y: x < y, "<"),
"eq": (lambda x, y: x == y, "=="),
"ne": (lambda x, y: x != y, "!="),
}

# a list containing booleans to evaluate reference check for each metric
Expand All @@ -369,9 +369,11 @@ def comparison_check(builder, comparison_type):
metric_names = list(builder.metadata["metrics"].keys())

if comparison_type not in COMPARISON_OPERATIONS:
raise BuildTestError(
# raise BuildTestError(
console.print(
f"comparison_type: {comparison_type} is not a valid comparison type. Valid comparison types are: {list(COMPARISON_OPERATIONS.keys())}"
)
return False

comparison_dict = builder.status[f"assert_{comparison_type}"]
# iterate over each metric in buildspec and determine reference check for each metric
Expand Down Expand Up @@ -418,7 +420,7 @@ def comparison_check(builder, comparison_type):
assert_check.append(False)
continue

comparison_op, symbol, log_message = COMPARISON_OPERATIONS[comparison_type]
comparison_op, symbol = COMPARISON_OPERATIONS[comparison_type]
bool_check = comparison_op(conv_value, ref_value)
console.print(
f"[blue]{builder}[/]: testing metric: {name} if {conv_value} {symbol} {ref_value} - Check: {bool_check}"
Expand All @@ -431,7 +433,7 @@ def comparison_check(builder, comparison_type):
else:
bool_check = all(assert_check)

console.print(f"[blue]{builder}[/]: {log_message}: {bool_check}")
console.print(f"[blue]{builder}[/]: {comparison_type} check: {bool_check}")

return bool_check

Expand Down
8 changes: 3 additions & 5 deletions buildtest/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def build(self):
if self.finished_builders:
update_report(self.finished_builders, self.report_file)

print(f"Writing Logfile to: {self.logfile.name}")
print(f"Writing Logfile to {self.logfile.name}")

self._update_build_history(self.finished_builders)

Expand Down Expand Up @@ -1222,10 +1222,8 @@ def run_phase(self):
"""

console.rule("[bold red]Running Tests")
try:
self.buildexecutor.run(self.builders)
except:
sys.exit()

self.buildexecutor.run(self.builders)

builders = self.buildexecutor.get_validbuilders()
########## TEST SUMMARY ####################
Expand Down
74 changes: 34 additions & 40 deletions buildtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import shutil
import sys
import tempfile
import webbrowser

Expand Down Expand Up @@ -146,45 +145,40 @@ def main():
if args.subcommands in ["build", "bd"]:
stdout_file = tempfile.NamedTemporaryFile(delete=True, suffix=".txt")
with Tee(stdout_file.name):
try:
cmd = BuildTest(
configuration=configuration,
buildspecs=args.buildspec,
exclude_buildspecs=args.exclude,
executors=args.executor,
tags=args.tags,
name=args.name,
exclude_tags=args.exclude_tags,
filter_buildspecs=args.filter,
rebuild=args.rebuild,
stage=args.stage,
testdir=args.testdir,
buildtest_system=system,
report_file=report_file,
maxpendtime=args.maxpendtime,
poll_interval=args.pollinterval,
remove_stagedir=args.remove_stagedir,
retry=args.retry,
account=args.account,
helpfilter=args.helpfilter,
numprocs=args.procs,
numnodes=args.nodes,
modules=args.modules,
modulepurge=args.module_purge,
unload_modules=args.unload_modules,
rerun=args.rerun,
executor_type=args.executor_type,
timeout=args.timeout,
limit=args.limit,
save_profile=args.save_profile,
profile=args.profile,
max_jobs=args.max_jobs,
)
cmd.build()
except (KeyboardInterrupt, SystemExit) as err:
console.print("[red]buildtest build command failed")
console.print(err)
sys.exit(1)
cmd = BuildTest(
configuration=configuration,
buildspecs=args.buildspec,
exclude_buildspecs=args.exclude,
executors=args.executor,
tags=args.tags,
name=args.name,
exclude_tags=args.exclude_tags,
filter_buildspecs=args.filter,
rebuild=args.rebuild,
stage=args.stage,
testdir=args.testdir,
buildtest_system=system,
report_file=report_file,
maxpendtime=args.maxpendtime,
poll_interval=args.pollinterval,
remove_stagedir=args.remove_stagedir,
retry=args.retry,
account=args.account,
helpfilter=args.helpfilter,
numprocs=args.procs,
numnodes=args.nodes,
modules=args.modules,
modulepurge=args.module_purge,
unload_modules=args.unload_modules,
rerun=args.rerun,
executor_type=args.executor_type,
timeout=args.timeout,
limit=args.limit,
save_profile=args.save_profile,
profile=args.profile,
max_jobs=args.max_jobs,
)
cmd.build()

if cmd.build_success():
build_history_dir = cmd.get_build_history_dir()
Expand Down
Loading