Skip to content

Commit

Permalink
chore: optimise stack execution speed by setting PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
seyhankhan committed Feb 17, 2023
1 parent 69370b9 commit 35d8ba2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions integration_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ def integrationTests():
print(SKIPPED, "skipped")
testSummary = ""
skippedTests = totalTests = 0

wacc40exe = next(Path("./.stack-work/dist").rglob("build/WACC40-exe/WACC40-exe"), None)
if not wacc40exe:
print(RED + "\nWACC40-exe not found - did you", BOLD + "stack build" + END + RED + "?", END)
exit(1)

for testDir in TESTS:
print("\n" + testDir)
for waccFilename in Path("./test/integration/" + testDir).rglob("*.wacc"):
totalTests += 1
result = subprocess.run(
["sh", "compile", waccFilename],
[str(wacc40exe), waccFilename],
stdout=None if VIEW_HASKELL_OUTPUT else subprocess.DEVNULL
)

Expand Down Expand Up @@ -68,10 +74,10 @@ def integrationTests():
print()
for testname, expectedOutput, actualOutput in failedTests:
print(LIGHT_RED, "--> Failed " + f"{testname}"[17:-5])
print(BLUE, "\t", "Expected:", YELLOW)
print(YELLOW, "\t", "Expected:", END)
for line in expectedOutput.split("\n"):
print("\t\t" + line)
print(BLUE, "\t", "Actual:", YELLOW)
print(YELLOW, "\t", "Actual:", END)
for line in actualOutput.split("\n"):
print("\t\t" + line)

Expand Down
6 changes: 3 additions & 3 deletions src/semanticAnalysis/SemanticErrors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ printSemanticErrors errs contents fname = putStrLn $ concatMap printSemanticErro
file = T.lines contents

printSemanticError :: SemanticError -> String
printSemanticError semErr = previewLocation semErr ++ previewCode (getPosition semErr) ++ yellow ++ errorMessage semErr ++ reset
printSemanticError semErr = "\n" ++ previewLocation semErr ++ previewCode (getPosition semErr) ++ yellow ++ errorMessage semErr ++ reset

previewLocation :: SemanticError -> String
previewLocation semErr =
Expand Down Expand Up @@ -94,8 +94,8 @@ errorMessage semErr = case semErr of
"The function "
++ func
++ if actual < expected
then " is missing " ++ bold (show (expected - actual)) ++ yellow ++ " arguments"
else " takes " ++ bold (show expected) ++ yellow ++ " arguments but " ++ bold (show actual) ++ yellow ++ " were given"
then " is missing " ++ bold (show (expected - actual)) ++ yellow ++ " arguments\n"
else " takes " ++ bold (show expected) ++ yellow ++ " arguments but " ++ bold (show actual) ++ yellow ++ " were given\n"
where
func = bold (show i) ++ yellow
IllegalReturn _ -> "Return statements outside of functions are not allowed\n" ++ reset
Expand Down

0 comments on commit 35d8ba2

Please sign in to comment.