Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Matthew P. Russell
unit_test
Commits
fe6e3adb
Commit
fe6e3adb
authored
Jan 06, 2021
by
Matthew P. Russell
Browse files
changed scoring paradigm to be tests passed / total tests
parent
c2e4935e
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/unit_test
View file @
fe6e3adb
...
...
@@ -118,33 +118,11 @@ inform("tests were set up successfully", color=SUCCESS)
# initialize variables for keeping track of the grade #
#-----------------------------------------------------------------------------#
# total points
overall_score
=
100.0
# total points valgrind tests are worth
valgrind_score
=
15.0
# number of points the standard tests are worth
standard_score
=
overall_score
-
valgrind_score
# score keeps track of the student's overall score
score
=
0.0
# test_results stores the results of the regular tests
standard_test_results
=
[]
# valgrind_test_results stores the results of the valgrind tests
valgrind_test_results
=
[]
# how many tests there are
num_tests
=
len
(
test_names
)
# points per standard test
standard_test_max
=
round
(
standard_score
/
num_tests
,
3
)
# points per valgrind test
valgrind_test_max
=
round
(
valgrind_score
/
num_tests
,
3
)
num_tests_passed
=
0
num_valgrind_passed
=
0
#-----------------------------------------------------------------------------#
# compile the tests #
...
...
@@ -164,7 +142,6 @@ else:
cleanup
()
sys
.
exit
(
1
)
#-----------------------------------------------------------------------------#
# run the tests #
#-----------------------------------------------------------------------------#
...
...
@@ -179,7 +156,7 @@ for test in test_names:
universal_newlines
=
True
)
#test was successful
if
test_result
.
returncode
==
0
:
score
+=
standard_test_max
num_tests_passed
+=
1
inform
(
"test passed"
,
color
=
SUCCESS
)
...
...
@@ -214,7 +191,7 @@ for test in test_names:
if
valgrind_passed
:
inform
(
"valgrind passed"
,
color
=
SUCCESS
)
score
+=
valgrind_test_max
num_valgrind_passed
+=
1
else
:
inform
(
"valgrind failed"
,
color
=
FAILURE
)
inform
(
VALGRIND_RESULT
.
stderr
,
color
=
FAILURE
)
...
...
@@ -234,17 +211,12 @@ for test in test_names:
std_out
(
"stderr"
,
linebreak
=
True
)
inform
(
test_result
.
stderr
,
color
=
OUTPUT
)
inform
(
str
(
num_tests_passsed
)
+
" / "
+
str
(
num_tests
)
+
" tests passed"
,
color
=
INFO
)
# make sure final score is <= max (might happen b/c we're rounding)
final_score
=
min
([
overall_score
,
round
(
score
,
2
)])
# don't sandbag anyone b/c rounding
if
final_score
>
99
:
final_score
=
100
inform
(
"final score: "
+
str
(
final_score
)
+
" / "
+
str
(
overall_score
),
color
=
INFO
)
inform
(
str
(
num_valgrind_passsed
)
+
" / "
+
str
(
num_tests
)
+
" valgrind tests passed"
,
color
=
INFO
)
# clean up
subprocess
.
run
([
'make'
,
'clean'
])
cleanup
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment