4 |
|
|
5 |
|
# Use with cmake build system deployed by NREL |
6 |
|
# Run from [build]/resources |
7 |
< |
# usage: [ruby]test_lib[.rb] (runs all tests with all available cores passed to radiance MP tools) |
7 |
> |
# usage: [ruby]test_lib[.rb] (runs all tests) |
8 |
|
# usage: [ruby]test_lib[.rb] -n [n] -t ['testname', 'all'] |
9 |
|
|
10 |
|
|
13 |
|
require 'etc' |
14 |
|
# default options |
15 |
|
flag = false |
16 |
+ |
|
17 |
|
tst = "all" |
18 |
|
|
19 |
+ |
|
20 |
|
tproc = Etc.nprocessors |
21 |
|
nproc = tproc / 2 # half cores by default, override with -n |
22 |
|
list = ["x", "y", "z"] |
23 |
|
|
24 |
+ |
clean = false |
25 |
+ |
|
26 |
|
# parse arguments |
27 |
|
file = __FILE__ |
28 |
|
ARGV.options do |opts| |
29 |
|
opts.on("-t", "--test=val", String) { |val| tst = val } |
30 |
|
opts.on("-n", "--nproc=val", Integer) { |val| nproc = val } |
31 |
+ |
|
32 |
+ |
opts.on("-c", "--clean") { |val| clean = val} |
33 |
|
opts.parse! |
34 |
|
end |
35 |
|
|
36 |
+ |
# print banner |
37 |
+ |
warn "Radiance Test Library" |
38 |
+ |
|
39 |
+ |
### Cleanup ### |
40 |
+ |
|
41 |
+ |
if clean == true |
42 |
+ |
|
43 |
+ |
puts "cleaning up" |
44 |
+ |
|
45 |
+ |
clean_list = [] |
46 |
+ |
|
47 |
+ |
globs = [ |
48 |
+ |
'../test/renders/*.oct', |
49 |
+ |
'../test/renders/*.amb', |
50 |
+ |
'../test/renders/*_ill.dat', |
51 |
+ |
'../test/renders/blinds_ill?.dat', |
52 |
+ |
'../test/renders/*_*.hdr', |
53 |
+ |
'../test/renders/*.unf', |
54 |
+ |
'./test/gen/gen*.rad' |
55 |
+ |
] |
56 |
+ |
|
57 |
+ |
globs.each do |glob| |
58 |
+ |
add_list = Dir.glob(glob) |
59 |
+ |
(clean_list << add_list).flatten! |
60 |
+ |
end |
61 |
+ |
|
62 |
+ |
#*.[cg]pm{,.leaf} |
63 |
+ |
|
64 |
+ |
add_files = [ |
65 |
+ |
|
66 |
+ |
'../test/renders/inst_rad.txt', |
67 |
+ |
'../test/renders/combined.rad', |
68 |
+ |
'../test/renders/fmirror.mtx', |
69 |
+ |
'../test/gen/replmarks.rad', |
70 |
+ |
'../test/util/test.mtx', |
71 |
+ |
'../test/cal/cnt.txt', |
72 |
+ |
'../test/cal/rcalc.txt', |
73 |
+ |
'../test/cal/total.txt', |
74 |
+ |
'../test/cal/histo.txt', |
75 |
+ |
'../test/cal/rlam.txt' |
76 |
+ |
|
77 |
+ |
] |
78 |
+ |
(clean_list << add_files).flatten! |
79 |
+ |
|
80 |
+ |
clean_list.each do |rmfile| |
81 |
+ |
if File.exist?(rmfile) |
82 |
+ |
File.delete(rmfile) |
83 |
+ |
puts "deleted #{rmfile}" |
84 |
+ |
end |
85 |
+ |
end |
86 |
+ |
exit |
87 |
+ |
|
88 |
+ |
end |
89 |
+ |
|
90 |
+ |
## END Cleanup ## |
91 |
+ |
|
92 |
|
# print opts |
93 |
< |
warn "ARGV: #{ARGV.inspect}" |
94 |
< |
warn "test: #{tst.inspect}" |
33 |
< |
warn "cores: #{nproc.inspect} (of #{tproc} total)" |
93 |
> |
warn "test: #{tst.inspect}" |
94 |
> |
warn "using #{nproc.inspect} cores (of #{tproc} total)" |
95 |
|
|
96 |
|
test_in = tst |
97 |
|
|
107 |
|
'test_total', 'test_histo', 'test_rlam' |
108 |
|
] |
109 |
|
|
110 |
+ |
|
111 |
+ |
# report pass/fail status |
112 |
+ |
|
113 |
|
def rcpf |
114 |
|
if $?.exitstatus == 0 |
115 |
|
@test_pass +=1 |
116 |
|
|
117 |
< |
puts "test: PASS" |
117 |
> |
puts "result: PASS" |
118 |
|
else |
119 |
|
@test_fail +=1 |
120 |
< |
puts "test: FAIL" |
120 |
> |
puts "result: FAIL" |
121 |
> |
|
122 |
|
end |
123 |
|
end |
124 |
|
|
639 |
|
|
640 |
|
### END test methods ### |
641 |
|
|
642 |
+ |
|
643 |
|
# call the test already |
644 |
|
|
645 |
|
if test_in == "all" |
658 |
|
|
659 |
|
puts "### Total tests: #{test_total} (Passed: #{@test_pass} Failed: #{@test_fail}) ###" |
660 |
|
|
595 |
– |
# do some cleanup |
596 |
– |
# rm... |
597 |
– |
# or not |