Commit 3601f30a authored by Tejasvi Kashi's avatar Tejasvi Kashi
Browse files

Bugfix: Failing test msgs are now shown to users

parent 49bf07d9
......@@ -37,6 +37,9 @@ for article in numarticles :
#save the seed generated
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
command = f"timeout 10s {inputFileName} {article} {seed} {thread} 2> temp.txt > /dev/null"
resultValue = os.system(command)
......@@ -44,9 +47,11 @@ for article in numarticles :
#check if the resulting funnction fails
if resultValue == 124:
buffer = "Test: article (%d), seed (%s), thread (%d) TIMEDOUT" % (article, seed, thread)
output.append(buffer)
continue
elif resultValue != 0 :
buffer = "Test: article (%d), seed (%s), thread (%d) fails" % (article, seed, thread)
output.append(buffer)
continue
else :
checks += 1
......@@ -55,24 +60,23 @@ for article in numarticles :
#counts the number of iterations in the check
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 line in file :
#iterate the counter
iteration += 1
output.append(line)
#if we are at the final line of the output
if iteration == 3 :
#if the multithreaded segment fails
if line.strip() == "ERROR: Please fix any bottlenecks in the code." :
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
elif line.strip() == "ERROR: Please check for race conditions or other bugs." :
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 FOR
......
......@@ -47,9 +47,11 @@ for consumer in numConsumers :
#check if the resulting funnction fails
if resultValue == 124:
buffer = "Test timeout: consumers (%d), producers (%d), ratio (%d) fails" % (consumer, producer, ratio)
output.append(buffer)
continue
elif resultValue != 0 :
buffer = "Test: consumers (%d), producers (%d), ratio (%d) fails" % (consumer, producer, ratio)
output.append(buffer)
continue
else :
checks += 1.5
......
......@@ -3,10 +3,16 @@ def a2q1(tests, helpers):
grade = 0
cmts = set()
tests = [t for t in tests if "a2q1" in t.name]
error_messages = ""
for t in tests:
# get the lines from the output
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])
except:
......@@ -23,6 +29,11 @@ def a2q2(tests, helpers):
# get the lines from the output
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])
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