coderunner 0.11.7 → 0.11.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/coderunner.gemspec +5 -4
- data/lib/coderunner.rb +5 -0
- data/lib/coderunner/instance_methods.rb +1 -0
- data/lib/coderunner/run.rb +1 -1
- data/lib/cubecalccrmod/{default_modlets/empty.rb → empty.rb} +0 -0
- data/lib/cubecalccrmod/{my_modlets/sleep.rb → sleep.rb} +0 -0
- data/test/cubecalc.cc +52 -0
- data/test/test_coderunner.rb +470 -5
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.8
|
data/coderunner.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "coderunner"
|
8
|
-
s.version = "0.11.
|
8
|
+
s.version = "0.11.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Edmund Highcock"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-11-12"
|
13
13
|
s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
|
14
14
|
s.email = "edmundhighcock@sourceforge.net"
|
15
15
|
s.executables = ["coderunner"]
|
@@ -61,10 +61,11 @@ Gem::Specification.new do |s|
|
|
61
61
|
"lib/coderunner/version.rb",
|
62
62
|
"lib/cubecalccrmod.rb",
|
63
63
|
"lib/cubecalccrmod/cubecalc_defaults.rb",
|
64
|
-
"lib/cubecalccrmod/default_modlets/empty.rb",
|
65
64
|
"lib/cubecalccrmod/default_modlets/empty_defaults.rb",
|
66
65
|
"lib/cubecalccrmod/defaults_files/sleep_defaults.rb",
|
67
|
-
"lib/cubecalccrmod/
|
66
|
+
"lib/cubecalccrmod/empty.rb",
|
67
|
+
"lib/cubecalccrmod/sleep.rb",
|
68
|
+
"test/cubecalc.cc",
|
68
69
|
"test/helper.rb",
|
69
70
|
"test/test_coderunner.rb"
|
70
71
|
]
|
data/lib/coderunner.rb
CHANGED
@@ -367,6 +367,7 @@ class CodeRunner
|
|
367
367
|
|
368
368
|
# p run_class_name
|
369
369
|
|
370
|
+
FileUtils.makedirs(ENV['HOME'] + "/.coderunner/#{code}crmod/")
|
370
371
|
return const_get(run_class_name) if constants.include? (run_class_name).to_sym unless options[:force]
|
371
372
|
SETUP_RUN_CLASSES.push run_class_name.downcase
|
372
373
|
|
data/lib/coderunner/run.rb
CHANGED
@@ -395,7 +395,7 @@ end
|
|
395
395
|
|
396
396
|
def defaults_location
|
397
397
|
if @runner.defaults_file
|
398
|
-
location = ["
|
398
|
+
location = [ENV['HOME'] + "/.coderunner/#{@code}crmod/defaults_files", rcp.code_module_folder + "/defaults_files"].find{|folder| FileTest.exist? folder and Dir.entries(folder).include? defaults_file_name}
|
399
399
|
raise "Defaults file: #{defaults_file_name} not found" unless location
|
400
400
|
return location
|
401
401
|
else
|
File without changes
|
File without changes
|
data/test/cubecalc.cc
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <iostream>
|
3
|
+
#include <cstdlib>
|
4
|
+
#include <fstream>
|
5
|
+
#include <cstring>
|
6
|
+
#include <ctime>
|
7
|
+
using namespace std;
|
8
|
+
|
9
|
+
int main(int argc, char* argv[]){
|
10
|
+
string line;
|
11
|
+
cout << "Starting..." << endl;
|
12
|
+
|
13
|
+
int calculate_sides = atoi(argv[1]); //Should the program calculate the area of the sides of the cube?
|
14
|
+
cout << calculate_sides << endl;
|
15
|
+
|
16
|
+
char* input_file_name = argv[2]; //Get the input file name from the command line
|
17
|
+
cout << input_file_name << endl;
|
18
|
+
|
19
|
+
if (argc > 3){ //It has been told to sleep for a time
|
20
|
+
bool cont = true;
|
21
|
+
time_t start_t;
|
22
|
+
time(&start_t);
|
23
|
+
while (cont){
|
24
|
+
time_t new_t;
|
25
|
+
time(&new_t);
|
26
|
+
cont = (new_t < (start_t + atoi(argv[3]) * 1.0));
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
ifstream edges_file(input_file_name); //Read the edges from the input file
|
31
|
+
float* edges = new float[3];
|
32
|
+
int j = 0;
|
33
|
+
while (edges_file >> edges[j++]){
|
34
|
+
cout << edges[j-1] << endl;
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
FILE* output = fopen("results.txt", "w"); //Write the volume to the output file
|
39
|
+
fprintf(output, "Volume was %f", edges[0] * edges[1] * edges[2]);
|
40
|
+
fclose(output);
|
41
|
+
|
42
|
+
if (calculate_sides == 1){ //If it has been told to calculate the sides
|
43
|
+
cout << "calculating sides" << endl;
|
44
|
+
FILE* sides = fopen("sides.txt", "w");
|
45
|
+
for(int i=0; i<3; i++){
|
46
|
+
cout << "Side " << i << ": " << edges[(i%3)] * edges[((i+1)%3)] << endl;
|
47
|
+
fprintf(sides, "The area of side %d is %f\n", i, edges[i%3] * edges[(i+1)%3]);
|
48
|
+
}
|
49
|
+
fclose(sides);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
data/test/test_coderunner.rb
CHANGED
@@ -1,7 +1,472 @@
|
|
1
|
-
require '
|
1
|
+
require 'coderunner'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
module Test::Unit::Assertions
|
5
|
+
def assert_system(string)
|
6
|
+
assert(system(string), "System Command: '#{string}'")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
`g++ cubecalc.cc -o cubecalc`
|
11
|
+
|
12
|
+
|
13
|
+
ppipe = PPipe.new(10, false, redirect: true)
|
14
|
+
|
15
|
+
raise "Please Specify Tests" unless ARGV[-1]
|
16
|
+
|
17
|
+
# CodeRunner::SYS = (ENV['CODE_RUNNER_SYSTEM'] or 'genericlinux')
|
18
|
+
|
19
|
+
if ARGV[-1] =~ /0/
|
20
|
+
if FileTest.exist? 'results'
|
21
|
+
FileUtils.rm_r 'results'
|
22
|
+
end
|
23
|
+
FileUtils.makedirs 'results'
|
24
|
+
|
25
|
+
Dir.chdir('results') do
|
26
|
+
|
27
|
+
puts 'testing test submission'
|
28
|
+
exit unless system %[ruby ../lib/coderunner.rb submit -C cubecalc -m sleep -D sleep -X ../cubecalc -T]
|
29
|
+
raise "didn't find defaults" unless FileTest.exist? 'sleep_defaults.rb'
|
30
|
+
puts 'testing test submission complete'
|
31
|
+
|
32
|
+
puts 'testing job_no detection'
|
33
|
+
puts fork{system %[ruby ../lib/coderunner.rb sub -p "{sleep_time: 4}"]}
|
34
|
+
sleep 2
|
35
|
+
#exit unless system %[ps | grep cubecalc]
|
36
|
+
Process.waitall
|
37
|
+
puts 'testing job_no detection complete'
|
38
|
+
|
39
|
+
#exit
|
40
|
+
|
41
|
+
|
42
|
+
puts 'testing canceling a job (not deleting)'
|
43
|
+
fork{system %[ruby ../../coderunner.rb sub -p "{sleep_time: 900}"]}
|
44
|
+
sleep 3
|
45
|
+
fork{system %[ruby ../../coderunner.rb sub -p "{sleep_time: 900, height: 3.0}"]}
|
46
|
+
sleep 4
|
47
|
+
runner = CodeRunner.new(Dir.pwd).update
|
48
|
+
runner.print_out(0)
|
49
|
+
runner.print_out_size = 0
|
50
|
+
runner.cancel_job(2, no_confirm: true, delete: false)
|
51
|
+
#pipe = ppipe.fork do
|
52
|
+
#runner.cancel_job(2)
|
53
|
+
#end
|
54
|
+
##3.times{puts ppipe.gets}
|
55
|
+
#2.times{ppipe.puts(pipe, "")}
|
56
|
+
#puts 'confirming...'
|
57
|
+
## sleep 0.5
|
58
|
+
##2.times{puts ppipe.gets}
|
59
|
+
#puts 'about to say no'
|
60
|
+
#ppipe.puts(pipe, "n")
|
61
|
+
## 9.times{puts ppipe.gets}
|
62
|
+
|
63
|
+
#exit
|
64
|
+
|
65
|
+
puts 'testing cancelling with deleting'
|
66
|
+
|
67
|
+
runner.update
|
68
|
+
runner.print_out(0)
|
69
|
+
runner.print_out_size = 0
|
70
|
+
runner.cancel_job(3, no_confirm: true, delete: true)
|
71
|
+
#pipe = ppipe.fork do
|
72
|
+
#runner.cancel_job(3)
|
73
|
+
#end
|
74
|
+
## 2.times{puts ppipe.gets}
|
75
|
+
#puts 'confirming...'
|
76
|
+
#ppipe.puts(pipe, "")
|
77
|
+
## ppipe.puts(pipe, "\n")
|
78
|
+
## sleep 0.5
|
79
|
+
## 2.times{puts ppipe.gets}
|
80
|
+
#puts 'about to say yes'
|
81
|
+
#ppipe.puts(pipe, "y")
|
82
|
+
## 8.times{puts ppipe.gets}
|
83
|
+
|
84
|
+
puts 'testing canceling complete'
|
85
|
+
|
86
|
+
#exit
|
87
|
+
|
88
|
+
# exit
|
89
|
+
|
90
|
+
puts
|
91
|
+
puts 'testing parameter scan'
|
92
|
+
File.open('parameter_scan.rb', 'w') do |file|
|
93
|
+
file.puts [
|
94
|
+
[
|
95
|
+
['width', [0.3, 0.5]], ['height', [0.5, 4.3]]
|
96
|
+
],
|
97
|
+
[
|
98
|
+
['width', [7.2]], ['height', [3.6, 12.6]]
|
99
|
+
]
|
100
|
+
].inspect
|
101
|
+
end
|
102
|
+
exit unless system %[ruby ../../coderunner.rb ps parameter_scan.rb]
|
103
|
+
# # exit unless system %[ruby ../../coderunner.rb -UN -O "width height"]
|
104
|
+
runner.update
|
105
|
+
runner.print_out(0)
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
# exit
|
110
|
+
#
|
111
|
+
end
|
112
|
+
|
113
|
+
end # if ARGV[0] == 's'
|
114
|
+
|
115
|
+
# exit
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
if ARGV[-1] =~ /1/
|
120
|
+
FileUtils.rm_r 'results' if FileTest.exist? 'results'
|
121
|
+
FileUtils.makedirs 'results'
|
122
|
+
|
123
|
+
# CodeRunner::SYS = ENV['CODE_RUNNER_SYSTEM'] = 'genericlinux_testsystem' if CodeRunner::SYS == 'genericlinux'
|
124
|
+
|
125
|
+
Dir.chdir('results') do
|
126
|
+
|
127
|
+
|
128
|
+
exit unless system %[ruby ../../coderunner.rb submit -C cubecalc -m empty -X ../cubecalc -T]
|
129
|
+
|
130
|
+
defs = File.read('cubecalc_defaults.rb')
|
131
|
+
File.open('cubecalc_defaults.rb', 'w'){|f| f.puts defs.sub(/(sides\s+=\s+)0/, '\11')}
|
132
|
+
|
133
|
+
puts 'testing submission with -p flag'
|
134
|
+
|
135
|
+
exit unless system %[ruby ../../coderunner.rb submit -p "{width: 3.0, height: 8.0}"]
|
136
|
+
raise "didn't find defaults" unless FileTest.exist? 'cubecalc_defaults.rb'
|
137
|
+
puts 'testing submission with -p flag complete'
|
138
|
+
# exit
|
139
|
+
|
140
|
+
puts 'testing printing out status'
|
141
|
+
exit unless system %[ruby ../../coderunner.rb status -N]
|
142
|
+
puts 'that should have raised a TerminalError from print_out'
|
143
|
+
ENV['ROWS'] = Terminal.terminal_size[0].to_s
|
144
|
+
ENV['COLS'] = Terminal.terminal_size[1].to_s
|
145
|
+
puts ENV['ROWS'], ENV['COLS']
|
146
|
+
exit unless system %[ruby ../../coderunner.rb st -N]
|
147
|
+
runner = CodeRunner.new(Dir.pwd).update
|
148
|
+
runner.print_out(0)
|
149
|
+
puts 'testing printing out status complete'
|
150
|
+
|
151
|
+
puts 'testing using large cache'
|
152
|
+
%x[ruby ../../coderunner.rb sub -p "{width: 3.0, height: 6.0}"]
|
153
|
+
%x[ruby ../../coderunner.rb sub -p "{width: 3.0, height: 9.0}"]
|
154
|
+
puts "using large cache without updating"
|
155
|
+
runner.use_large_cache = true
|
156
|
+
runner.update.print_out(0)
|
157
|
+
puts 'using large cache after updating'
|
158
|
+
runner.update
|
159
|
+
runner.use_large_cache = true
|
160
|
+
runner.update.print_out(0)
|
161
|
+
puts 'testing using large cache complete'
|
162
|
+
|
163
|
+
puts 'testing sorting'
|
164
|
+
%x[ruby ../../coderunner.rb sub -p "{width: 12.0, height: 9.0}"]
|
165
|
+
%x[ruby ../../coderunner.rb sub -p "{width: 5.0, height: 6.0}"]
|
166
|
+
puts '----', 'unsorted'
|
167
|
+
exit unless system %[ruby ../../coderunner.rb st -N]
|
168
|
+
puts '----', 'sort by volume'
|
169
|
+
exit unless system %[ruby ../../coderunner.rb st -O "volume" -N]
|
170
|
+
puts '----','sort by width then by height'
|
171
|
+
exit unless system %[ruby ../../coderunner.rb st -O "width;height" -N]
|
172
|
+
puts 'testing sorting complete'
|
173
|
+
|
174
|
+
puts 'testing getting directory'
|
175
|
+
exit unless system %[ruby ../../coderunner.rb dir 3 -UN ]
|
176
|
+
puts 'testing getting directory complete'
|
177
|
+
|
178
|
+
puts 'testing filtering'
|
179
|
+
puts '----', 'height == 9.0'
|
180
|
+
exit unless system %[ruby ../../coderunner.rb st -UNf "height == 9.0"]
|
181
|
+
puts '----', 'id == 1 or width == 12.0'
|
182
|
+
exit unless system %[ruby ../../coderunner.rb st -UNf 'id == 1 or width == 12.0']
|
183
|
+
puts 'testing filtering complete'
|
184
|
+
|
185
|
+
# exit
|
186
|
+
|
187
|
+
puts 'testing phantom runs'
|
188
|
+
exit unless system %[ruby ../../coderunner.rb st -UN -h -O "volume;area"]
|
189
|
+
puts 'testing using both'
|
190
|
+
exit unless system %[ruby ../../coderunner.rb st -UN -h both -O "volume;id"]
|
191
|
+
puts 'testing phantom runs complete'
|
192
|
+
|
193
|
+
puts 'testing readout'
|
194
|
+
exit unless system %[ruby ../../coderunner.rb ro -UN -O "width;height"]
|
195
|
+
puts 'testing readout complete'
|
196
|
+
|
197
|
+
puts 'testing run eval'
|
198
|
+
exit unless system %[ruby ../../coderunner.rb rc "puts %[hello I am run \#\@run_name]" -U -f "id ==1" ]
|
199
|
+
puts 'testing run eval complete'
|
200
|
+
|
201
|
+
puts 'testing graph plotting'
|
202
|
+
exit unless system %[ruby ../../coderunner.rb sub -p "{width: 11.0, height: 9.0, depth: 2.0}"]
|
203
|
+
|
204
|
+
# IO.popen(%[ruby ../../coderunner.rb -U -g "width*height*depth:volume"]) do |pipe|
|
205
|
+
# sleep 1
|
206
|
+
# pipe.puts
|
207
|
+
# end
|
208
|
+
exit unless system %[ruby ../../coderunner.rb wg graph.ps -O volume -G "width*height*depth:volume"]
|
209
|
+
exit unless system %[ruby ../../coderunner.rb wg graph1.ps -U -O volume -G "width:height:depth:volume;;;height"]
|
210
|
+
exit unless system %[ruby ../../coderunner.rb wg "" -U -f "id==1 or id == 2" -g "sides"]
|
211
|
+
puts 'testing graph plotting complete'
|
212
|
+
|
213
|
+
puts 'testing max'
|
214
|
+
exit unless system %[ruby ../../coderunner.rb st -U -f "max(:volume)"]
|
215
|
+
exit unless system %[ruby ../../coderunner.rb st -U -f "width == 3.0 and smax(:volume, :height)"]
|
216
|
+
puts 'testing max complete'
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
#
|
225
|
+
# # puts 'testing interactive mode'
|
226
|
+
# # IO.popen(%[ruby ../../coderunner.rb -i]) do |pipe|
|
227
|
+
# # pipe.puts 'cr'
|
228
|
+
# # pipe.puts 'exit'
|
229
|
+
# # end
|
230
|
+
# # puts 'testing interactive mode'
|
231
|
+
|
232
|
+
end # Dir.chdir
|
233
|
+
|
234
|
+
end # if
|
235
|
+
|
236
|
+
p ARGV[-1] =~ /2/
|
237
|
+
|
238
|
+
if ARGV[-1] =~ /2/
|
239
|
+
|
240
|
+
FileUtils.rm_r 'results' if FileTest.exist? 'results'
|
241
|
+
FileUtils.makedirs 'results'
|
242
|
+
|
243
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', C: 'cubecalc', m: 'empty', X: '../cubecalc', T: true)
|
244
|
+
# exit
|
245
|
+
defs = File.read('results/cubecalc_defaults.rb')
|
246
|
+
File.open('results/cubecalc_defaults.rb', 'w'){|f| f.puts defs.sub(/\#(@calculate_sides\s+=\s+)0/, '\11')}
|
247
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 3.0, height: 8.0}")
|
248
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 3.0, height: 6.0}")
|
249
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 3.0, height: 9.0}")
|
250
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 12.0, height: 9.0}")
|
251
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 5.0, height: 6.0}")
|
252
|
+
CodeRunner.submit(Y: Dir.pwd + '/results', p: "{width: 11.0, height: 9.0, depth: 2.0}")
|
253
|
+
|
254
|
+
class TestCodeRunner < Test::Unit::TestCase
|
255
|
+
|
256
|
+
# Override this method as we want the tests to be run in the order they are defined
|
257
|
+
|
258
|
+
def self.test_methods
|
259
|
+
public_instance_methods(true).grep(/^test/).map { |m| m.to_s}
|
260
|
+
end
|
261
|
+
|
262
|
+
def setup
|
263
|
+
@runner = CodeRunner.fetch_runner(Y: Dir.pwd + '/results').update
|
264
|
+
end
|
265
|
+
|
266
|
+
def teardown
|
267
|
+
end
|
268
|
+
|
269
|
+
def cl(command)
|
270
|
+
Dir.chdir('results'){assert_system command}
|
271
|
+
end
|
272
|
+
|
273
|
+
def cl2(command)
|
274
|
+
Dir.chdir('results3'){assert_system command}
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
def cl3(command)
|
279
|
+
Dir.chdir('results3'){assert_system command}
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
#def test_remote_coderunner
|
284
|
+
#puts 'testing remote coderunner'
|
285
|
+
#rc = RemoteCodeRunner.new(ENV['USER'] + '@localhost', Dir.pwd + '/results', U: true, N: true).update
|
286
|
+
#assert_equal(@runner.ids.sort, rc.ids.sort)
|
287
|
+
#rc.print_out(0)
|
288
|
+
#wdvh = rc.graphkit("width:height:depth:volume;;;height")
|
289
|
+
#wdvh.gnuplot
|
290
|
+
#assert_equal(4, wdvh.naxes)
|
291
|
+
#assert_equal(1, wdvh.data.size)
|
292
|
+
#assert_equal([30.0, 18.0, 24.0, 108.0, 27.0, 198.0], wdvh.data[0].axes[:f].data)
|
293
|
+
#sds = rc.run_graphkit('sides;;[1,2].include? id')
|
294
|
+
## sds.gnuplot
|
295
|
+
#wdvh.close
|
296
|
+
#puts 'testing remote coderunner complete'
|
297
|
+
#end
|
298
|
+
|
299
|
+
#def test_run_eval_saving
|
300
|
+
#puts "\nTesting run command saving"
|
301
|
+
#cl(%[ruby ../../coderunner.rb rc '@test_var = :will_o_the_wisp' -U])
|
302
|
+
#@runner.update(false, true)
|
303
|
+
#assert_equal(:will_o_the_wisp, @runner.run_list[1].instance_variable_get(:@test_var))
|
304
|
+
#cl(%[ruby ../../coderunner.rb rc '@test_var2 = :will_o_the_wisps' -U -M 3])
|
305
|
+
|
306
|
+
#@runner.update(false, true)
|
307
|
+
#assert_equal(:will_o_the_wisps, @runner.run_list[1].instance_variable_get(:@test_var2))
|
308
|
+
#puts 'finished testing run command saving'
|
309
|
+
#end
|
310
|
+
|
311
|
+
#def test_relative_directory
|
312
|
+
#puts "\nTesting relative directory"
|
313
|
+
#@runner.recalc_all = true
|
314
|
+
#puts 'updating fully'
|
315
|
+
#@runner.update #(true, false)
|
316
|
+
#FileUtils.rm_r('results2') if FileTest.exist? 'results2'
|
317
|
+
#FileUtils.cp_r('results', 'results2')
|
318
|
+
#r = CodeRunner.fetch_runner(Y: 'results2', U: true)
|
319
|
+
#r.update(false)
|
320
|
+
#assert_equal(Dir.pwd + '/results', @runner.root_folder)
|
321
|
+
#assert_equal(Dir.pwd + '/results2', r.root_folder)
|
322
|
+
#assert_equal(@runner.run_list[1].directory.sub(File.expand_path(@runner.root_folder) + '/', ''), r.run_list[1].relative_directory)
|
323
|
+
#assert_equal(r.root_folder + '/' + r.run_list[1].relative_directory, r.run_list[1].directory)
|
324
|
+
#end
|
325
|
+
|
326
|
+
#def test_set_start_id
|
327
|
+
#eputs "\ntesting set_start_id"
|
328
|
+
#FileUtils.rm_r 'results3' if FileTest.exist?('results3')
|
329
|
+
#FileUtils.mkdir('results3')
|
330
|
+
#cl3('ruby ../../coderunner.rb st -C cubecalc -m empty -X ../cubecalc -T')
|
331
|
+
#cl3("ruby ../../coderunner.rb ev 'set_start_id(20)'")
|
332
|
+
#cl3('ruby ../../coderunner.rb sub -p "{width: 12.0, height: 9.0}"')
|
333
|
+
#@runner3 = CodeRunner.new(Dir.pwd + '/results3').update
|
334
|
+
#assert_equal(20, @runner3.start_id)
|
335
|
+
#assert_equal(21, @runner3.max_id)
|
336
|
+
#eputs "\ntesting set_start_id complete"
|
337
|
+
#end
|
338
|
+
|
339
|
+
#def test_merged_code_runner
|
340
|
+
#@runner3 = CodeRunner.new(Dir.pwd + '/results3').update
|
341
|
+
#assert_nothing_raised{@mrunner = CodeRunner::Merged.new(@runner, @runner3)}
|
342
|
+
#@mrunner.print_out(0)
|
343
|
+
#assert_equal(@runner.run_list.size + 1, @mrunner.run_list.size)
|
344
|
+
#@mrunner2 = @runner.merge(@runner3)
|
345
|
+
#assert_equal(@mrunner2.run_list.keys, @mrunner.run_list.keys)
|
346
|
+
#end
|
347
|
+
|
348
|
+
#def test_alter_ids
|
349
|
+
#FileUtils.rm_r('results4') if FileTest.exist? 'results4'
|
350
|
+
#FileUtils.cp_r('results', 'results4')
|
351
|
+
#@runner4 = CodeRunner.new(Dir.pwd + '/results4').update
|
352
|
+
#@runner4.alter_ids(40, no_confirm: true)
|
353
|
+
#@runner4a = CodeRunner.new(Dir.pwd + '/results4').update
|
354
|
+
#assert_equal(@runner.ids.map{|id| id + 40}.sort, @runner4.ids.sort)
|
355
|
+
#assert_equal(@runner4a.ids.sort, @runner4.ids.sort)
|
356
|
+
#@runner4.alter_ids(40, no_confirm: true)
|
357
|
+
#@runner4a.update
|
358
|
+
#assert_equal(@runner.ids.map{|id| id + 80}.sort, @runner4.ids.sort)
|
359
|
+
#assert_equal(@runner4a.ids.sort, @runner4.ids.sort)
|
360
|
+
#run = @runner4.run_list.values[0]
|
361
|
+
#assert(FileTest.exist?(run.directory), "Run directory exists")
|
362
|
+
#assert_equal(run.id, eval(File.read(run.directory + '/code_runner_info.rb'))[:id])
|
363
|
+
#end
|
364
|
+
|
365
|
+
#def test_submit_non_parallel_with_large_cache
|
366
|
+
#FileUtils.touch('results/submitting')
|
367
|
+
## fork{cl('ruby ../../coderunner.rb sub -p "{width: 1.887, height: 9.0}"')}
|
368
|
+
#fork{CodeRunner.submit(Y: 'results', p: "{width: 1.887, height: 9.0}", U: true)}
|
369
|
+
#sleep 1.0
|
370
|
+
#@runner.update(true, false)
|
371
|
+
#assert_equal(0, @runner.run_list.values.find_all{|run| run.width==1.887}.size)
|
372
|
+
#FileUtils.rm('results/submitting')
|
373
|
+
#i = 0
|
374
|
+
#Process.waitall
|
375
|
+
## (@runner.update(true, true); sleep 0.5; i+=1 ; flunk if i==20) until @runner.run_list.values.find{|run| run.width==1.887}
|
376
|
+
#@runner.update(true, true)
|
377
|
+
#assert_equal(1, @runner.run_list.values.find_all{|run| run.width==1.887}.size)
|
378
|
+
#@runner.conditions = "id==7"
|
379
|
+
#@runner.destroy(no_confirm: true)
|
380
|
+
#assert_equal(0, @runner.run_list.values.find_all{|run| run.width==1.887}.size)
|
381
|
+
#assert_raise(RuntimeError){CodeRunner.submit(Y: 'results', p: "{run_test_flags: {test_submit_error_handling: true}}", U: true)}
|
382
|
+
#assert(!FileTest.exist?('results/submitting'))
|
383
|
+
#end
|
384
|
+
|
385
|
+
def test_latex_graphkit
|
386
|
+
sds = @runner.run_graphkit('sides;;[1,2].include? id')
|
387
|
+
p sds
|
388
|
+
sds.ylabel = 'Hello'
|
389
|
+
sds.data.each_with_index{|dk,i| dk.title = i.to_s}
|
390
|
+
sds.xlabel = '\(\Gamma_{\epsilon}\)'
|
391
|
+
sds.title = 'Area of the Sides'
|
392
|
+
#pid1 = sds.gnuplot
|
393
|
+
|
394
|
+
sds.gnuplot_write('latgraph.eps', latex: true)
|
395
|
+
#pid = forkex "okular latgraph.eps"
|
396
|
+
sleep 3
|
397
|
+
#Process.kill 'TERM', pid
|
398
|
+
#Process.kill 'TERM', pid1
|
399
|
+
end
|
400
|
+
|
401
|
+
def test_graphkit_multiplot
|
402
|
+
|
403
|
+
######################
|
404
|
+
# Make 3 random graphs
|
405
|
+
######################
|
406
|
+
|
407
|
+
|
408
|
+
# As usual, data can be an array or a GSL::Vector
|
409
|
+
kit1 = GraphKit.autocreate(x: {data: [0,2,4], title: 'A label with latex \(\Gamma_\epsilon \chi\)', units: '\(\nu e\)'}, y: {data: [3.3, 5.5, 10], title: 'Label with latex \(\beta\)', units: '\(v_{thi}\)'})
|
410
|
+
kit1.title = 'First Graph'
|
411
|
+
kit1.gp.label = '\'A label\' at 2,7' # This 'gp' syntax is new. You can set pretty much any gnuplot option like this - see gnuplot help set
|
412
|
+
kit1.data[0].title = 'A new title'
|
413
|
+
|
414
|
+
kit2 = GraphKit.autocreate(x: {data: [0,2,4], title: 'Stuff \(\Gamma_\epsilon \chi\)', units: '\(\nu e\)'}, y: {data: [2, -1, 2], title: 'Some \(\beta\)', units: '\(v_{thi}\)'})
|
415
|
+
kit2.title = 'Second Graph'
|
416
|
+
kit2.data[0].gp.with = 'lp linewidth 6' # See gnuplot help plot for data options
|
417
|
+
kit2.gp.key = 'off'
|
418
|
+
kit2.xlabel = 'A NEW XLABEL'
|
419
|
+
|
420
|
+
kit3 = GraphKit.autocreate(x: {data: [0,5,10], title: 'Mouse Height \(\Gamma_\epsilon \chi\)', units: '\(\nu e\)'}, y: {data: [4, 3, 4], title: 'Mouse weight \(\kappa\)', units: '\(v_{thi}\)'})
|
421
|
+
kit3.title = 'Mouse info'
|
422
|
+
kit3.data[0].gp.with = 'lp'
|
423
|
+
kit3.gp.key = 'off'
|
424
|
+
|
425
|
+
#####################
|
426
|
+
# Plot a single one
|
427
|
+
#####################
|
428
|
+
|
429
|
+
kit1.gnuplot_write('first_graph.eps', latex: true) #Just plot it by itself
|
430
|
+
|
431
|
+
###########################
|
432
|
+
# Plot multiple graphs
|
433
|
+
##########################
|
434
|
+
|
435
|
+
kit1.gnuplot_write('aname.eps', latex: true)
|
436
|
+
kit2.gnuplot_write('anothername.eps', latex: true)
|
437
|
+
kit3.gnuplot_write('athirdname.eps', latex: true, size: "2.0in,2.0in")
|
438
|
+
|
439
|
+
my_preamble = <<EOF
|
440
|
+
\\documentclass{article}
|
441
|
+
%\documentclass[aip,reprint]{}
|
442
|
+
\\usepackage{graphics,bm,overpic,subfigure,color}
|
443
|
+
|
444
|
+
\\pagestyle{empty}
|
445
|
+
\\begin{document}
|
446
|
+
\\begin{figure}
|
447
|
+
EOF
|
448
|
+
|
449
|
+
|
450
|
+
# Can use default preamble - just don't include preamble option in function call GraphKit.latex_multiplot('all_graphs.eps')
|
451
|
+
GraphKit.latex_multiplot('all_graphs.eps', preamble: my_preamble) do
|
452
|
+
<<EOF
|
453
|
+
\\subfigure{
|
454
|
+
\\includegraphics{aname}
|
455
|
+
}
|
456
|
+
\\subfigure{
|
457
|
+
\\begin{overpic}{anothername}
|
458
|
+
% The location is in percent of image width
|
459
|
+
\\put(44,22){\\includegraphics[scale=.45]
|
460
|
+
{athirdname}}
|
461
|
+
\\end{overpic}
|
462
|
+
}
|
463
|
+
EOF
|
464
|
+
end
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
end # def
|
469
|
+
|
470
|
+
end # class TestCodeRunner
|
2
471
|
|
3
|
-
class TestCoderunner < Test::Unit::TestCase
|
4
|
-
should "probably rename this file and start testing for real" do
|
5
|
-
flunk "hey buddy, you should probably rename this file and start testing for real"
|
6
|
-
end
|
7
472
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphkit
|
@@ -244,10 +244,11 @@ files:
|
|
244
244
|
- lib/coderunner/version.rb
|
245
245
|
- lib/cubecalccrmod.rb
|
246
246
|
- lib/cubecalccrmod/cubecalc_defaults.rb
|
247
|
-
- lib/cubecalccrmod/default_modlets/empty.rb
|
248
247
|
- lib/cubecalccrmod/default_modlets/empty_defaults.rb
|
249
248
|
- lib/cubecalccrmod/defaults_files/sleep_defaults.rb
|
250
|
-
- lib/cubecalccrmod/
|
249
|
+
- lib/cubecalccrmod/empty.rb
|
250
|
+
- lib/cubecalccrmod/sleep.rb
|
251
|
+
- test/cubecalc.cc
|
251
252
|
- test/helper.rb
|
252
253
|
- test/test_coderunner.rb
|
253
254
|
homepage: http://coderunner.sourceforge.net
|