-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestInvalid
More file actions
executable file
·50 lines (40 loc) · 1.33 KB
/
testInvalid
File metadata and controls
executable file
·50 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/ruby
#script to run all valid tests through our wacc language.
# USAGE: ./tests {dirOfTests} {showOutput}?
# for showOutput, leave empty for true, anything for false
#build parser
puts `make`
$num_tests = 0
$num_tests_failed = 0
def run_tests(dir, show_out)
Dir.foreach(dir) do | item |
next if item == "." or item == ".."
if File.directory?(dir+"/"+item)
run_tests(dir+"/"+item, show_out)
elsif File.extname(item) == ".wacc"
puts "\n#{dir + "/" + item}\n"
out = `./compile #{dir+"/"+item} 2>&1`
puts out unless show_out
$num_tests += 1
if out.include? "error" or out.include? "Error" or out.include? "line"
$num_tests_failed += 1
puts "\e[32mTEST FAILED\e[0m"
else
puts "\e[31mTEST PASSED\e[0m"
end
#puts out unless out.include?("error")
end
end
end
puts "==================================================================="
puts "Running tests..."
puts "==================================================================="
tests_dir = "../wacc_examples/invalid"
if ARGV.empty?
run_tests(tests_dir, true)
else
run_tests(tests_dir + "/" + ARGV[0], false)
end
puts "==================================================================="
puts "...Tests finished = #{$num_tests - $num_tests_failed}/#{$num_tests} PASSED"
puts "==================================================================="