-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_runner.rb
76 lines (56 loc) · 1.53 KB
/
test_runner.rb
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require_relative 'pe'
require_relative 'core/environment/store'
require_relative 'core/environment/store_var'
require 'fileutils'
$debug = true
def initializeDirs
FileUtils.rm_rf("..\\output", secure: true)
FileUtils.mkdir "..\\output"
end
#loop through all the files in the input dir and partial evaluate the files
#and put the residual code in the output folder
def partialEvaluateFiles
pe = PE.new()
Dir.foreach('..\input') { |file|
if (File.fnmatch("*.rb", file))
puts "Start pe of #{file}"
if ($debug)
a = PE.new
a.run(nil, file)
else
system ("ruby pe.rb #{file}")
end
end
}
end
def checkPartialEvaluatedFiles
Dir.foreach('..\ExpectedOutput') { |file|
if (File.fnmatch("*.rb", file))
if (File.exist? "..\\output\\#{file}")
same = FileUtils.compare_file("..\\output\\#{file}", "..\\expectedOutput\\#{file}")
puts "#{file} not identical" if !same
else
puts "#{file} doesn't exist in the output folder.'"
end
end
}
end
def compareResults
Dir.foreach('..\input') { |file|
if (File.fnmatch("*.rb", file))
org = "..\\input\\#{file}"
res = "..\\output\\#{file}"
system("ruby #{org} > ..\\org.txt")
system("ruby #{res} > ..\\res.txt")
same = FileUtils.compare_file("..\\org.txt", "..\\res.txt")
puts "#{file} has not the same output" if !same
end
}
end
#run the unit tests.
#st = StoreTest.new()
#st.run
initializeDirs
partialEvaluateFiles
checkPartialEvaluatedFiles
compareResults