mesa_test 0.2.15 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mesa_test +253 -430
  3. data/lib/mesa_test.rb +433 -1162
  4. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 258ab45be43e85b9d9bf5bb5ee31014f845ce52a760abc5d36d52efefec783fc
4
- data.tar.gz: 179db21ba9f4da610bc0491e089eb8de5a8eb18d003682c7432579cdf80c4363
3
+ metadata.gz: cdee517026a8d0cca40ba51a9ad5418a5d5ac0e52977dcca9fdd9fcb32ead0b2
4
+ data.tar.gz: 7913ccaed137662943c1aa6ff06853c8641674c9fb822d5ee7391a2a12042ccd
5
5
  SHA512:
6
- metadata.gz: faeacd323506e78ec1788191664aa411b18d844e2ee2e7b1ed7ad6e392415d6e8aa2aa73a9e124ca5e18dde8ec8536eb07b15c49a0bfeda3c6750b202f9604cc
7
- data.tar.gz: e6658640ae43198ed869d1b991f185b030190ba1d42609e9ebc721b22bfafdda6dd861c4956b20ab64e84341577d38f72927dd25e73a64bc47cb265e9495ad11
6
+ metadata.gz: 6ffe69d78fb35653875ef3232e31c3f1cad46342281df3825a81ff364d113049658681140afadabfb7db2dcb85ea4a4046bc79117632b35fbc37f6b2dfc19251
7
+ data.tar.gz: e130047bbd95f236aec698240e0c9633d27185daf1c8cd4cdb8448773a675765187192386b81f91a7095ca6a71cbbe2ac3a30b6a3ff3669a3ab4b0efbfae5a46
@@ -2,9 +2,10 @@
2
2
 
3
3
  # if true, submit cases to localhost:3000 and load local mesa_test library
4
4
  # rather than system version
5
- DEVELOPMENT_MODE = false
5
+ MODE = :production
6
6
 
7
- if DEVELOPMENT_MODE
7
+ case MODE
8
+ when :staging, :development
8
9
  require_relative '../lib/mesa_test'
9
10
  else
10
11
  require 'mesa_test'
@@ -15,448 +16,302 @@ require 'yaml'
15
16
 
16
17
  class MesaTest < Thor
17
18
  DEVELOPMENT_URI = 'http://localhost:3000'.freeze
19
+ STAGING_URI = 'https://beta-testhub.herokuapp.com'.freeze
18
20
 
19
- desc 'setup [CONFIG_FILE]', 'Setup MesaTestHub config file.'
21
+ desc 'test [TEST CASE]', 'run and submit a test case or commit'
20
22
  long_desc <<-LONGDESC
21
- If optional CONFIG_FILE is provided, search for that file and load it
22
- to provide default values for configuration. If not provided, the default
23
- file, ~/.mesa_test.yml, is used. The resulting config file is saved to
24
- the same location it was read from.
23
+ If you specify an optional test case, only that test case
24
+ will be tested. Otherwise all test cases in your work directory (set up in
25
+ your .mesa_test.yml file). TEST_CASE can also be an integer corresponding
26
+ to the position it has in do1_test_source (or a concatenated version of
27
+ that file if no module is specified). Modules are searched/concatenated in
28
+ this order:
29
+
30
+ #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(', ')}
25
31
  LONGDESC
26
- def setup(config_file = File.join(ENV['HOME'], '.mesa_test.yml'))
27
- MesaTestSubmitter.new_from_config(config_file: config_file,
28
- force_setup: true)
29
- end
30
-
31
- desc 'test_one MESA_DIR TEST_CASE', 'run, check, and submit one test case'
32
- long_desc <<-LONGDESC
33
- Run and check TEST_CASE, which resides in MESA_DIR/star/test_suite. Then
34
- report results to MesaTestHub. TEST_CASE can also be an integer corresponding
35
- to the line number of the test name in its do1_test_source file (or a
36
- concatenated version of that file if no module is specified). Modules are
37
- searched/concatenated in this order:
38
32
 
39
- #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(', ')}
40
- LONGDESC
41
- option :force, desc: 'When submitting, assume submission data in ' +
42
- '~/.mesa_test.yml are correct rather than checking ' +
43
- 'with user.', type: :boolean, default: false,
44
- aliases: '-f'
33
+ option :force, desc: 'When submitting, assume submission data in ' \
34
+ '~/.mesa_test.yml are correct rather than checking ' \
35
+ 'with user.',
36
+ type: :boolean, default: true, aliases: '-f'
45
37
  option :submit, desc: 'Submit results (if any) to MesaTestHub.',
46
38
  type: :boolean, default: true
