Commit 927fcab9 authored by Kenneth Ryan Hancock's avatar Kenneth Ryan Hancock
Browse files

Merge branch 'bugfix/a2userspace' into 'master'

Bugfix: Failing test msgs are now shown to users

See merge request !8
parents 43421f9b 3601f30a
...@@ -37,6 +37,9 @@ for article in numarticles : ...@@ -37,6 +37,9 @@ for article in numarticles :
#save the seed generated #save the seed generated
seed = str(random.randint(1, 100)) seed = str(random.randint(1, 100))
#set default success message
buffer = "Test: article (%d), seed (%s), thread (%d) passes" % (article, seed, thread)
#run the command and capture stderr output #run the command and capture stderr output
command = f"timeout 100s {inputFileName} {article} {seed} {thread} 2> temp.txt > /dev/null" command = f"timeout 100s {inputFileName} {article} {seed} {thread} 2> temp.txt > /dev/null"
resultValue = os.system(command) resultValue = os.system(command)
...@@ -44,9 +47,11 @@ for article in numarticles : ...@@ -44,9 +47,11 @@ for article in numarticles :
#check if the resulting funnction fails #check if the resulting funnction fails
if resultValue == 124: if resultValue == 124:
buffer = "Test: article (%d), seed (%s), thread (%d) TIMEDOUT" % (article, seed, thread) buffer = "Test: article (%d), seed (%s), thread (%d) TIMEDOUT" % (article, seed, thread)
output.append(buffer)
continue continue
elif resultValue != 0 : elif resultValue != 0 :
buffer = "Test: article (%d), seed (%s), thread (%d) fails" % (article, seed, thread) buffer = "Test: article (%d), seed (%s), thread (%d) fails" % (article, seed, thread)
output.append(buffer)
continue continue
else : else :
checks += 1 checks += 1
...@@ -55,25 +60,24 @@ for article in numarticles : ...@@ -55,25 +60,24 @@ for article in numarticles :
#counts the number of iterations in the check #counts the number of iterations in the check
iteration = 0 iteration = 0
#set default success message
buffer = "Test: article (%d), seed (%s), thread (%d) passes" % (article, seed, thread)
#for each line of error code #for each line of error code
for line in file : for line in file :
#iterate the counter #iterate the counter
iteration += 1 iteration += 1
output.append(line)
#if we are at the final line of the output #if we are at the final line of the output
if iteration == 3 : if iteration == 3 :
#if the multithreaded segment fails #if the multithreaded segment fails
if line.strip() == "ERROR: Please fix any bottlenecks in the code." : if line.strip() == "ERROR: Please fix any bottlenecks in the code." :
checks -= 0.5 checks -= 0.5
buffer = "Test: article (%d), seed (%s), thread (%d) fails multithreading test" % (article, seed, thread) buffer += "Test: article (%d), seed (%s), thread (%d) fails multithreading test" % (article, seed, thread)
#if the single threaded segment fails #if the single threaded segment fails
elif line.strip() == "ERROR: Please check for race conditions or other bugs." : elif line.strip() == "ERROR: Please check for race conditions or other bugs." :
checks -= 1 checks -= 1
buffer = "Test: article (%d), seed (%s), thread (%d) fails single threaded test" % (article, seed, thread) buffer += "Test: article (%d), seed (%s), thread (%d) fails single threaded test" % (article, seed, thread)
#END IF #END IF
#END IF #END IF
#END FOR #END FOR
......
...@@ -3,10 +3,16 @@ def a2q1(tests, helpers): ...@@ -3,10 +3,16 @@ def a2q1(tests, helpers):
grade = 0 grade = 0
cmts = set() cmts = set()
tests = [t for t in tests if "a2q1" in t.name] tests = [t for t in tests if "a2q1" in t.name]
error_messages = ""
for t in tests: for t in tests:
# get the lines from the output # get the lines from the output
l = t.results().split("\n") l = t.results().split("\n")
failed_tests = [s for s in l if "fails" in s]
for entry in failed_tests:
cmts.add(entry)
grade = int(l[-1].split(":")[1].strip().split("/")[0]) grade = int(l[-1].split(":")[1].strip().split("/")[0])
except: except:
...@@ -23,6 +29,11 @@ def a2q2(tests, helpers): ...@@ -23,6 +29,11 @@ def a2q2(tests, helpers):
# get the lines from the output # get the lines from the output
l = t.results().split("\n") l = t.results().split("\n")
failed_tests = [s for s in l if "fails" in s]
for entry in failed_tests:
cmts.add(entry)
grade = int(l[-1].split(":")[1].strip().split("/")[0]) grade = int(l[-1].split(":")[1].strip().split("/")[0])
except: except:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment