mesa_test 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mesa_test +124 -141
  3. data/lib/mesa_test.rb +154 -60
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52edc717f3e8c1322b3448c01cb323857d86a1a2
4
- data.tar.gz: 7287c330978661cd7a4a265c24f57cb09807a340
3
+ metadata.gz: a8cc4cbf769460ee63c65aaff5c1e61d5d762fe7
4
+ data.tar.gz: '096c818d3a7f9f0e86cc2a2fe1dc59d03476cc51'
5
5
  SHA512:
6
- metadata.gz: 9424e51b29121151ad2abc2b4d8ea5969263e0785a68111755b4b9318c722fb610f790d94a948b565c528d9b12fb76bc3c904a919a3dbaa5244207d8742a7146
7
- data.tar.gz: aa31face553ef21a787e8a0540ac67a965e670f1009093390b5f02755c080b98bc6f56eda7b75c745ac0f6476306b9975238ceda3dbc3421f35a78e1593ffbc2
6
+ metadata.gz: 92f2cfd3aa55cb4bcc396499d993bc994f112c8f192a938966120f05c174cd125308d922889848a78aef4f78aae329f1157794344d43be3486036c75ab26a1dd
7
+ data.tar.gz: 73550ea45adde5b962ef00bea03efaadab4b378601286239c78b4ccf62cf1bccd2478c3d365bbfc32d5d3239e131df78f3f59bc37d6011c03120f86a7fc027f8
data/bin/mesa_test CHANGED
@@ -5,6 +5,8 @@ require 'mesa_test'
5
5
  require 'thor'
6
6
 
7
7
  class MesaTest < Thor
8
+ DEVLOPMENT_URI = 'http://localhost:3000'.freeze
9
+
8
10
  desc 'setup [CONFIG_FILE]', 'Setup MesaTestHub config file.'
9
11
  long_desc <<-LONGDESC
10
12
  If optional CONFIG_FILE is provided, search for that file and load it
@@ -17,11 +19,11 @@ class MesaTest < Thor
17
19
  force_setup: true)
18
20
  end
19
21
 
20
- desc 'test_one MESA_DIR TEST_CASE', "run, check, and submit one test case"
22
+ desc 'test_one MESA_DIR TEST_CASE', 'run, check, and submit one test case'
21
23
  long_desc <<-LONGDESC
22
24
  Run and check TEST_CASE, which resides in MESA_DIR/star/test_suite. Then
23
25
  report results to MesaTestHub. TEST_CASE can also be an integer corresponding
24
- to the line number of the test name in its do1_test_source file (or a
26
+ to the line number of the test name in its do1_test_source file (or a
25
27
  concatenated version of that file if no module is specified). Modules are
26
28
  searched/concatenated in this order:
27
29
 
@@ -49,38 +51,11 @@ class MesaTest < Thor
49
51
  option :module, type: :string, default: :all
50
52
  option :submit, type: :boolean, default: true
51
53
  def test_one(mesa_dir, test_case_name)
52
- if options[:submit]
53
- s = MesaTestSubmitter.new_from_config
54
- unless options[:force]
55
- s.setup unless s.confirm_computer_data
56
- end
57
-
58
- check_user_and_computer s
59
- end
60
-
61
- # set up and check mesa directory (doesn't really check to see if it's
62
- # installed, just to see if it has a version number and a test suite
63
- # directory)
64
- m = Mesa.new mesa_dir: mesa_dir
65
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download and " +
66
- "install a valid MESA version or provide the path to one." unless
67
- m.installed?
68
- m.load_test_source_data
69
-
70
- # choose whether to update checksums
71
- m.update_checksums = !options[:diff]
72
-
73
- # make sure the test case is valid
74
- t = m.find_test_case(test_case_name: test_case_name,
75
- mod: options[:module].downcase.to_sym)
76
- if t.nil?
77
- msg = "No such test case, #{test_case_name} found in any of "
78
- msg << MesaTestCase.modules.map do |mod|
79
- File.join(m.test_suite_dir(mod: mod), 'do1_test_source')
80
- end.join(' or ')
81
- msg << '.'
82
- raise TestCaseDirError, msg
83
- end
54
+ s = create_and_check_submitter(force: options[:force]) if options[:submit]
55
+ m = create_and_check_mesa(mesa_dir: mesa_dir, diff: options[:diff],
56
+ mod: options[:module].downcase.to_sym)
57
+ t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
58
+ mod: options[:module].downcase.to_sym)
84
59
 
85
60
  # clean and run test
86
61
  t.clean
@@ -89,17 +64,16 @@ class MesaTest < Thor
89
64
  # log results
90
65
  t.log_results if options[:log]
91
66
 
67
+ # bail out if not submitting
68
+ return unless options[:submit]
69
+
92
70
  # submit results