47
- option :diff, type: :boolean, default: false, desc: 'Assume checksums are ' +
48
- 'up to date and perform diff', aliases: '-d'
49
- option :svn, desc: 'Use svn to gather log/version data. Safe to use when ' +
50
- 'also using --no-submit; else may give bad version numbers.',
51
- type: :boolean, default: true
52
- option :set_sdk, desc: 'Override user- and test-generated data to deterine' +
53
- ' if the SDK is used and instead use value of --using_sdk.',
54
- type: :boolean, default: false
55
- option :using_sdk, desc: 'Assume we are using the SDK and automatically ' +
56
- 'determine SDK version. Ignored unless using --set-sdk).',
57
- type: :boolean, default: true
58
39
  option :module, desc: 'Which module to test and/or submit, if applicable.',
59
- type: :string, default: 'all', aliases: '-m'
60
- option :log, type: :boolean, default: true, desc: 'Save yml file of test ' \
61
- 'results in test case directory.'
62
- option :auto_diff, desc: 'Automatically determine if diffs should be run '\
63
- 'from svn log entry. Overrides --diff or --no-diff.',
64
- type: :boolean, default: false
65
- def test_one(mesa_dir, test_case_name)
66
- s = create_and_check_submitter(force: options[:force]) if options[:submit]
67
- m = create_and_check_mesa(mesa_dir: mesa_dir, diff: options[:diff],
68
- mod: options[:module].downcase.to_sym,
69
- use_svn: options[:svn], using_sdk: using_sdk?(s),
70
- auto_diff: options[:auto_diff])
71
- t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
72
- mod: options[:module].downcase.to_sym)
73
-
74
- # clean and run test
75
- t.clean
76
- t.do_one
77
-
78
- # log results
79
- t.log_results if options[:log]
80
-
81
- # bail out if not submitting
82
- return unless options[:submit]
83
-
84
- # submit results
85
- print 'Submitting results to ' + s.base_uri + '... '
86
- s.submit(t)
87
- puts "Done.\n"
88
- end
40
+ type: :string, default: 'all', aliases: '-m'
41
+ option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
42
+ type: :string
89
43
 
90
- desc 'test_revision MESA_DIR', 'test and submit all tests as a packaged version'
91
- long_desc <<-LONGDESC
92
- Run and check all test cases residing in MESA_DIR/star/test_suite. Then
93
- report results to MesaTestHub. Specifically, runs and checks all tests
94
- detailed in MESA_DIR/star/test_suite/do1_test_source. Also submit version
95
- information with test instances. Submits all test instances and version data
96
- in a single request rather than case-by-case in `test_all`.
97
- LONGDESC
44
+ def test(test_case_name = nil)
45
+ s = if options[:submit]
46
+ create_and_check_submitter(force: options[:force])
47
+ else
48
+ create_submitter(force: options[:force])
49
+ end
50
+ m = create_and_check_mesa(
51
+ mesa_dir: work_dir(options[:mesadir], s.mesa_work),
52
+ mirror_dir: s.mesa_mirror,
53
+ mod: options[:module].downcase.to_sym,
54
+ github_protocol: s.github_protocol
55
+ )
56
+ if test_case_name
57
+ # only testing one test case
58
+ t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
59
+ mod: options[:module].downcase.to_sym)
60
+
61
+ # run test
62
+ t.do_one
63
+
64
+ # bail out if not submitting
65
+ return unless options[:submit]
66
+
67
+ # submit results
68
+ shell.say 'Submitting results to ' + s.base_uri + '... ', :blue
69
+ s.submit_instance(m, t)
70
+ shell.say "Done.\n", :green
71
+ else
72
+ # run all tests
73
+ m.each_test_run(mod: options[:module].downcase.to_sym)
98
74
 
99
- option :force, desc: 'When submitting, assume submission data in ' +
100
- '~/.mesa_test.yml are correct rather than checking ' +
101
- 'with user.', type: :boolean, default: false,
102
- aliases: '-f'
103
- option :submit, desc: 'Submit results (if any) to MesaTestHub.',
104
- type: :boolean, default: true
105
- option :diff, type: :boolean, default: false, desc: 'Assume checksums are ' +
106
- 'up to date and perform diff', aliases: '-d'
107
- option :svn, desc: 'Use svn to gather log/version data. Safe to use when ' +
108
- 'also using --no-submit; else may give bad version numbers.',
109
- type: :boolean, default: true
110
- option :set_sdk, desc: 'Override user- and test-generated data to deterine' +
111
- ' if the SDK is used and instead use value of --using_sdk.',
112
- type: :boolean, default: false
113
- option :using_sdk, desc: 'Assume we are using the SDK and automatically ' +
114
- 'determine SDK version. Ignored unless using --set-sdk).',
115
- type: :boolean, default: true
116
- option :module, desc: 'Which module to test and/or submit, if applicable.',
117
- type: :string, default: 'all', aliases: '-m'
118
- option :log, type: :boolean, default: true, desc: 'Save yml file of test ' \
119
- 'results in test case directory.'
120
- option :auto_diff, desc: 'Automatically determine if diffs should be run '\
121
- 'from svn log entry. Overrides --diff or --no-diff.',
122
- type: :boolean, default: false
123
- def test_revision(mesa_dir)
124
- s = create_and_check_submitter(force: options[:force]) if options[:submit]
125
- m = create_and_check_mesa(mesa_dir: mesa_dir, diff: options[:diff],
126
- mod: options[:module].downcase.to_sym,
127
- use_svn: options[:svn],
128
- using_sdk: using_sdk?(s),
129
- auto_diff: options[:auto_diff])
130
-
131
- # run all tests
132
- m.each_test_run_and_diff(log_results: options[:log],
133
- mod: options[:module].downcase.to_sym)
134
-
135
- # submit all tests
136
- s.submit_revision(m) if options[:submit]
137
- end
75
+ # bail out if not submitting
76
+ return unless options[:submit]
138
77
 
