ft: verbose flag for compile and minimal logging adjustments
This commit is contained in:
@@ -20,7 +20,9 @@ from auto_grader.utils import build_root, clean_root
|
||||
help='Overrides command that is run to build roots. The default command is `make distclean`.')
|
||||
@click.option('-t', '--timeout', default=10, type=click.INT,
|
||||
help='Sets timeout of both clean and build commands, defaults to 10s.')
|
||||
def compile(number, path, command, student, timeout, clean_command):
|
||||
@click.option('--verbose', is_flag=True, default=False,
|
||||
help='Sets timeout of both clean and build commands, defaults to 10s.')
|
||||
def compile(number, path, command, student, timeout, clean_command, verbose):
|
||||
current_wd = os.getcwd()
|
||||
students = os.listdir(path)
|
||||
if student and student not in students:
|
||||
@@ -51,7 +53,11 @@ def compile(number, path, command, student, timeout, clean_command):
|
||||
f"{indent_text('[CLEAN]:' + clean_log.oneline(type_as_prefix=False), 4)}")
|
||||
continue
|
||||
log = build_root(root, command, timeout=timeout)
|
||||
click.echo(f"{indent_text(log.oneline(type_as_prefix=False), 4)}")
|
||||
if not verbose:
|
||||
click.echo(
|
||||
f"{indent_text(log.oneline(type_as_prefix=False), 4)}")
|
||||
else:
|
||||
click.echo(f"{indent_text(log.as_str(),4)}")
|
||||
clean_log = clean_root(root, clean_command)
|
||||
if not clean_log.run_success or not clean_log.cmd_return_code == 0:
|
||||
click.echo(
|
||||
|
||||
@@ -219,10 +219,10 @@ def dissect(number, solution_path, path):
|
||||
shlex.split(command), capture_output=True, text=True, timeout=10)
|
||||
if result.returncode == 0:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[BUILD]:[{function}]:{SUCCESS_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[BUILD]:{SUCCESS_BOX}")
|
||||
else:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[BUILD]:[{function}]:{ERROR_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[BUILD]:{ERROR_BOX}")
|
||||
click.echo(f"\t\tstderr: {result.stderr[:61]:61s}...")
|
||||
continue
|
||||
|
||||
@@ -238,14 +238,14 @@ def dissect(number, solution_path, path):
|
||||
except subprocess.TimeoutExpired:
|
||||
result.returncode = 1
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[RUN]:[{function}]:{ERROR_BOX} -- Timeout")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[RUN]:{ERROR_BOX} -- Timeout")
|
||||
|
||||
if result.returncode == 0:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[RUN]:[{function}]:{SUCCESS_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[RUN]:{SUCCESS_BOX}")
|
||||
else:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[RUN]:[{function}]:{ERROR_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[RUN]:{ERROR_BOX}")
|
||||
click.echo(f"\t\tstderr: {result.stderr[:61]:61s}...")
|
||||
continue
|
||||
|
||||
@@ -254,9 +254,9 @@ def dissect(number, solution_path, path):
|
||||
|
||||
if np.allclose(ref_sol_data, usr_sol_data, rtol=1e-1) == 0:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[CORRECT]:[{function}]:{SUCCESS_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[CORRECT]:{SUCCESS_BOX}")
|
||||
else:
|
||||
click.echo(
|
||||
f"\t[{os.path.basename(root)}]:[CORRECT]:[{function}]:{ERROR_BOX}")
|
||||
f"\t[{os.path.basename(root)}]:[{function}]:[CORRECT]:{ERROR_BOX}")
|
||||
continue
|
||||
os.chdir(current_wd)
|
||||
|
||||
@@ -49,6 +49,7 @@ def run(
|
||||
clean_command,
|
||||
exe_name
|
||||
):
|
||||
print("NOT IMPLEMENTED")
|
||||
pass
|
||||
# current_wd = os.getcwd()
|
||||
# students = os.listdir(path)
|
||||
|
||||
Reference in New Issue
Block a user