93
- if options[:submit]
94
- print 'Submitting results to ' + s.base_uri + '... '
95
- s.submit(t)
96
- puts "Done."
97
- puts ""
98
- end
71
+ print 'Submitting results to ' + s.base_uri + '... '
72
+ s.submit(t)
73
+ puts "Done.\n"
99
74
  end
100
75
 
101
-
102
- desc "test_all MESA_DIR", "run, check, and submit all test cases"
76
+ desc 'test_all MESA_DIR', 'run, check, and submit all test cases'
103
77
  long_desc <<-LONGDESC
104
78
  Run and check all test cases residing in MESA_DIR/star/test_suite. Then
105
79
  report results to MesaTestHub. Specifically, runs and checks all tests
@@ -113,6 +87,9 @@ class MesaTest < Thor
113
87
  in ~/.mesa_test.yml are correct. Only relevant if --submit option is on
114
88
  (by default it is).
115
89
 
90
+ With --module option, select which module to search through, with the default
91
+ being "all" (search all modules in order). Example: --module=star.
92
+
116
93
  With --log option, save yml file of test results in test directory and a
117
94
  summary in the test suite directory. On by default. Shut off with --no-log.
118
95
 
@@ -122,34 +99,19 @@ class MesaTest < Thor
122
99
  option :diff, type: :boolean, default: true
123
100
  option :force, type: :boolean, aliases: '-f'
124
101
  option :log, type: :boolean, default: true
102
+ option :module, type: :string, default: :all
125
103
  option :submit, type: :boolean, default: true
126
104
  def test_all(mesa_dir)
127
-
128
- if options[:submit]
129
- s = MesaTestSubmitter.new_from_config
130
- unless options[:force]
131
- unless s.confirm_computer_data
132
- s.setup
133
- end
134
- end
135
- check_user_and_computer s
136
- end
137
-
138
- # set up and check mesa directory (doesn't really check to see if it's
139
- # installed, just to see if it has a version number and a test suite
140
- # directory)
141
- m = Mesa.new mesa_dir: mesa_dir
142
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download and " +
143
- "install a valid MESA version or provide the path to one." unless
144
- m.installed?
145
- m.load_test_source_data
105
+ s = create_and_check_submitter(force: options[:force]) if options[:submit]
106
+ m = create_and_check_mesa(mesa_dir: mesa_dir, diff: options[:diff],
107
+ mod: options[:module].downcase.to_sym)
146
108
 
147
109
  # run all tests
148
- m.update_checksums = !options[:diff]
149
- m.each_test_run_and_diff(log_results: options[:log])
110
+ m.each_test_run_and_diff(log_results: options[:log],
111
+ mod: options[:module].downcase.to_sym)
150
112
 
151
113
  # submit all tests
152
- s.submit_all(m) if options[:submit]
114
+ s.submit_all(m, options[:module].downcase.to_sym) if options[:submit]
153
115
  end
154
116
 
155
117
  desc 'submit_one MESA_DIR TEST_CASE', 'submit one completed test case'
@@ -159,7 +121,7 @@ class MesaTest < Thor
159
121
  name in its do1_test_source file (or a concatenated version of that file if
160
122
  no module is specified). Modules are searched/concatenated in this order:
161
123
 
162
- #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(", ") }
124
+ #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(', ')}
163
125
 
164
126
  With --force option, skip confirmation of computer details, assuming values
165
127
  in ~/.mesa_test.yml are correct.
@@ -170,35 +132,11 @@ class MesaTest < Thor
170
132
  option :force, type: :boolean, aliases: '-f'
171
133
  option :module, type: :string, aliases: '-m', default: 'all'
172
134
  def submit_one(mesa_dir, test_case_name)
173
- s = MesaTestSubmitter.new_from_config
174
- unless options[:force]
175
- s.setup unless s.confirm_computer_data
176
- end
177
-
178
- check_user_and_computer s
179
-
180
- # set up and check mesa directory (doesn't really check to see if it's
181
- # installed, just to see if it has a version number and a test suite
182
- # directory)
183
- m = Mesa.new mesa_dir: mesa_dir
184
- unless m.installed?
185
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download " \
186
- 'and install a valid MESA version or provide the path to one.'
187
- end
188
- m.load_test_source_data
189
-
190
- # make sure the test case is valid
191
- t = m.find_test_case(test_case_name: test_case_name,
192
- mod: options[:module].downcase.to_sym)
193
- if t.nil?
194
- msg = "No such test case, #{test_case_name} found in any of "
195
- msg << MesaTestCase.modules.map do |mod|
196
- File.join(m.test_suite_dir(mod: mod), 'do1_test_source')
197
- end.join(' or ')
198
- msg << '.'
199
- raise TestCaseDirError, msg
200
- end
201
-
135
+ s = create_and_check_submitter(force: options[:force])
136
+ m = create_and_check_mesa(mesa_dir: mesa_dir,
137
+ mod: options[:module].downcase.to_sym)
138
+ t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
139
+ mod: options[:module].downcase.to_sym)
202
140
  # load test results
203
141
  t.load_results
204
142
 
@@ -216,103 +154,105 @@ class MesaTest < Thor
216
154
 
217
155
  With --force option, skip confirmation of computer details, assuming values
218
156
  in ~/.mesa_test.yml are correct.
157
+
158
+ With --module option, select which module to search through, with the default
159
+ being "all" (search all modules in order). Example: --module=star.
219
160
  LONGDESC
220
161
  option :force, type: :boolean, aliases: '-f'
162
+ option :module, type: :string, aliases: '-m', default: 'all'
221
163
  def submit_all(mesa_dir)
222
- s = MesaTestSubmitter.new_from_config
223
- unless options[:force]
224
- s.setup unless s.confirm_computer_data
225
- end
226
- check_user_and_computer s
164
+ s = create_and_check_submitter(force: options[:force])
165
+ m = create_and_check_mesa(mesa_dir: mesa_dir,
166
+ mod: options[:module].downcase.to_sym)
227
167
 
228
- # set up and check mesa directory (doesn't really check to see if it's
229
- # installed, just to see if it has a version number and a test suite
230
- # directory)
231
- m = Mesa.new mesa_dir: mesa_dir
232
- unless m.installed?
233
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download " \
234
- 'and install a valid MESA version or provide the path to one.'
235
- end
236
- m.load_test_source_data
237
-
238
- # run all tests
239
- m.each_test_load_results
168
+ # load all test data
169
+ m.each_test_load_results(mod: options[:module].downcase.to_sym)
240
170
 
241
171
  # submit all tests
242
- s.submit_all(m)
172
+ s.submit_all(m, options[:module].downcase.to_sym)
243
173
  end
244
174
 
245
-
246
- desc "install VERSION_NUMBER MESA_DIR", 'download and install mesa release '+
175
+ desc 'install VERSION_NUMBER MESA_DIR', 'download and install mesa release '\
247
176
  'VERSION_NUMBER to directory MESA_DIR'
248
177
  long_desc <<-LONGDESC
249
- Calls to svn to install mesa release VERSION_NUMBER into the directory
178
+ Calls to svn to install mesa release VERSION_NUMBER into the directory
250
179
  MESA_DIR. Basically just an svn checkout followed by going into the directory
251
180
  and running ./clean and ./install. SDK or compilers must be set up prior.
252
181
  Does not affect the user's MESA_DIR or other environment variables.
253
182
  LONGDESC
254
183
  def install(version, mesa_dir)
255
- m = Mesa.download(version_number:version, new_mesa_dir: mesa_dir)
184
+ m = Mesa.download(version_number: version, new_mesa_dir: mesa_dir)
256
185
  m.clean
257
186
  m.install
258
187
  end
259
188
 
260
-
261
- desc "install_and_test_all VERSION_NUMBER MESA_DIR", 'download and install ' +
189
+ desc 'install_and_test_all VERSION_NUMBER MESA_DIR', 'download and install '\
262
190
  'mesa release VERSION_NUMBER to directory MESA_DIR and run/submit all tests'
263
191
  long_desc <<-LONGDESC
264
- Calls to svn to install mesa release VERSION_NUMBER into the directory
192
+ Calls to svn to install mesa release VERSION_NUMBER into the directory
265
193
  MESA_DIR. Basically just an svn checkout followed by going into the directory
266
194
  and running ./clean and ./install. SDK or compilers must be set up prior.
267
- Once installation is complete, run the test suite, and report results to
195
+ Once installation is complete, run the test suite, and report results to
268
196
  MesaTestHub. Does not affect the user's MESA_DIR or other environment
269
- variables. This is basically a shortcut for running
197
+ variables. This is basically a shortcut for running
270
198
 
271
199
  `mesa_test install SOME_VERSION SOME_DIR`
272
200
 
273
- followed by
201
+ followed by
274
202
 
275
203
  `mesa_test test_all SOME_DIR`
276
204
 
205
+ If VERSION_NUMBER is 'non-paxton', then the most recent commit by anyone
206
+ other than Bill Paxton ('bill_paxton') is tested and the --diff flag is
207
+ ignored and set to false. Note that using 'HEAD' for version number will
208
+ automatically select the most recent release, regardless of the author.
209
+
210
+ With --diff option, assume the checksums are up-to-date (behave like
211
+ each_test_run_and_diff), on by default. To update checksums after ./rn
212
+ (behave like each_test_run), use --no-diff.
213
+
277
214
  Use flag --destroy to self destruct MESA_DIR after successful test
278
215
  submission. Essentially does rm -rf MESA_DIR after the test suite. Useful
279
216
  for automated testing without piling up disk space.
280
217
 
281
218
  Use flag --force to skip confirmation of computer details if they can be
282
219
  read from ~/.mesa_test.yml.
220
+
221
+ With --log option, save yml file of test results in test directory and a
222
+ summary in the test suite directory. On by default. Shut off with --no-log.
223
+
224
+ With --module option, select which module to search through, with the default
225
+ being "all". Example: --module=star.
283
226
  LONGDESC
227
+ option :diff, type: :boolean, default: true
284
228
  option :destroy, type: :boolean
229
+ option :log, type: :boolean, default: true
285
230
  option :force, type: :boolean, aliases: '-f'
231
+ option :module, type: :string, aliases: '-m', default: 'all'
286
232
  def install_and_test_all(version, mesa_dir)
287
- s = MesaTestSubmitter.new_from_config
288
- unless options[:force]
289
- unless s.confirm_computer_data
290
- s.setup
291
- end
292
- end
293
-
294
- m = Mesa.download(version_number:version, new_mesa_dir: mesa_dir)
233
+ s = create_and_check_submitter(force: options[:force])
234
+ mesa_version, diff = filter_version_and_diff(version, s)
235
+ m = Mesa.download(version_number: mesa_version, new_mesa_dir: mesa_dir)
295
236
  m.clean
296
237
  m.install
297
238
 
298
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download and " +
299
- "install a valid MESA version or provide the path to one." unless
300
- m.installed?
301
- m.load_test_source_data
239
+ m = create_and_check_mesa(mesa_dir: mesa_dir, diff: diff,
240
+ mod: options[:module].downcase.to_sym)
302
241
 
303
- # run all tests
304
- m.each_test_run_and_diff
242
+ # run all tests. Don't be fooled, whether or not a diff happens is set
243
+ # by the diff attribute of the mesa object, set above.
244
+ m.each_test_run_and_diff(mod: options[:module].downcase.to_sym,
245
+ log_results: options[:log])
305
246
 
306
247
  # submit all tests
307
- successfully_submitted = s.submit_all(m)
248
+ successfully_submitted = s.submit_all(m, options[:module].downcase.to_sym)
308
249
 
309
250
  # if requested, and if submission successful, destroy the directory
310
- if successfully_submitted and options[:destroy]
311
- m.destroy
312
- end
251
+ m.destroy if successfully_submitted && options[:destroy]
313
252
  end
314
253
 
315
254
  private
255
+
316
256
  def check_user_and_computer(submitter)
317
257
  computer_check = submitter.confirm_computer
318
258
  if computer_check['valid']
@@ -323,9 +263,52 @@ class MesaTest < Thor
323
263
  end
324
264
  end
325
265
 
266
+ def create_and_check_submitter(force: false)
267
+ s = MesaTestSubmitter.new_from_config
268
+ # s = MesaTestSubmitter.new_from_config(base_uri: DEFAULT_URI)
269
+ unless force
270
+ s.setup unless s.confirm_computer_data
271
+ end
272
+ check_user_and_computer s
273
+ s
274
+ end
326
275
 
327
- end
276
+ def create_and_check_mesa(mesa_dir:, diff: true, mod: :all)
277
+ m = Mesa.new mesa_dir: mesa_dir
278
+ unless m.installed?
279
+ raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download " \
280
+ 'and install a valid MESA version or provide the path to one.'
281
+ end
282
+ m.load_test_source_data(mod: mod)
283
+
284
+ # choose whether to update checksums
285
+ m.update_checksums = !diff
286
+ m
287
+ end
328
288
 
289
+ def create_and_check_test_case(mesa:, test_case_name:, mod: :all)
290
+ t = mesa.find_test_case(test_case_name: test_case_name, mod: mod)
291
+ # return test case if it was found
292
+ return t unless t.nil?
293
+ # test case was not found. Throw an error.
294
+ msg = "No such test case, #{test_case_name} found in any of "
295
+ # this should care about the value in `mod`. Current behavior is only
296
+ # appropriate if `mod` is :all.
297
+ msg << MesaTestCase.modules.map do |this_mod|
298
+ File.join(m.test_suite_dir(mod: this_mod), 'do1_test_source')
299
+ end.join(' or ')
300
+ msg << '.'
301
+ raise TestCaseDirError, msg
302
+ end
303
+
304
+ def filter_version_and_diff(version, submitter)
305
+ if version.downcase == 'non-paxton'
306
+ [Mesa.last_non_paxton_revision(submitter.last_tested), false]
307
+ else
308
+ [version, options[:diff]]
309
+ end
310
+ end
311
+ end
329
312
 
330
313
  # actually start the CLI
331
314
  MesaTest.start(ARGV)
data/lib/mesa_test.rb CHANGED
@@ -12,11 +12,16 @@ MesaDirError = Class.new(StandardError)
12
12
  TestCaseDirError = Class.new(StandardError)
13
13
  InvalidDataType = Class.new(StandardError)
14
14
 
15
+ Commit = Struct.new(:revision, :author, :datetime, :message)
16
+ DEFAULT_REVISION = 10_000
17
+
15
18
  class MesaTestSubmitter
19
+ DEFAULT_URI = 'https://mesa-test-hub.herokuapp.com'.freeze
20
+
16
21
  # set up config file for computer
17
22
  def setup
18
23
  update do |s|
19
- shell.say 'This wizard will guide you through setting up a computer
24
+ shell.say 'This wizard will guide you through setting up a computer
20
25
  profile and default data for test case submissions to MESATestHub. You
21
26
  will be able to confirm entries at the end. Default/current values are always
22
27
  shown in parentheses at the end of a prompt. Pressing enter will accept the
@@ -74,6 +79,12 @@ e-mail and password will be stored in plain text.'
74
79
  "7.2.0)? (#{s.compiler_version}): ", :blue
75
80
  s.compiler_version = response unless response.empty?
76
81
 
82
+ # Get earliest revision to check
83
+ response = shell.ask "What's the earliest revision to search back to " \
84
+ 'when finding the latest testable revision (eg. 10000)? ' \
85
+ "(#{s.last_tested}): ", :blue
86
+ s.last_tested = response.to_i unless response.empty?
87
+
77
88
  # Confirm save location
78
89
  response = shell.ask "This will be saved in #{s.config_file}. Press " \
79
90
  'enter to accept or enter a new location:', :blue, path: true
@@ -91,7 +102,7 @@ e-mail and password will be stored in plain text.'
91
102
 
92
103
  def self.new_from_config(
93
104
  config_file: File.join(ENV['HOME'], '.mesa_test.yml'), force_setup: false,
94
- base_uri: 'https://mesa-test-hub.herokuapp.com'
105
+ base_uri: DEFAULT_URI
95
106
  # base_uri: 'http://localhost:3000'
96
107
  )
97
108
  new_submitter = new(config_file: config_file, base_uri: base_uri)
@@ -107,7 +118,7 @@ e-mail and password will be stored in plain text.'
107
118
 
108
119
  attr_accessor :computer_name, :user_name, :email, :password, :platform,
109
120
  :platform_version, :processor, :ram_gb, :compiler,
110
- :compiler_version, :config_file, :base_uri
121
+ :compiler_version, :config_file, :base_uri, :last_tested
111
122
 
112
123
  attr_reader :shell
113
124
 
@@ -115,7 +126,7 @@ e-mail and password will be stored in plain text.'
115
126
  def initialize(
116
127
  computer_name: nil, user_name: nil, email: nil, platform: nil,
117
128
  platform_version: nil, processor: nil, ram_gb: nil, compiler: nil,
118
- compiler_version: nil, config_file: nil, base_uri: nil
129
+ compiler_version: nil, config_file: nil, base_uri: nil, last_tested: nil
119
130
  )
120
131
  @computer_name = computer_name || Socket.gethostname.scan(/^[^\.]+\.?/)[0]
121
132
  @computer_name.chomp!('.') if @computer_name
@@ -140,6 +151,7 @@ e-mail and password will be stored in plain text.'
140
151
  @compiler_version = compiler_version || ''
141
152
  @config_file = config_file || File.join(ENV['HOME'], '.mesa_test.yml')
142
153
  @base_uri = base_uri
154
+ @last_tested = last_tested || DEFAULT_REVISION
143
155
 
144
156
  # set up thor-proof way to get responses from user. Thor hijacks the
145
157
  # gets command, so we have to use its built-in "ask" method, which is
@@ -164,11 +176,12 @@ e-mail and password will be stored in plain text.'
164
176
  puts "Processor #{processor}"
165
177
  puts "RAM #{ram_gb} GB"
166
178
  puts "Compiler #{compiler} #{compiler_version}"
179
+ puts "Last tested revision #{last_tested}"
167
180
  puts "Config location #{config_file}"
168
181
  puts '-------------------------------------------------------'
169
182
  puts ''
170
183
  response = shell.ask 'Is this correct? (y/Y = Yes, anything else = No):'
171
- response.strip.casecmp('y') == 0
184
+ response.strip.casecmp('y').zero?
172
185
  end
173
186
 
174
187
  # For one "computer" on the web server, and for [subjective] consistency
@@ -196,7 +209,8 @@ e-mail and password will be stored in plain text.'
196
209
  'ram_gb' => ram_gb,
197
210
  'platform_version' => platform_version,
198
211
  'compiler' => compiler,
199
- 'compiler_version' => compiler_version
212
+ 'compiler_version' => compiler_version,
213
+ 'last_tested' => last_tested
200
214
  }
201
215
  File.open(config_file, 'w') { |f| f.write(YAML.dump(data_hash)) }
202
216
  end
