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