nera 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +37 -0
- data/README.rdoc +47 -0
- data/Rakefile +27 -0
- data/bin/nera +29 -0
- data/bin/nera_addsim +30 -0
- data/lib/nera/nera_cui.rb +417 -0
- data/lib/nera/nera_database.rb +281 -0
- data/lib/nera/nera_db_folders.rb +226 -0
- data/lib/nera/nera_dialog.rb +205 -0
- data/lib/nera/nera_job_layer_controller.rb +237 -0
- data/lib/nera/nera_job_records.rb +111 -0
- data/lib/nera/nera_job_script.rb +202 -0
- data/lib/nera/nera_parameter_layer_controller.rb +157 -0
- data/lib/nera/nera_parameter_records.rb +186 -0
- data/lib/nera/nera_run_layer_controller.rb +192 -0
- data/lib/nera/nera_run_records.rb +184 -0
- data/lib/nera/nera_simulator.rb +26 -0
- data/lib/nera/nera_simulator_layer_controller.rb +66 -0
- data/lib/nera/nera_simulator_records.rb +84 -0
- data/lib/nera.rb +25 -0
- data/lib/nera_addsim/make_simulator.rb +307 -0
- data/scripts/make_manifest.rb +21 -0
- data/test/runner.rb +3 -0
- data/test/test_helper.rb +52 -0
- data/test/test_nera_database.rb +221 -0
- data/test/test_nera_db_folders.rb +209 -0
- data/test/test_nera_dialog.rb +134 -0
- data/test/test_nera_job_layer_controller.rb +132 -0
- data/test/test_nera_job_records.rb +260 -0
- data/test/test_nera_parameter_layer_controller.rb +188 -0
- data/test/test_nera_parameter_records.rb +285 -0
- data/test/test_nera_run_layer_controller.rb +171 -0
- data/test/test_nera_run_records.rb +290 -0
- data/test/test_nera_simulator.rb +26 -0
- data/test/test_nera_simulator_layer_controller.rb +54 -0
- data/test/test_nera_simulator_records.rb +140 -0
- metadata +125 -0
@@ -0,0 +1,290 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TC_NERA_RUN_RECORDS < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@testdir = 'test_run_recs'
|
8
|
+
FileUtils.mkdir( @testdir)
|
9
|
+
FileUtils.chdir( @testdir)
|
10
|
+
@table_file = 'run_recs.pstore'
|
11
|
+
NERA::RunRecords.create_table( @table_file)
|
12
|
+
@rrecs = NERA::RunRecords.new( @table_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
FileUtils.chdir('..')
|
17
|
+
FileUtils.rm_r( @testdir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_initialize
|
21
|
+
assert_raise( RuntimeError) {
|
22
|
+
NERA::RunRecords.new( 'unknown')
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_a_new_table
|
27
|
+
n = NERA::RunRecords.create_table( @table_file)
|
28
|
+
assert_nil(n)
|
29
|
+
|
30
|
+
n = NERA::RunRecords.create_table('hoge')
|
31
|
+
assert( File.exist?('hoge') )
|
32
|
+
assert_equal( true, n)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_keys
|
36
|
+
a = [ [:id, Integer], [:state, Symbol], [:created_at, DateTime],
|
37
|
+
[:job_id, Integer], [:seed, Integer],
|
38
|
+
[:start_at, DateTime], [:finish_at, DateTime],
|
39
|
+
[:included_at, DateTime], [:real_time, Float],
|
40
|
+
[:user_time, Float], [:host_name, String],
|
41
|
+
[:omp_threads, Integer], [:mpi_processes, Integer]
|
42
|
+
]
|
43
|
+
k = a.map do |x| x[0] end
|
44
|
+
assert_equal( k, @rrecs.keys)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_add
|
48
|
+
r = @rrecs.add( 1)
|
49
|
+
l = @rrecs.list_all
|
50
|
+
lf = @rrecs.list_all_finished
|
51
|
+
ln = @rrecs.list_all_not_finished
|
52
|
+
assert_equal( 1, r.size)
|
53
|
+
assert_equal( r[0][:id], 1)
|
54
|
+
assert( r[0][:seed] > 0 )
|
55
|
+
assert_equal( r[0][:omp_threads], 1)
|
56
|
+
assert_equal( r[0][:mpi_processes], 1)
|
57
|
+
assert_equal( 1, l.size)
|
58
|
+
assert_equal( 0, lf.size)
|
59
|
+
assert_equal( 1, ln.size)
|
60
|
+
|
61
|
+
r = @rrecs.add( 99)
|
62
|
+
a = @rrecs.list_all
|
63
|
+
assert_equal( 99, r.size)
|
64
|
+
assert_equal( 100, a.size)
|
65
|
+
|
66
|
+
r = @rrecs.add( 20)
|
67
|
+
a = @rrecs.list_all
|
68
|
+
assert_equal( 20, r.size)
|
69
|
+
assert_equal( 120, a.size)
|
70
|
+
f = a.find do |r| r[:id] == 120 end
|
71
|
+
assert( f)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_set_job_id
|
75
|
+
r = @rrecs.add( 10)
|
76
|
+
id = r[0][:id]
|
77
|
+
jid = @rrecs.set_job_id( id, 10, 1)
|
78
|
+
assert_equal( 1, jid)
|
79
|
+
r = @rrecs.add( 10)
|
80
|
+
id = r[0][:id]
|
81
|
+
assert_raise( RuntimeError) {
|
82
|
+
@rrecs.set_job_id( id, 11, 1)
|
83
|
+
}
|
84
|
+
assert_raise( RuntimeError) {
|
85
|
+
@rrecs.set_job_id( 21, 1, 1)
|
86
|
+
}
|
87
|
+
assert_raise( ArgumentError) {
|
88
|
+
@rrecs.set_job_id( 11, 1, "1")
|
89
|
+
}
|
90
|
+
assert_raise( ArgumentError) {
|
91
|
+
@rrecs.set_job_id( "11", 1, 1)
|
92
|
+
}
|
93
|
+
assert_raise( ArgumentError) {
|
94
|
+
@rrecs.set_job_id( 11, "1", 1)
|
95
|
+
}
|
96
|
+
jid = @rrecs.set_job_id(11,10,2)
|
97
|
+
assert_raise( RuntimeError) {
|
98
|
+
@rrecs.set_job_id(11,10,2)
|
99
|
+
}
|
100
|
+
|
101
|
+
l = @rrecs.list_all
|
102
|
+
l.find_all do |x|
|
103
|
+
x[:job_id] == 1
|
104
|
+
end
|
105
|
+
assert_equal( 20, l.size)
|
106
|
+
k = l.find_all do |x|
|
107
|
+
x[:job_id] == 2
|
108
|
+
end
|
109
|
+
assert_equal( 10, k.size)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_list
|
113
|
+
l = @rrecs.list_all
|
114
|
+
lf = @rrecs.list_all_finished
|
115
|
+
ln = @rrecs.list_all_not_finished
|
116
|
+
assert( l.is_a?(Array))
|
117
|
+
assert( lf.is_a?(Array))
|
118
|
+
assert( ln.is_a?(Array))
|
119
|
+
assert_equal( 0, l.size)
|
120
|
+
assert_equal( 0, lf.size)
|
121
|
+
assert_equal( 0, ln.size)
|
122
|
+
|
123
|
+
@rrecs.add( 5)
|
124
|
+
l = @rrecs.list_all
|
125
|
+
lf = @rrecs.list_all_finished
|
126
|
+
ln = @rrecs.list_all_not_finished
|
127
|
+
assert_equal( 5, l.size)
|
128
|
+
assert_equal( 0, lf.size)
|
129
|
+
assert_equal( 5, ln.size)
|
130
|
+
5.times do |i|
|
131
|
+
assert( l[i].is_a?(Hash) )
|
132
|
+
assert_equal( 0, (l[i].keys - @rrecs.keys).size)
|
133
|
+
assert_equal( 0, (ln[i].keys - @rrecs.keys).size)
|
134
|
+
end
|
135
|
+
|
136
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, DateTime.now, DateTime.now, 0.5, 0.5, "host_hoge")
|
137
|
+
@rrecs.update_state_to_finished( 2, DateTime.now, DateTime.now, DateTime.now, 0.5, 0.5, "host_hoge")
|
138
|
+
l2 = @rrecs.list_all
|
139
|
+
lf = @rrecs.list_all_finished
|
140
|
+
ln = @rrecs.list_all_not_finished
|
141
|
+
assert_equal( 5, l2.size)
|
142
|
+
assert_equal( 2, lf.size)
|
143
|
+
assert_equal( 3, ln.size)
|
144
|
+
found1 = l.find do |r| r[:id] == 3 end
|
145
|
+
found2 = l2.find do |r| r[:id] == 3 end
|
146
|
+
assert_equal( found1, found2)
|
147
|
+
found1 = l.find do |r| r[:id] == 4 end
|
148
|
+
found2 = l2.find do |r| r[:id] == 4 end
|
149
|
+
assert_equal( found1, found2)
|
150
|
+
found1 = l.find do |r| r[:id] == 5 end
|
151
|
+
found2 = l2.find do |r| r[:id] == 5 end
|
152
|
+
assert_equal( found1, found2)
|
153
|
+
|
154
|
+
2.times do |i|
|
155
|
+
assert( lf[i].is_a?(Hash) )
|
156
|
+
assert_equal( 0, (lf[i].keys - @rrecs.keys).size)
|
157
|
+
end
|
158
|
+
|
159
|
+
found = lf.find do |rec|
|
160
|
+
rec[:id] == 3
|
161
|
+
end
|
162
|
+
assert_nil( found)
|
163
|
+
found = lf.find do |rec|
|
164
|
+
rec[:id] == 2
|
165
|
+
end
|
166
|
+
assert(found)
|
167
|
+
|
168
|
+
d = @rrecs.destroy( 4)
|
169
|
+
assert( d)
|
170
|
+
l = @rrecs.list_all
|
171
|
+
lf = @rrecs.list_all_finished
|
172
|
+
ln = @rrecs.list_all_not_finished
|
173
|
+
assert_equal( 4, l.size)
|
174
|
+
assert_equal( 2, lf.size)
|
175
|
+
assert_equal( 2, ln.size)
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_update_state_to_finished
|
179
|
+
r = @rrecs.add( 10)
|
180
|
+
id = r[0][:id]
|
181
|
+
jid = @rrecs.set_job_id( id, 10, 1)
|
182
|
+
l = @rrecs.list_all_not_finished
|
183
|
+
assert( 10, l.size)
|
184
|
+
|
185
|
+
d = DateTime.now
|
186
|
+
@rrecs.update_state_to_finished( 1, d, d, d, 0.5, 0.5, "acp1")
|
187
|
+
l = @rrecs.list_all_not_finished
|
188
|
+
assert( 9, l.size)
|
189
|
+
lf = @rrecs.list_all_finished
|
190
|
+
assert( 1, lf.size)
|
191
|
+
p lf[0]
|
192
|
+
assert_equal( 1, lf[0][:id])
|
193
|
+
assert_equal( d, lf[0][:start_at])
|
194
|
+
assert_equal( d, lf[0][:finish_at])
|
195
|
+
assert_equal( d, lf[0][:included_at])
|
196
|
+
assert_equal( 0.5, lf[0][:real_time])
|
197
|
+
assert_equal( 0.5, lf[0][:user_time])
|
198
|
+
assert_equal( "acp1", lf[0][:host_name])
|
199
|
+
assert_equal( :finished, lf[0][:state])
|
200
|
+
n = @rrecs.update_state_to_finished( 1, d, d, d, 0.5, 0.5, "acp1")
|
201
|
+
assert_nil( n)
|
202
|
+
|
203
|
+
assert_raise( ArgumentError) {
|
204
|
+
@rrecs.update_state_to_finished( "1", DateTime.now, DateTime.now, DateTime.now, 0.5, 0.5, "acp1")
|
205
|
+
}
|
206
|
+
assert_raise( ArgumentError) {
|
207
|
+
@rrecs.update_state_to_finished( 1, "08-25-12", DateTime.now, DateTime.now, 0.5, 0.5, "acp1")
|
208
|
+
}
|
209
|
+
assert_raise( ArgumentError) {
|
210
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, "08-25-12", DateTime.now, 0.5, 0.5, "acp1")
|
211
|
+
}
|
212
|
+
assert_raise( ArgumentError) {
|
213
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, DateTime.now, "08-25-12", 0.5, 0.5, "acp1")
|
214
|
+
}
|
215
|
+
assert_raise( ArgumentError) {
|
216
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, DateTime.now, DateTime.now, 5, 0.5, "acp1")
|
217
|
+
}
|
218
|
+
assert_raise( ArgumentError) {
|
219
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, DateTime.now, DateTime.now, 0.5, 5, "acp1")
|
220
|
+
}
|
221
|
+
assert_raise( ArgumentError) {
|
222
|
+
@rrecs.update_state_to_finished( 1, DateTime.now, DateTime.now, DateTime.now, 0.5, 0.5, 13)
|
223
|
+
}
|
224
|
+
|
225
|
+
n = @rrecs.update_state_to_finished( 11, d, d, d, 0.5, 0.5, "acp1")
|
226
|
+
assert_nil( n)
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_destroy
|
230
|
+
r = @rrecs.add( 10)
|
231
|
+
id = r[0][:id]
|
232
|
+
jid = @rrecs.set_job_id( id, 10, 1)
|
233
|
+
|
234
|
+
rec = @rrecs.destroy( 1)
|
235
|
+
assert( rec.is_a?(Hash))
|
236
|
+
assert_equal(1, rec[:id])
|
237
|
+
assert_equal(:not_finished, rec[:state])
|
238
|
+
assert_equal(jid, rec[:job_id])
|
239
|
+
rec = @rrecs.destroy( 1)
|
240
|
+
assert_nil(nil)
|
241
|
+
assert_equal( 9, @rrecs.list_all.size)
|
242
|
+
|
243
|
+
d = DateTime.now
|
244
|
+
@rrecs.update_state_to_finished( 2, d, d, d, 0.5, 0.5, "acp1")
|
245
|
+
rec = @rrecs.destroy( 2)
|
246
|
+
assert_nil(rec)
|
247
|
+
assert_equal(9, @rrecs.list_all.size)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_destroy_job_id
|
251
|
+
r = @rrecs.add(2)
|
252
|
+
id = r[0][:id]
|
253
|
+
jid = @rrecs.set_job_id( id, 2, 1)
|
254
|
+
|
255
|
+
f = @rrecs.destroy_job_id(1)
|
256
|
+
assert(f)
|
257
|
+
assert_equal( 0, @rrecs.list_all.size)
|
258
|
+
f = @rrecs.destroy_job_id(1)
|
259
|
+
assert_nil(f)
|
260
|
+
|
261
|
+
r = @rrecs.add(1)
|
262
|
+
id = r[0][:id]
|
263
|
+
jid = @rrecs.set_job_id( id, 1, 2)
|
264
|
+
d = DateTime.now
|
265
|
+
@rrecs.update_state_to_finished( 3, d, d, d, 0.5, 0.5, "acp1")
|
266
|
+
f = @rrecs.destroy_job_id(2)
|
267
|
+
assert_nil(f)
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_transaction
|
271
|
+
r = @rrecs.add( 10)
|
272
|
+
id = r[0][:id]
|
273
|
+
jid = @rrecs.set_job_id( id, 10, 1)
|
274
|
+
l = @rrecs.list_all_not_finished
|
275
|
+
assert( 10, l.size)
|
276
|
+
|
277
|
+
assert_raise(RuntimeError) {
|
278
|
+
@rrecs.transaction {
|
279
|
+
d = DateTime.now
|
280
|
+
@rrecs.update_state_to_finished(1,d,d,d,0.5,0.5,"hoge")
|
281
|
+
assert( 9, @rrecs.list_all_not_finished)
|
282
|
+
raise
|
283
|
+
}
|
284
|
+
}
|
285
|
+
l2 = @rrecs.list_all_not_finished
|
286
|
+
assert_equal( l, l2)
|
287
|
+
assert_equal( 10, l2.size)
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TC_NERA_SIMULATOR < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_inherited_simulators
|
13
|
+
sim = NERA::Simulator.inherited_simulators
|
14
|
+
p sim
|
15
|
+
assert( sim.is_a?(Array) )
|
16
|
+
assert_equal( 3, sim.size)
|
17
|
+
a = sim.find do |x|
|
18
|
+
x == Ising
|
19
|
+
end
|
20
|
+
assert(a)
|
21
|
+
a = sim.find do |x|
|
22
|
+
x == Heisenberg
|
23
|
+
end
|
24
|
+
assert(a)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TC_NERA_SIM_LAYER_CONTROLLER < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@testdir = 'test_sim_controller'
|
8
|
+
FileUtils.mkdir(@testdir)
|
9
|
+
FileUtils.chdir(@testdir)
|
10
|
+
@db_folder = "nera_db"
|
11
|
+
NERA::DbFolders.create_db( @db_folder)
|
12
|
+
@dbf = NERA::DbFolders.new( @db_folder)
|
13
|
+
@slc = NERA::SimulatorLayerController.new( @db_folder)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
FileUtils.chdir('..')
|
18
|
+
FileUtils.rm_r(@testdir)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_constructor
|
22
|
+
assert_raise( ArgumentError) {
|
23
|
+
NERA::SimulatorLayerController.new( @dbf)
|
24
|
+
}
|
25
|
+
assert_raise( RuntimeError) {
|
26
|
+
NERA::SimulatorLayerController.new( "hoge")
|
27
|
+
}
|
28
|
+
|
29
|
+
assert( File.exist?( @dbf.path_to_simulators_table) )
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_list
|
33
|
+
assert( @slc.list.is_a?(Array) )
|
34
|
+
assert_equal( 2, @slc.list.size)
|
35
|
+
|
36
|
+
found = @slc.list.find do |rec| rec[:name] == Ising.to_s end
|
37
|
+
assert( found)
|
38
|
+
assert( found[:id] > 0)
|
39
|
+
assert( found[:id] <= 2 )
|
40
|
+
assert( found[:created_at].is_a?(DateTime) )
|
41
|
+
assert( found[:updated_at].is_a?(DateTime) )
|
42
|
+
|
43
|
+
found = @slc.list.find do |rec| rec[:name] == Temp.to_s end
|
44
|
+
assert_nil( found)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_path_to_sim_layer
|
49
|
+
p = @slc.path_to_sim_layer
|
50
|
+
assert_equal( @db_folder+'/', p)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TC_NERA_SIM_RECS < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@testdir = 'test_sim_recs'
|
8
|
+
FileUtils.mkdir(@testdir)
|
9
|
+
FileUtils.chdir(@testdir)
|
10
|
+
@path_to_db = 'sim_recs_table.marshal'
|
11
|
+
NERA::SimulatorRecords.create_table( @path_to_db)
|
12
|
+
@db = NERA::SimulatorRecords.new( @path_to_db)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
FileUtils.chdir('..')
|
17
|
+
FileUtils.rm_r(@testdir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_constructor
|
21
|
+
assert_raise( RuntimeError) {
|
22
|
+
NERA::SimulatorRecords.new('unknown_file')
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_table
|
27
|
+
f = NERA::SimulatorRecords.create_table( @path_to_db)
|
28
|
+
assert_equal( nil, f)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_keys
|
32
|
+
assert_equal( [:id,:name,:created_at,:updated_at], @db.keys)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_add
|
36
|
+
assert_raise( ArgumentError) {
|
37
|
+
@db.add( Temp)
|
38
|
+
}
|
39
|
+
|
40
|
+
given_id = @db.add( Ising )
|
41
|
+
l = @db.list
|
42
|
+
assert_equal(1, given_id)
|
43
|
+
assert_equal( 1, l[0][:id])
|
44
|
+
assert_equal( "Ising", l[0][:name])
|
45
|
+
assert_equal( l[0][:updated_at], l[0][:created_at])
|
46
|
+
|
47
|
+
sleep 2
|
48
|
+
given_id = @db.add( XY )
|
49
|
+
l = @db.list
|
50
|
+
assert_equal(2, given_id)
|
51
|
+
assert_equal( 2, l[1][:id])
|
52
|
+
assert_equal( "XY", l[1][:name])
|
53
|
+
assert_equal( l[1][:updated_at], l[1][:created_at])
|
54
|
+
|
55
|
+
assert( l[0][:updated_at] < l[1][:updated_at])
|
56
|
+
|
57
|
+
flag = @db.add( XY )
|
58
|
+
assert_equal( nil, flag)
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_three
|
62
|
+
@db.add( Ising )
|
63
|
+
@db.add( XY )
|
64
|
+
@db.add( Heisenberg )
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_get_class
|
68
|
+
add_three
|
69
|
+
klass = @db.get_class(1)
|
70
|
+
assert_equal( Ising, klass)
|
71
|
+
klass = @db.get_class(3)
|
72
|
+
assert_equal( Heisenberg, klass)
|
73
|
+
|
74
|
+
klass = @db.get_class(5)
|
75
|
+
assert_nil(klass)
|
76
|
+
|
77
|
+
assert_raise( ArgumentError) {
|
78
|
+
@db.get_class('2')
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_list
|
83
|
+
# ------
|
84
|
+
l = @db.list
|
85
|
+
assert( l.is_a?(Array) )
|
86
|
+
assert( l.size == 0 )
|
87
|
+
|
88
|
+
# ------
|
89
|
+
add_three
|
90
|
+
l = @db.list
|
91
|
+
assert_equal( 3, l.size)
|
92
|
+
l2 = l.dup
|
93
|
+
l2.sort! do |a,b|
|
94
|
+
a[:id] <=> b[:id]
|
95
|
+
end
|
96
|
+
assert_equal( l, l2)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_touch
|
100
|
+
add_three
|
101
|
+
sleep 3
|
102
|
+
flag = @db.touch( 3)
|
103
|
+
assert_equal(true, flag)
|
104
|
+
r3 = @db.list[2]
|
105
|
+
assert( r3[:created_at] < r3[:updated_at])
|
106
|
+
r2 = @db.list[1]
|
107
|
+
assert( r2[:created_at] == r2[:updated_at])
|
108
|
+
|
109
|
+
# ------
|
110
|
+
flag = @db.touch( 500)
|
111
|
+
assert_nil( flag)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_destroy
|
115
|
+
add_three
|
116
|
+
r3 = @db.list[2]
|
117
|
+
flag = @db.destroy(3)
|
118
|
+
assert_equal(r3, flag)
|
119
|
+
|
120
|
+
l = @db.list
|
121
|
+
assert_equal( 2, l.size)
|
122
|
+
assert_nil( l.find do |r| r[:id]==3 end )
|
123
|
+
|
124
|
+
flag = @db.destroy(500)
|
125
|
+
assert_nil(flag)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_transaction
|
129
|
+
add_three
|
130
|
+
assert_raise(RuntimeError) {
|
131
|
+
@db.transaction {
|
132
|
+
@db.destroy(2)
|
133
|
+
raise
|
134
|
+
}
|
135
|
+
}
|
136
|
+
l = @db.list
|
137
|
+
assert_equal( 3, l.size)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nera
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yohsuke Murase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-26 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.3.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
version:
|
35
|
+
description: This is an application which helps you to manage a database for the Monte Carlo simulations. For the dtailed usage, see http://nera.rubyforge.com
|
36
|
+
email:
|
37
|
+
- murase@serow.t.u-tokyo.ac.jp
|
38
|
+
executables:
|
39
|
+
- nera
|
40
|
+
- nera_addsim
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- History.txt
|
45
|
+
- Manifest.txt
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- History.txt
|
49
|
+
- Manifest.txt
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- bin/nera
|
53
|
+
- bin/nera_addsim
|
54
|
+
- lib/nera.rb
|
55
|
+
- lib/nera/nera_cui.rb
|
56
|
+
- lib/nera/nera_database.rb
|
57
|
+
- lib/nera/nera_db_folders.rb
|
58
|
+
- lib/nera/nera_dialog.rb
|
59
|
+
- lib/nera/nera_job_layer_controller.rb
|
60
|
+
- lib/nera/nera_job_records.rb
|
61
|
+
- lib/nera/nera_job_script.rb
|
62
|
+
- lib/nera/nera_parameter_layer_controller.rb
|
63
|
+
- lib/nera/nera_parameter_records.rb
|
64
|
+
- lib/nera/nera_run_layer_controller.rb
|
65
|
+
- lib/nera/nera_run_records.rb
|
66
|
+
- lib/nera/nera_simulator.rb
|
67
|
+
- lib/nera/nera_simulator_layer_controller.rb
|
68
|
+
- lib/nera/nera_simulator_records.rb
|
69
|
+
- lib/nera_addsim/make_simulator.rb
|
70
|
+
- scripts/make_manifest.rb
|
71
|
+
- test/runner.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- test/test_nera_database.rb
|
74
|
+
- test/test_nera_db_folders.rb
|
75
|
+
- test/test_nera_dialog.rb
|
76
|
+
- test/test_nera_job_layer_controller.rb
|
77
|
+
- test/test_nera_job_records.rb
|
78
|
+
- test/test_nera_parameter_layer_controller.rb
|
79
|
+
- test/test_nera_parameter_records.rb
|
80
|
+
- test/test_nera_run_layer_controller.rb
|
81
|
+
- test/test_nera_run_records.rb
|
82
|
+
- test/test_nera_simulator.rb
|
83
|
+
- test/test_nera_simulator_layer_controller.rb
|
84
|
+
- test/test_nera_simulator_records.rb
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://nera.rubyforge.com
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- --main
|
90
|
+
- README.rdoc
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project: nera
|
108
|
+
rubygems_version: 1.2.0
|
109
|
+
signing_key:
|
110
|
+
specification_version: 2
|
111
|
+
summary: This is an application which helps you to manage a database for the Monte Carlo simulations
|
112
|
+
test_files:
|
113
|
+
- test/test_helper.rb
|
114
|
+
- test/test_nera_database.rb
|
115
|
+
- test/test_nera_db_folders.rb
|
116
|
+
- test/test_nera_dialog.rb
|
117
|
+
- test/test_nera_job_layer_controller.rb
|
118
|
+
- test/test_nera_job_records.rb
|
119
|
+
- test/test_nera_parameter_layer_controller.rb
|
120
|
+
- test/test_nera_parameter_records.rb
|
121
|
+
- test/test_nera_run_layer_controller.rb
|
122
|
+
- test/test_nera_run_records.rb
|
123
|
+
- test/test_nera_simulator.rb
|
124
|
+
- test/test_nera_simulator_layer_controller.rb
|
125
|
+
- test/test_nera_simulator_records.rb
|