@@ -213,6 +227,7 @@ e-mail and password will be stored in plain text.'
213
227
  @platform_version = data_hash['platform_version']
214
228
  @compiler = data_hash['compiler']
215
229
  @compiler_version = data_hash['compiler_version']
230
+ @last_tested = data_hash['last_tested'] || @last_tested
216
231
  end
217
232
 
218
233
  # create and return hash of parameters for a TestInstance submission
@@ -290,58 +305,117 @@ e-mail and password will be stored in plain text.'
290
305
  response.is_a? Net::HTTPCreated
291
306
  end
292
307
 
293
- def submit_all(mesa)
308
+ def submit_all(mesa, mod = :all)
294
309
  submitted_cases = []
295
310
  unsubmitted_cases = []
296
- mesa.test_names.each do |mod, test_names|
297
- test_names.each do |test_name|
311
+ if mod == :all
312
+ success = true
313
+ mesa.test_names.each_key do |this_mod|
314
+ success &&= submit_all(mesa, mod = this_mod)
315
+ end
316
+ else
317
+ mesa.test_names[mod].each do |test_name|
298
318
  # get at test case
299
319
  test_case = mesa.test_cases[mod][test_name]
300
320
  # try to submit and note if it does or doesn't successfully submit
301
321
  submitted = false
302
- unless test_case.outcome == :not_tested
303
- submitted = submit(test_case)
304
- end
305
-
322
+ submitted = submit(test_case) unless test_case.outcome == :not_tested
306
323
  if submitted
307
324
  submitted_cases << test_name
308
325
  else
309
326
  unsubmitted_cases << test_name
310
327
  end
311
328
  end
329
+ puts "\n Submission results for #{mod} module:"
330
+ puts '#####################################'
331
+ if !submitted_cases.empty?
332
+ shell.say 'Submitted the following cases:', :green
333
+ puts submitted_cases.join("\n")
334
+ else
335
+ shell.say 'Did not successfully submit any cases.', :red
336
+ end
337
+ unless unsubmitted_cases.empty?
338
+ puts "\n\n\n"
339
+ shell.say 'Failed to submit the following cases:', :red
340
+ puts unsubmitted_cases.join("\n")
341
+ end
342
+ # return true and update last tested if all cases were submitted
343
+ success = submitted_cases.length == mesa.test_names.length
344
+ if success
345
+ last_tested = mesa.version
346
+ shell.say "\n\nUpdating last tested revision to #{last_tested}."
347
+ save_computer_data
348
+ end
312
349
  end
313
- puts ''
314
- if not submitted_cases.empty?
315
- shell.say 'Submitted the following cases:', :green
316
- puts submitted_cases.join("\n")
317
- else
318
- shell.say 'Did not successfully submit any cases.', :red
319
- end
320
- if not unsubmitted_cases.empty?
321
- puts "\n\n\n"
322
- shell.say 'Failed to submit the following cases:', :red
323
- puts unsubmitted_cases.join("\n")
324
- end
325
- # return true if all cases were submitted
326
- submitted_cases.length == mesa.test_names.length
350
+ # return boolean indicating whether or not all cases successfully
351
+ # SUBMITTED (irrespective of passing status)
352
+ success
327
353
  end
328
354
  end
329
355
 
330
356
  class Mesa
357
+ SVN_URI = 'svn://svn.code.sf.net/p/mesa/code/trunk'.freeze
358
+
331
359
  attr_reader :mesa_dir, :test_data, :test_names, :test_cases, :shell
332
360
  attr_accessor :update_checksums
333
361
 
334
362
  def self.download(version_number: nil, new_mesa_dir: nil)
335
363
  new_mesa_dir ||= File.join(ENV['HOME'], 'mesa-test-r' + version_number.to_s)