78
+ shell.say 'Submitting results to ' + s.base_uri + '... ', :blue
79
+ s.submit_commit(m)
80
+ shell.say "Done.\n", :green
81
+ end
82
+ end
139
83
 
140
- desc 'submit_one MESA_DIR TEST_CASE', 'submit one completed test case'
84
+ desc 'submit [TEST CASE]', 'submit a test case or commit'
141
85
  long_desc <<-LONGDESC
142
- Load complete test case data from existing YAML file and submit to MESA.
143
- TEST_CASE can also be an integer corresponding to the line number of the test
144
- name in its do1_test_source file (or a concatenated version of that file if
145
- no module is specified). Modules are searched/concatenated in this order:
146
-
147
- #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(', ')}
86
+ All tests are assumed to be in the default mesa directory (set as mesa_work
87
+ in .mesa_test.yml. If you specify an optional test case, only that test case
88
+ will be submitted. TEST_CASE can also be an integer corresponding to the
89
+ position it has in do1_test_source (or a concatenated version of that file
90
+ if no module is specified). Modules are searched/concatenated in this
91
+ order:
92
+
93
+ #{MesaTestCase.modules.map { |mod| ' ' + mod.to_s }.join(', ')}
148
94
  LONGDESC
149
95
 
150
- option :force, desc: 'When submitting, assume submission data in ' +
151
- '~/.mesa_test.yml are correct rather than checking ' +
152
- 'with user.', type: :boolean, default: false,
153
- aliases: '-f'
154
- option :svn, desc: 'Use svn to gather log/version data. NECESSARY TO GET ' +
155
- 'ACCURATE VERSION NUMBER.', type: :boolean, default: true
156
- option :set_sdk, desc: 'Override user- and test-generated data to deterine' +
157
- ' if the SDK is used and instead use value of --using_sdk.',
158
- type: :boolean, default: false
159
- option :using_sdk, desc: 'Assume we are using the SDK and automatically ' +
160
- 'determine SDK version. Ignored unless using --set-sdk).',
161
- type: :boolean, default: true
96
+ option :force, desc: 'When submitting, assume submission data in ' \
97
+ '~/.mesa_test.yml are correct rather than checking ' \
98
+ 'with user.',
99
+ type: :boolean, default: true, aliases: '-f'
162
100
  option :module, desc: 'Which module to test and/or submit, if applicable.',
163
101
  type: :string, default: 'all', aliases: '-m'
164
- def submit_one(mesa_dir, test_case_name)
102
+ option :empty, desc: 'Whether any test cases will be submitted. Useful for '\
103
+ 'indicating compilation status independently of ' \
104
+ 'single test submissions.',
105
+ type: :boolean, default: false, aliases: '-e'
106
+ option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
107
+ type: :string
108
+
109
+ def submit(test_case_name = nil)
165
110
  s = create_and_check_submitter(force: options[:force])
166
- m = create_and_check_mesa(mesa_dir: mesa_dir,
167
- mod: options[:module].downcase.to_sym,
168
- using_sdk: using_sdk?(s), use_svn: options[:svn])
169
- t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
170
- mod: options[:module].downcase.to_sym)
171
- # load test results
172
- t.load_results
173
-
174
- # submit results
175
- print 'Submitting results to ' + s.base_uri + '... '
176
- s.submit(t)
177
- puts "Done.\n"
111
+ m = create_and_check_mesa(
112
+ mesa_dir: work_dir(options[:mesadir], s.mesa_work),
113
+ mirror_dir: s.mesa_mirror,
114
+ mod: options[:module].downcase.to_sym,
115
+ github_protocol: s.github_protocol
116
+ )
117
+ empty = options[:empty]
118
+
119
+ # default value for now; might change to false if we have a bad
120
+ # installation or if a test case is specified
121
+
122
+ if test_case_name
123
+ # just submitting one test case.
124
+ # this is not an empty submission since there is one test case (the
125
+ # +empty+ option is ignored in this case)
126
+
127
+ t = create_and_check_test_case(mesa: m, test_case_name: test_case_name,
128
+ mod: options[:module].downcase.to_sym)
129
+ # submit results
130
+ shell.say 'Submitting results to ' + s.base_uri + '... ', :blue
131
+ s.submit_instance(m, t)
132
+ shell.say "Done.\n", :green
133
+ else
134
+ # submitting compilation information and either all tests (entire) or
135
+ # no tests (empty)
136
+ begin
137
+ m.check_installation
138
+ rescue MesaDirError
139
+ shell.say %q{This MESA installation doesn't seem to be compiled } \
140
+ 'properly. Submitting a compilation failure to MESATestHub.', :red
141
+ empty = true
142
+ ensure
143
+ # submit all tests
144
+ s.submit_commit(m, empty: empty)
145
+ end
146
+ end
178
147
  end
179
148
 
180
- desc 'submit_revision MESA_DIR', 'submit version with pre-run test cases'
149
+ desc 'checkout SHA', 'checkout a commit'
181
150
  long_desc <<-LONGDESC
182
- Load results for all test cases residing in MESA_DIR/star/test_suite. Then
183
- submit results to MesaTestHub. Specifically, loads and submits all tests
184
- detailed in MESA_DIR/star/test_suite/do1_test_source along with version data
185
- (number, author, and commit message). Unlike submit_all, this submits all
186
- test cases AND version info in a single request rather than just the cases
187
- in series.
151
+ Checks out a particular commit to default mesa directory (mesa_work in
152
+ .mesa_test.yml). Uses git worktree magic to avoid re-downloading all of
153
+ mesa history if a mirror repo is already set up. Does not affect the
154
+ user's MESA_DIR or other environment variables.
188
155
  LONGDESC
189
- option :force, desc: 'When submitting, assume submission data in ' +
190
- '~/.mesa_test.yml are correct rather than checking ' +
191
- 'with user.', type: :boolean, default: false,
192
- aliases: '-f'
193
- option :module, desc: 'Which module to test and/or submit, if applicable.',
194
- type: :string, default: 'all', aliases: '-m'
195
- option :svn, desc: 'Use svn to gather log/version data. NECESSARY TO GET ' +
196
- 'ACCURATE VERSION NUMBER.', type: :boolean, default: true
197
- option :set_sdk, desc: 'Override user- and test-generated data to deterine' +
198
- ' if the SDK is used and instead use value of --using_sdk.',
199
- type: :boolean, default: false
200
- option :using_sdk, desc: 'Assume we are using the SDK and automatically ' +
201
- 'determine SDK version. Ignored unless using --set-sdk).',
202
- type: :boolean, default: true
203
- def submit_revision(mesa_dir)
204
- s = create_and_check_submitter(force: options[:force])
205
- m = create_and_check_mesa(mesa_dir: mesa_dir,
206
- mod: options[:module].downcase.to_sym,
207
- use_svn: options[:svn], using_sdk: using_sdk?(s))
208
- begin
209
- m.check_installation
210
- rescue MesaDirError
211
- shell.say %q{This MESA installation doesn't seem to be compiled } \
212
- 'properly. Submitting a compilation failure to MESATestHub.', :red
213
- else
214
- # load all test data
215
- m.each_test_load_results(mod: options[:module].downcase.to_sym)
216
- ensure
217
- # submit all tests
218
- s.submit_revision(m)
219
- end
220
- end
221
156
 
157
+ option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
158
+ type: :string
159
+
160
+ def checkout(sha)
161
+ # assuming config wizard has already been set (perhaps a little reckless)
162
+ # so that we can get at the work directory and mirror directory
163
+ s = create_submitter(force: true)
164
+ Mesa.checkout(sha: sha,
165
+ work_dir: work_dir(options[:mesadir], s.mesa_work),
166
+ mirror_dir: s.mesa_mirror,
167
+ github_protocol: s.github_protocol)
168
+ end
222
169
 
223
- desc 'install VERSION_NUMBER MESA_DIR', 'download and install mesa release '\
224
- 'VERSION_NUMBER to directory MESA_DIR'
170
+ desc 'install [SHA]', 'checkout and install a commit'
225
171
  long_desc <<-LONGDESC
226
- Calls to svn to install mesa release VERSION_NUMBER into the directory
227
- MESA_DIR. Basically just an svn checkout followed by going into the directory
228
- and running ./clean and ./install. SDK or compilers must be set up prior.
229
- Does not affect the user's MESA_DIR or other environment variables.
172
+ Optionally checks out a particular commit to default mesa directory
173
+ (mesa_work in .mesa_test.yml). Then runs installation script in the work
174
+ directory. Equivalent to an [optional] git checkout followed by going
175
+ into the directory and running ./clean and ./install, but there is some git
176
+ worktree magic on the backend to improve efficiency. SDK or compilers must be
177
+ set up prior. Does not affect the user's MESA_DIR or other environment
178
+ variables outside of execution.
179
+
180
+ If no sha is provided, defaults to master (if checkout is occuring). SHA is
181
+ ignored if using option --no-checkout
230
182
  LONGDESC
231
- def install(version, mesa_dir)
232
- m = Mesa.download(version_number: version, new_mesa_dir: mesa_dir)
183
+
184
+ option :checkout, desc: 'Whether a checkout needs to happen. Use '\
185
+ '--no-checkout if you already ran checkout.',
186
+ type: :boolean, default: true, aliases: '-c'
187
+ option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
188
+ type: :string
189
+
190
+ def install(sha = 'master')
191
+ # assuming config wizard has already been set (perhaps a little reckless)
192
+ # so that we can get at the work directory and mirror directory
193
+ s = create_submitter(force: true)
194
+ m = if options[:checkout]
195
+ Mesa.checkout(
196
+ sha: sha,
197
+ work_dir: work_dir(options[:mesadir], s.mesa_work),
198
+ mirror_dir: s.mesa_mirror,
199
+ github_protocol: s.github_protocol
200
+ )
201
+ else
202
+ create_and_check_mesa(
203
+ mesa_dir: work_dir(options[:mesadir], s.mesa_work),
204
+ mirror_dir: s.mesa_mirror,
205
+ mod: :all,
206
+ github_protocol: s.github_protocol
207
+ )
208
+ end
233
209
  m.clean
234
210
  m.install
235
211
  end
236
212
 
237
- desc 'install_and_test_revision VERSION_NUMBER MESA_DIR', 'download and '\
238
- 'install mesa release VERSION_NUMBER to directory MESA_DIR, run all tests,'\
239
- 'and submit version and test data in single request.'
213
+ desc 'install_and_test [SHA]', 'Install, test, and submit an entire commit.'
240
214
  long_desc <<-LONGDESC
241
- Calls to svn to install mesa release VERSION_NUMBER into the directory
242
- MESA_DIR. Basically just an svn checkout followed by going into the directory
243
- and running ./clean and ./install. SDK or compilers must be set up prior.
244
- Once installation is complete, run the test suite, and report results
245
- (version and all test data) to MesaTestHub in a single request (whereas
246
- install_and_test_all only submits test data and does so in a serial fashion).
215
+ Optionally checks out a particular commit (specified by SHA, which default to
216
+ HEAD if not provided) to a mesa directory (mesa_work in .mesa_test.yml,
217
+ unless a custom location is provided by --workdir=MYDIR). Then go into the
218
+ directory and run ./clean and ./install. SDK or compilers must be set up
219
+ prior. Once installation is complete, run the test suite, and report results
220
+ (commit and all test data) to MesaTestHub in a single request.
247
221
  Does not affect the user's MESA_DIR or other environment variables. This is
248
222
  basically a shortcut for running
249
223
 
250
- `mesa_test install SOME_VERSION SOME_DIR`
224
+ `mesa_test install SOME_SHA`
251
225
 
252
226
  followed by
253
227
 
254
- `mesa_test test_revision SOME_DIR`
255
-
256
- If VERSION_NUMBER is 'non-paxton' or 'non_paxton', then the most recent
257
- commit by anyone other than Bill Paxton ('bill_paxton') is tested and the
258
- --diff flag is ignored and set to false. Note that using 'HEAD' for version
259
- number will automatically select the most recent release, regardless of the
260
- author.
228
+ `mesa_test test`
261
229
  LONGDESC
262
230
 
263
- option :force, desc: 'When submitting, assume submission data in ' +
264
- '~/.mesa_test.yml are correct rather than checking ' +
265
- 'with user.', type: :boolean, default: false,
266
- aliases: '-f'
231
+ option :checkout, desc: 'Whether a checkout needs to happen. Use '\
232
+ '--no-checkout if you already ran checkout.',
233
+ type: :boolean, default: true, aliases: '-c'
234
+ option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
235
+ type: :string
236
+ option :force, desc: 'When submitting, assume submission data in ' \
237
+ '~/.mesa_test.yml are correct rather than checking ' \
238
+ 'with user.',
239
+ type: :boolean, default: true, aliases: '-f'
267
240
  option :submit, desc: 'Submit results (if any) to MesaTestHub.',
268
241
  type: :boolean, default: true
269
- option :diff, type: :boolean, default: false, desc: 'Assume checksums are ' +
270
- 'up to date and perform diff', aliases: '-d'
271
- option :svn, desc: 'Use svn to gather log/version data. Safe to use when ' +
272
- 'also using --no-submit; else may give bad version numbers.',
273
- type: :boolean, default: true
274
- option :set_sdk, desc: 'Override user- and test-generated data to deterine' +
275
- ' if the SDK is used and instead use value of --using_sdk.',
276
- type: :boolean, default: false
277
- option :using_sdk, desc: 'Assume we are using the SDK and automatically ' +
278
- 'determine SDK version. Ignored unless using --set-sdk).',
279
- type: :boolean, default: true
280
242
  option :module, desc: 'Which module to test and/or submit, if applicable.',
281
243
  type: :string, default: 'all', aliases: '-m'
282
244
  option :destroy, type: :boolean, desc: 'Delete mesa installation upon ' \
283
245
  'submission of complete results.', default: false
284
- option :log, type: :boolean, default: true, desc: 'Save yml file of test ' \
285
- 'results in test case directory.'
286
- option :auto_diff, desc: 'Automatically determine if diffs should be run '\
287
- 'from svn log entry. Overrides --diff or --no-diff.',
288
- type: :boolean, default: false
289
- def install_and_test_revision(version, mesa_dir)
290
- s = nil # to make sure using_sdk? below will work properly
291
- s = create_and_check_submitter(force: options[:force]) if options[:submit]
292
- mesa_version, diff = filter_version_and_diff(version, s)
293
- if mesa_version.nil?
294
- puts 'No commits by anyone other than Bill Paxton since '\
295
- "r#{s.last_tested}. Exiting."
296
- return
297
- end
298
- m = Mesa.download(version_number: mesa_version, new_mesa_dir: mesa_dir,
299
- use_svn: options[:svn], using_sdk: using_sdk?(s))
246
+
247
+ def install_and_test(sha)
248
+ s = if options[:submit]
249
+ create_and_check_submitter(force: options[:force])
250
+ else
251
+ # not submitting? don't check config file (risky!) still need
252
+ # submitter to get work and mirror directories, though
253
+ create_submitter(force: true)
254
+ end
255
+
256
+ m = if options[:checkout]
257
+ Mesa.checkout(
258
+ sha: sha,
259
+ work_dir: work_dir(options[:mesadir], s.mesa_work),
260
+ mirror_dir: s.mesa_mirror,
261
+ github_protocol: s.github_protocol
262
+ )
263
+ else
264
+ create_and_check_mesa(
265
+ mesa_dir: work_dir(options[:mesadir], s.mesa_work),
266
+ mirror_dir: s.mesa_mirror,
267
+ mod: options[:module].to_sym,
268
+ github_protocol: s.github_protocol
269
+ )
270
+ end
271
+
300
272
  begin
301
273
  m.clean
302
274
  m.install
303
275
  rescue MesaDirError
304
- shell.say "\nFailed in compiling MESA r-#{m.version_number}.", :red
276
+ shell.say "\nFailed in compiling MESA.", :red
305
277
  else
306
278
  check_mesa(m)
307
- update_mesa(mesa: m, diff: diff, mod: options[:module].downcase.to_sym,
308
- auto_diff: options[:auto_diff])
279
+ update_mesa(mesa: m, mod: options[:module].downcase.to_sym)
309
280
 
310
281
  # run all tests. Don't be fooled, whether or not a diff happens is set
311
282
  # by the diff attribute of the mesa object, set above.
312
- m.each_test_run_and_diff(mod: options[:module].downcase.to_sym,
313
- log_results: options[:log])
283
+ m.each_test_run(mod: options[:module].downcase.to_sym)
314
284
  ensure
315
- # submit all version and test data
285
+ # submit all commit and test data
316
286
  successfully_submitted = false
317
- successfully_submitted = s.submit_revision(m) if options[:submit]
287
+ successfully_submitted = s.submit_commit(m) if options[:submit]
318
288
 
319
289
  # if requested, installation and submission are successful, destroy the
320
290
  # directory
321
- m.destroy if successfully_submitted && options[:destroy] && m.installed?
322
- end
323
- end
324
-
325
- desc 'search "SEARCH_QUERY" [EMAIL] [PASSWORD]', 'retrieve JSON array of ' \
326
- 'test instances matching SEARCH_QUERY'
327
- long_desc <<-LONGDESC
328
- Sends a JSON request to the Mesa TestHub API. All of your SEARCH_QUERY should
329
- be in quotes. For details on how to form a proper search query, visit
330
- testhub.mesastar.org/test_instances/search, where you can also test out
331
- the search capability in a browser interface. Result is a single line of
332
- JSON printed to STDOUT.
333
-
334
- To prevent abuse, the API requires authentication with email and password.
335
- By default, these are pulled from ~/.mesa_test.yml, but you may override
336
- these with optional arguments.
337
- LONGDESC
338
-
339
- def search(search_query, email=nil, password=nil)
340
- # get/confirm email and password
341
- yml_file = File.join(ENV['HOME'], '.mesa_test.yml')
342
- email, password = get_email_and_password(yml_file, email, password)
343
- # prep API request
344
- base_uri = if DEVELOPMENT_MODE
345
- 'http://localhost:3000'
346
- else
347
- 'https://testhub.mesastar.org'
348
- end
349
- uri_search = URI.parse(base_uri + '/test_instances/search.json')
350
- params = {
351
- email: email,
352
- password: password,
353
- query_text: search_query
354
- }
355
- uri_search.query = URI.encode_www_form(params)
356
-
357
- # perform search query
358
- search_response = nil
359
- Net::HTTP.start(uri_search.host, uri_search.port, use_ssl: base_uri.include?('https')) do |https|
360
- request = Net::HTTP::Get.new(
361
- uri_search,
362
- initheader = { 'Content-Type' => 'application/json' }
363
- )
364
- search_response = JSON.parse(https.request(request).body)
365
- end
366
-
367
- # parse results
368
- if search_response['error']
369
- STDERR.puts "Error: #{search_response['error']}"
370
- else
371
- # break into sections
372
- results = search_response["results"]
373
- failures = search_response["failures"]
374
-
375
- unless failures.empty?
376
- STDERR.puts "The folloiwng options were invalid and ignored:"
377
- failures.each { |failure| STDERR.puts "- #{failure}"}
378
- end
379
-
380
- shell.say results.to_json
291
+ m.remove if successfully_submitted && options[:destroy] && m.installed?
381
292
  end
382
293
  end
383
294
 
384
- desc 'count "SEARCH_QUERY" [EMAIL] [PASSWORD]', 'count number of test ' \
385
- 'instances matching SEARCH_QUERY'
295
+ desc 'setup [CONFIG_FILE]', 'Setup MesaTestHub config file.'
386
296
  long_desc <<-LONGDESC
387
- Sends a JSON request to the Mesa TestHub API. All of your SEARCH_QUERY should
388
- be in quotes. For details on how to form a proper search query, visit
389
- testhub.mesastar.org/test_instances/search, where you can also test out
390
- the search capability in a browser interface. Result is a single integer.
391
-
392
- To prevent abuse, the API requires authentication with email and password.
393
- By default, these are pulled from ~/.mesa_test.yml, but you may override
394
- these with optional arguments.
297
+ If optional CONFIG_FILE is provided, search for that file and load it
298
+ to provide default values for configuration. If not provided, the default
299
+ file, ~/.mesa_test.yml, is used. The resulting config file is saved to
300
+ the same location it was read from.
395
301
  LONGDESC
396
-
397
- def count(search_query, email=nil, password=nil)
398
- # get/confirm email and password
399
- yml_file = File.join(ENV['HOME'], '.mesa_test.yml')
400
- email, password = get_email_and_password(yml_file, email, password)
401
- # prep API request
402
- base_uri = if DEVELOPMENT_MODE
403
- 'http://localhost:3000'
404
- else
405
- 'https://testhub.mesastar.org'
406
- end
407
- uri_count = URI.parse(base_uri + '/test_instances/search_count.json')
408
- params = {
409
- email: email,
410
- password: password,
411
- query_text: search_query
412
- }
413
- uri_count.query = URI.encode_www_form(params)
414
-
415
- # perform count query
416
- count_response = nil
417
- Net::HTTP.start(uri_count.host, uri_count.port, use_ssl: base_uri.include?('https')) do |https|
418
- request = Net::HTTP::Get.new(
419
- uri_count,
420
- initheader = { 'Content-Type' => 'application/json' }
421
- )
422
- count_response = JSON.parse(https.request(request).body)
423
- end
424
-
425
- # parse results
426
- if count_response['error']
427
- STDERR.puts "Error: #{count_response['error']}"
428
- else
429
- # break into sections
430
- count = count_response["count"]
431
- failures = count_response["failures"]
432
-
433
- unless failures.empty?
434
- STDERR.puts "The folloiwng options were invalid and ignored:"
435
- failures.each { |failure| STDERR.puts "- #{failure}"}
436
- end
437
-
438
- shell.say count, :blue
439
- end
302
+ def setup(config_file = File.join(ENV['HOME'], '.mesa_test', 'config.yml'))
303
+ MesaTestSubmitter.new_from_config(config_file: config_file,
304
+ force_setup: true)
440
305
  end
441
306
 
442
307
  private
443
308
 
444
- def get_email_and_password(file, email=nil, password=nil)
445
- if email && password
446
- return [email, password]
309
+ def work_dir(given, default)
310
+ if given
311
+ File.expand_path('', given)
312
+ else
313
+ default
447
314
  end
448
- raise("File does not exist: #{file}.") unless File.exist?(file)
449
- contents = File.read(file)
450
- email_matcher = /^email\:\s*(?<email>.+@.+\..+)$/
451
- password_matcher = /^password\:\s*(?<password>.+)$/
452
-
453
- m = email_matcher.match(contents)
454
- email ||= m[:email] if m
455
-
456
- m = password_matcher.match(contents)
457
- password ||= m[:password] if m
458
-
459
- return [email, password]
460
315
  end
461
316
 
462
317
  def check_user_and_computer(submitter)
@@ -469,46 +324,52 @@ class MesaTest < Thor
469
324
  end
470
325
  end
471
326
 
472
- def create_and_check_submitter(force: false)
473
- s = if DEVELOPMENT_MODE
327
+ def create_submitter(force: true)
328
+ s = case MODE
329
+ when :development
474
330
  MesaTestSubmitter.new_from_config(base_uri: DEVELOPMENT_URI)
331
+ when :staging
332
+ MesaTestSubmitter.new_from_config(base_uri: STAGING_URI)
475
333
  else
476
334
  MesaTestSubmitter.new_from_config
477
335
  end
478
336
  unless force
479
337
  s.setup unless s.confirm_computer_data
480
338
  end
339
+ s
340
+ end
341
+
342
+ def create_and_check_submitter(force: true)
343
+ s = create_submitter(force: force)
481
344
  check_user_and_computer s
482
345
  s
483
346
  end
484
347
 
485
- def create_and_check_mesa(mesa_dir:, use_svn: true, diff: true, mod: :all,
486
- using_sdk: true, auto_diff: false)
487
- m = Mesa.new(mesa_dir: mesa_dir, use_svn: use_svn, using_sdk: using_sdk)
348
+ def create_and_check_mesa(mesa_dir: '', mirror_dir: '', mod: :all,
349
+ github_protocol: nil)
350
+ m = Mesa.new(mesa_dir: mesa_dir, mirror_dir: mirror_dir,
351
+ github_protocol: github_protocol)
488
352
  check_mesa(m)
489
- update_mesa(mesa: m, diff: diff, mod: mod, auto_diff: auto_diff)
490
- m
353
+ update_mesa(mesa: m, mod: mod)
491
354
  end
492
355
 
493
356
  def check_mesa(mesa)
494
- unless mesa.downloaded?
495
- raise MesaDirError, "Invalid MESA_DIR: #{mesa_dir}. Please download " \
496
- 'and install a valid MESA version or provide the path to one.'
497
- end
357
+ return if mesa.downloaded?
358
+
359
+ raise MesaDirError, "Invalid MESA_DIR: #{mesa.mesa_dir}. Please "\
360
+ 'download and install a valid MESA version or provide the path to one.'
498
361
  end
499
362
 
500
- def update_mesa(mesa:, diff: true, mod: :all, auto_diff: false)
363
+ def update_mesa(mesa:, mod: :all)
501
364
  mesa.load_test_source_data(mod: mod)
502
- # choose whether to update checksums.
503
- mesa.update_checksums = !diff unless diff.nil?
504
- # automatically figure out diff situation. Overrides choice from diff!
505
- mesa.determine_diff if auto_diff
365
+ mesa
506
366
  end
507
367
 
508
368
  def create_and_check_test_case(mesa:, test_case_name:, mod: :all)
509
369
  t = mesa.find_test_case(test_case_name: test_case_name, mod: mod)
510
370
  # return test case if it was found
511
371
  return t unless t.nil?
372
+
512
373
  # test case was not found. Throw an error.
513
374
  msg = "No such test case, #{test_case_name} found in any of "
514
375
  # this should care about the value in `mod`. Current behavior is only
@@ -519,44 +380,6 @@ class MesaTest < Thor
519
380
  msg << '.'
520
381
  raise TestCaseDirError, msg
521
382
  end
522
-
523
- def filter_version_and_diff(version, submitter)
524
- if %w[non-paxton non_paxton].include?(version.to_s.downcase)
525
- [Mesa.last_non_paxton_revision(submitter.last_tested), false]
526
- else
527
- [version, options[:diff]]
528
- end
529
- end
530
-
531
- # determine whether or not we can assume the test should be / was run with
532
- # the SDK. This results should only be relevant if a test is GOING TO BE RUN.
533
- # If it has already been run, then the compiler and compiler version have
534
- # already been set (or the opportunity was lost, either way this won't help.)
535
- #
536
- # This gets used in a lot of places where it probably isn't necessary, just
537
- # to prevent problems later on if things change, as it does no harm when it
538
- # doesn't help.
539
- #
540
- # The only parameter is a submitter, if there is one to lean on. If there
541
- # isn't, it's no problem.
542
- def using_sdk?(s = nil)
543
- # did user specify so? Trust them
544
- if options[:set_sdk]
545
- options[:using_sdk]
546
- # are we submitting? scrape compiler info from that
547
- elsif s
548
- s.compiler == 'SDK'
549
- # we don't have a submitter... need to read config file (same thing
550
- # submitter is doing)
551
- elsif File.exist?(File.join(ENV['HOME'], '.mesa_test.yml'))
552
- data = YAML.load(File.read(File.join(ENV['HOME'], '.mesa_test.yml')))
553
- data['compiler'] == 'SDK'
554
- # nothing works. Don't tell mesa that we are using SDK (we could still be
555
- # using it, but it's up to a future submitter to tell the web site so.)
556
- else
557
- false
558
- end
559
- end
560
383
  end
561
384
 
562
385
  # actually start the CLI