336
- success = system("svn co -r #{version_number} "+
364
+ success = system("svn co -r #{version_number} " \
337
365
  "svn://svn.code.sf.net/p/mesa/code/trunk #{new_mesa_dir}")
338
366
  unless success
339
- raise MesaDirError, "Encountered a problem in download mesa " +
367
+ raise MesaDirError, 'Encountered a problem in download mesa ' \
340
368
  "revision #{version_number}."
341
369
  end
342
370
  Mesa.new(mesa_dir: new_mesa_dir)
343
371
  end
344
372
 
373
+ def self.log_since(last_tested = DEFAULT_REVISION)
374
+ # svn commit log back to, but excluding, the last revision tested
375
+ `svn log #{SVN_URI} -r #{last_tested + 1}:HEAD`
376
+ end
377
+
378
+ def self.log_lines_since(last_tested = DEFAULT_REVISION)
379
+ log_since(last_tested).split("\n").reject(&:empty?)
380
+ end
381
+
382
+ def self.add_commit(commits, revision, author)
383
+ commits << Commit.new
384
+ commits.last.revision = revision.to_i
385
+ commits.last.author = author
386
+ commits.last.message = []
387
+ end
388
+
389
+ def self.process_line(commits, line)
390
+ last = commits.last
391
+ if line =~ /^-+$/
392
+ # dashed lines separate commits
393
+ # Done with last commit (if it exists), so clean up message
394
+ last.message = last.message.join("\n") unless last.nil?
395
+ elsif line =~ /^r(\d+) \| (\w+) \| .* \| \d+ lines?$/
396
+ # first line of a commit, scrape data and make new commit
397
+ add_commit(commits, $1, $2)
398
+ else
399
+ # add lines to the message (will concatenate later to single String)
400
+ last.message << line.strip
401
+ end
402
+ end
403
+
404
+ # all commits since the given version number
405
+ def self.commits_since(last_tested = DEFAULT_REVISION)
406
+ commits = []
407
+ log_lines_since(last_tested).each { |line| process_line(commits, line) }
408
+ commits.sort_by(&:revision).reverse
409
+ end
410
+
411
+ def self.last_non_paxton_revision(last_tested = DEFAULT_REVISION)
412
+ commits_since(last_tested).each do |commit|
413
+ return commit.revision unless commit.author == 'bill_paxton'
414
+ end
415
+ # give out garbage if no valid commit is found
416
+ nil
417
+ end
418
+
345
419
  def initialize(mesa_dir: ENV['MESA_DIR'])
346
420
  @mesa_dir = mesa_dir
347
421
  @update_checksums = false
@@ -355,8 +429,23 @@ class Mesa
355
429
  @shell = Thor::Shell::Color.new
356
430
  end
357
431
 
358
- # read version number from $MESA_DIR/data/version_number
359
432
  def version_number
433
+ # prefer svn's reported version number
434
+ version = svn_version_number
435
+ # fall back to MESA_DIR/data's version number svn didn't work
436
+ version = data_version_number unless version > 0
437
+ version
438
+ end
439
+
440
+ # get version number from svn (preferred method)
441
+ def svn_version_number
442
+ return `svnversion #{mesa_dir}`.strip.to_i
443
+ rescue Errno::ENOENT
444
+ return 0
445
+ end
446
+
447
+ # read version number from $MESA_DIR/data/version_number
448
+ def data_version_number
360
449
  contents = ''
361
450
  File.open(File.join(mesa_dir, 'data', 'version_number'), 'r') do |f|
362
451
  contents = f.read
@@ -365,8 +454,8 @@ class Mesa
365
454
  end
366
455
 
367
456
  def clean
368
- with_MESA_DIR do
369
- visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " +
457
+ with_mesa_dir do
458
+ visit_and_check mesa_dir, MesaDirError, 'E\countered a problem in ' \
370
459
  "running `clean` in #{mesa_dir}." do
371
460
  puts 'MESA_DIR = ' + ENV['MESA_DIR']
372
461
  puts './clean'
@@ -377,8 +466,8 @@ class Mesa
377
466
  end
378
467
 
379
468
  def install
380
- with_MESA_DIR do
381
- visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " +
469
+ with_mesa_dir do
470
+ visit_and_check mesa_dir, MesaDirError, 'Encountered a problem in ' \
382
471
  "running `install` in #{mesa_dir}." do
383
472
  puts 'MESA_DIR = ' + ENV['MESA_DIR']
384
473
  puts './install'
@@ -397,7 +486,7 @@ class Mesa
397
486
  def check_mod(mod)
398
487
  return if MesaTestCase.modules.include? mod
399
488
  raise TestCaseDirError, "Invalid module: #{mod}. Must be one of: " +
400
- MesaTestCase.modules.join(', ')
489
+ MesaTestCase.modules.join(', ')
401
490
  end
402
491
 
403
492
  def test_suite_dir(mod: nil)
@@ -435,7 +524,7 @@ class Mesa
435
524
  if line =~ no_skip
436
525
  found_test = true
437
526
  @test_data[mod][$1] = { success_string: $2, final_model: $3,
438
- photo: $4}
527
+ photo: $4}
439
528
  elsif line =~ one_skip
440
529
  found_test = true
441
530
  @test_data[mod][$1] = { success_string: $2, final_model: $3,
@@ -447,16 +536,17 @@ class Mesa
447
536
  end
448
537
 
449
538
  if found_test
450
- @test_names[mod] << $1 unless @test_names.include? $1
539
+ @test_names[mod] << $1 unless @test_names[mod].include? $1
451
540
  end
452
541
  end
453
542
 
454
543
  # make MesaTestCase objects accessible by name
455
544
  @test_names[mod].each do |test_name|
456
545
  data = @test_data[mod][test_name]
457
- @test_cases[mod][test_name] = MesaTestCase.new(test: test_name,
458
- mesa: self, success_string: data[:success_string], mod: mod,
459
- final_model: data[:final_model], photo: data[:photo])
546
+ @test_cases[mod][test_name] = MesaTestCase.new(
547
+ test: test_name, mesa: self, success_string: data[:success_string],
548
+ mod: mod, final_model: data[:final_model], photo: data[:photo]
549
+ )
460
550
  end
461
551
  end
462
552
  end
@@ -470,7 +560,7 @@ class Mesa
470
560
  end
471
561
  end
472
562
 
473
- # based off of `$MESA_DIR/star/test_suite/each_test_run_and_diff` from
563
+ # based off of `$MESA_DIR/star/test_suite/each_test_run_and_diff` from
474
564
  # revision 10000
475
565
  def each_test_clean(mod: :all)
476
566
  if mod == :all
@@ -495,7 +585,7 @@ class Mesa
495
585
  test_cases[mod][test_name].do_one
496
586
  test_cases[mod][test_name].log_results if log_results
497
587
  end
498
- log_summary if log_results
588
+ log_summary(mod: mod) if log_results
499
589
  end
500
590
  end
501
591
 
@@ -522,14 +612,14 @@ class Mesa
522
612
  def check_mesa_dir
523
613
  res = File.exist?(File.join(mesa_dir, 'data', 'version_number'))
524
614
  MesaTestCase.modules.each do |mod|
525
- res = res and File.directory? test_suite_dir(mod: mod)
526
- end
615
+ res &&= File.directory?(test_suite_dir(mod: mod))
616
+ end
527
617
  res
528
618
  end
529
619
 
530
620
  # change MESA_DIR for the execution of the block and then revert to the
531
621
  # original value
532
- def with_MESA_DIR
622
+ def with_mesa_dir
533
623
  # change MESA_DIR, holding on to old value
534
624
  orig_mesa_dir = ENV['MESA_DIR']
535
625
  ENV['MESA_DIR'] = mesa_dir
@@ -567,7 +657,7 @@ class Mesa
567
657
  end
568
658
  summary_file = File.join(test_suite_dir(mod: mod), 'test_summary.yml')
569
659
  File.open(summary_file, 'w') do |f|
570
- f.write(YAML::dump(res))
660
+ f.write(YAML.dump(res))
571
661
  end
572
662
  end
573
663
  end
@@ -752,6 +842,7 @@ class MesaTestCase
752
842
  'test_results.yml', color = :blue
753
843
  FileUtils.rm_f 'binary_history.data'
754
844
  FileUtils.rm_f 'out.txt'
845
+ FileUtils.rm_f 'test_results.yml'
755
846
  if File.directory? File.join('star_history', 'history_out')
756
847
  shell.say 'Removing all files of the form history_out* from ' \
757
848
  'star_history', :blue
@@ -809,13 +900,19 @@ class MesaTestCase
809
900
  return
810
901
  end
811
902
  data = YAML.safe_load(File.read(load_file), [Symbol])
812
- @runtime_seconds = data['runtime_seconds']
813
- @mod = data['module']
814
- @mesa_version = data['mesa_version']
815
- @outcome = data['outcome'].to_sym
816
- @test_omp_num_threads = data['omp_num_threads']
817
- @success_type = data['success_type']
818
- @failure_type = data['failure_type']
903
+ @runtime_seconds = data['runtime_seconds'] || @runtime_seconds
904
+ @mod = data['module'] || @mod
905
+ @mesa_version = data['mesa_version'] || @mesa_version
906
+ @outcome = data['outcome'] || @outcome
907
+ @test_omp_num_threads = data['omp_num_threads'] || @test_omp_num_threads
908
+ @success_type = data['success_type'] || @success_type
909
+ @failure_type = data['failure_type'] || @failure_type
910
+
911
+ # convert select data to symbols since that is how they are used
912
+ @outcome = @outcome.to_sym if @outcome
913
+ @success_type = @success_type.to_sym if @success_type
914
+ @failure_type = @failure_type.to_sym if @failure_type
915
+
819
916
  shell.say "Done loading data from #{load_file}.\n", :green
820
917
  end
821
918
 
@@ -928,13 +1025,10 @@ class MesaTestCase
928
1025
  puts "md5sum \"#{final_model}\" > checks.md5"
929
1026
  FileUtils.cp final_model, 'final_check.mod'
930
1027
 
931
- if not photo
932
- # if there's no photo, we won't check the checksum, so we've succeeded
933
- return succeed(:run_test_string)
934
- else
935
- # if there is a photo, we'll have to wait and see
936
- return true
937
- end
1028
+ # if there's no photo, we won't check the checksum, so we've succeeded
1029
+ return succeed(:run_test_string) unless photo
1030
+ # if there is a photo, we'll have to wait and see
1031
+ return true
938
1032
  end
939
1033
 
940
1034
  # check that final model matches
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mesa_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Wolf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json