mesa_test 1.0.0 → 1.0.5

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 +16 -9
  3. data/lib/mesa_test.rb +46 -25
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdee517026a8d0cca40ba51a9ad5418a5d5ac0e52977dcca9fdd9fcb32ead0b2
4
- data.tar.gz: 7913ccaed137662943c1aa6ff06853c8641674c9fb822d5ee7391a2a12042ccd
3
+ metadata.gz: a826fba7ff75a9e70bc48f382a695dd97c901d4fb592b62c12efc71815228166
4
+ data.tar.gz: bcfcc756505119163a4a9fd26a33a6e7ec1f93a866b0fcda0fbe1e5d4d0b73cc
5
5
  SHA512:
6
- metadata.gz: 6ffe69d78fb35653875ef3232e31c3f1cad46342281df3825a81ff364d113049658681140afadabfb7db2dcb85ea4a4046bc79117632b35fbc37f6b2dfc19251
7
- data.tar.gz: e130047bbd95f236aec698240e0c9633d27185daf1c8cd4cdb8448773a675765187192386b81f91a7095ca6a71cbbe2ac3a30b6a3ff3669a3ab4b0efbfae5a46
6
+ metadata.gz: 8f08733e96c142a057741a888b7ff0db782c305e77596bee2bc8b888b42b9874f5905fb22c1a81bb7e2bed6e27afa60cf025107b9dc3805141769eff20e8527f
7
+ data.tar.gz: c58df66933472bef5f6849837272c599bc5480446119a946362e900c0b4e995409cd5b72db6bd56cd6b912c2480a0eb5746c2a12dad0c3ce89a075d24e7170bd
@@ -1,7 +1,9 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- # if true, submit cases to localhost:3000 and load local mesa_test library
4
- # rather than system version
3
+ # if :development, submit cases to localhost:3000 and load local mesa_test library
4
+ # rather than system version and run out of local lib, not installed
5
+ # if :staging, submit to beta version and run out of local lib, not installed
6
+ # anything else: trust rubygems to get lib and submit to real deal testhub
5
7
  MODE = :production
6
8
 
7
9
  case MODE
@@ -67,7 +69,6 @@ class MesaTest < Thor
67
69
  # submit results
68
70
  shell.say 'Submitting results to ' + s.base_uri + '... ', :blue
69
71
  s.submit_instance(m, t)
70
- shell.say "Done.\n", :green
71
72
  else
72
73
  # run all tests
73
74
  m.each_test_run(mod: options[:module].downcase.to_sym)
@@ -77,8 +78,8 @@ class MesaTest < Thor
77
78
 
78
79
  shell.say 'Submitting results to ' + s.base_uri + '... ', :blue
79
80
  s.submit_commit(m)
80
- shell.say "Done.\n", :green
81
81
  end
82
+ shell.say "Done.\n", :green
82
83
  end
83
84
 
84
85
  desc 'submit [TEST CASE]', 'submit a test case or commit'
@@ -146,18 +147,20 @@ class MesaTest < Thor
146
147
  end
147
148
  end
148
149
 
149
- desc 'checkout SHA', 'checkout a commit'
150
+ desc 'checkout [SHA]', 'checkout a commit'
150
151
  long_desc <<-LONGDESC
151
152
  Checks out a particular commit to default mesa directory (mesa_work in
152
153
  .mesa_test.yml). Uses git worktree magic to avoid re-downloading all of
153
154
  mesa history if a mirror repo is already set up. Does not affect the
154
155
  user's MESA_DIR or other environment variables.
156
+
157
+ If no sha is provided, defaults to main (if checkout is occuring).
155
158
  LONGDESC
156
159
 
157
160
  option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
158
161
  type: :string
159
162
 
160
- def checkout(sha)
163
+ def checkout(sha = 'main')
161
164
  # assuming config wizard has already been set (perhaps a little reckless)
162
165
  # so that we can get at the work directory and mirror directory
163
166
  s = create_submitter(force: true)
@@ -177,7 +180,7 @@ class MesaTest < Thor
177
180
  set up prior. Does not affect the user's MESA_DIR or other environment
178
181
  variables outside of execution.
179
182
 
180
- If no sha is provided, defaults to master (if checkout is occuring). SHA is
183
+ If no sha is provided, defaults to main (if checkout is occuring). SHA is
181
184
  ignored if using option --no-checkout
182
185
  LONGDESC
183
186
 
@@ -187,7 +190,7 @@ class MesaTest < Thor
187
190
  option :mesadir, desc: 'Location of mesa dir, if not relying on config data',
188
191
  type: :string
189
192
 
190
- def install(sha = 'master')
193
+ def install(sha = 'main')
191
194
  # assuming config wizard has already been set (perhaps a little reckless)
192
195
  # so that we can get at the work directory and mirror directory
193
196
  s = create_submitter(force: true)
@@ -226,6 +229,10 @@ class MesaTest < Thor
226
229
  followed by
227
230
 
228
231
  `mesa_test test`
232
+
233
+ If no sha is provided, defaults to main (if checkout is occuring). SHA is
234
+ ignored if using option --no-checkout
235
+
229
236
  LONGDESC
230
237
 
231
238
  option :checkout, desc: 'Whether a checkout needs to happen. Use '\
@@ -244,7 +251,7 @@ class MesaTest < Thor
244
251
  option :destroy, type: :boolean, desc: 'Delete mesa installation upon ' \
245
252
  'submission of complete results.', default: false
246
253
 
247
- def install_and_test(sha)
254
+ def install_and_test(sha='main')
248
255
  s = if options[:submit]
249
256
  create_and_check_submitter(force: options[:force])
250
257
  else
@@ -13,7 +13,6 @@ TestCaseDirError = Class.new(StandardError)
13
13
  InvalidDataType = Class.new(StandardError)
14
14
  GitHubError = Class.new(StandardError)
15
15
 
16
- DEFAULT_REVISION = 10_000
17
16
  GITHUB_HTTPS = 'https://github.com/MESAHub/mesa.git'.freeze
18
17
  GITHUB_SSH = 'git@github.com:MESAHub/mesa.git'.freeze
19
18
 
@@ -76,10 +75,12 @@ e-mail and password will be stored in plain text.'
76
75
  "Ubuntu 16.04)? (#{s.platform_version}):", :blue
77
76
  s.platform_version = response unless response.empty?
78
77
 
79
- # Confirm save location
80
- response = shell.ask "This will be saved in #{s.config_file}. Press " \
81
- 'enter to accept or enter a new location:', :blue, path: true
82
- s.config_file = response unless response.empty?
78
+ # we are powerless to do change the location for now, so stop asking
79
+ # about it
80
+ # # Confirm save location
81
+ # response = shell.ask "This will be saved in #{s.config_file}. Press " \
82
+ # 'enter to accept or enter a new location:', :blue, path: true
83
+ # s.config_file = response unless response.empty?
83
84
  end
84
85
 
85
86
  # Confirm data. If not confirmed, restart whole wizard.
@@ -145,7 +146,6 @@ e-mail and password will be stored in plain text.'
145
146
  @config_file = config_file || File.join(ENV['HOME'], '.mesa_test',
146
147
  'config.yml')
147
148
  @base_uri = base_uri
148
- @last_tested = last_tested || DEFAULT_REVISION
149
149
 
150
150
  # set up thor-proof way to get responses from user. Thor hijacks the
151
151
  # gets command, so we have to use its built-in "ask" method, which is
@@ -170,7 +170,7 @@ e-mail and password will be stored in plain text.'
170
170
  puts "MESA Mirror Location #{mesa_mirror}"
171
171
  puts "MESA Work Location #{mesa_work}"
172
172
  puts "Platform #{platform} #{platform_version}"
173
- puts "Config location #{config_file}"
173
+ # puts "Config location #{config_file}"
174
174
  puts '-------------------------------------------------------'
175
175
  puts ''
176
176
  response = shell.ask 'Is this correct? (y/Y = Yes, anything else = No):'
@@ -289,7 +289,7 @@ e-mail and password will be stored in plain text.'
289
289
  https.use_ssl = base_uri.include? 'https'
290
290
 
291
291
  request = Net::HTTP::Post.new(
292
- uri, initheader = { 'Content-Type' => 'application/json' }
292
+ uri, initheader = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
293
293
  )
294
294
  request.body = {
295
295
  email: email,
@@ -302,13 +302,17 @@ e-mail and password will be stored in plain text.'
302
302
  # submit entire commit's worth of test cases, OR submit compilation status
303
303
  # and NO test cases
304
304
  def submit_commit(mesa, empty: false)
305
+ unless mesa.install_attempted?
306
+ raise MesaDirError, 'No testhub.yml file found in installation; '\
307
+ 'must attempt to install before subitting.'
308
+ end
305
309
  uri = URI.parse(base_uri + '/submissions/create.json')
306
310
  https = Net::HTTP.new(uri.hostname, uri.port)
307
311
  https.use_ssl = true if base_uri.include? 'https'
308
312
 
309
313
  request = Net::HTTP::Post.new(
310
314
  uri,
311
- initheader = { 'Content-Type' => 'application/json' }
315
+ initheader = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
312
316
  )
313
317
 
314
318
  # create the request body for submission to the submissions API
@@ -341,13 +345,18 @@ e-mail and password will be stored in plain text.'
341
345
  # submit results for a single test case instance. Does *not* report overall
342
346
  # compilation status to testhub. Use an empty commit submission for that
343
347
  def submit_instance(mesa, test_case)
348
+ unless mesa.install_attempted?
349
+ raise MesaDirError, 'No testhub.yml file found in installation; '\
350
+ 'must attempt to install before subitting.'
351
+ end
352
+
344
353
  uri = URI.parse(base_uri + '/submissions/create.json')
345
354
  https = Net::HTTP.new(uri.hostname, uri.port)
346
355
  https.use_ssl = true if base_uri.include? 'https'
347
356
 
348
357
  request = Net::HTTP::Post.new(
349
358
  uri,
350
- initheader = { 'Content-Type' => 'application/json' }
359
+ initheader = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }
351
360
  )
352
361
 
353
362
  # create the request body for submission to the submissions API
@@ -443,7 +452,7 @@ class Mesa
443
452
  bash_execute(command)
444
453
 
445
454
  raise(GitHubError, 'Error while executing the following command:'\
446
- "#{command}. Perhaps you haven't set up ssh "\
455
+ "#{command}. Perhaps you haven't set up "\
447
456
  'ssh keys with your GitHub account?')
448
457
  end
449
458
  when :https
@@ -557,14 +566,17 @@ class Mesa
557
566
  # installation
558
567
  def compiler_hash
559
568
  data_file = File.join(mesa_dir, 'testhub.yml')
560
- unless File.exist? data_file
561
- raise(MesaDirError, "Could not find file testhub.yml in #{mesa_dir}.")
569
+ res = {
570
+ compiler: 'Unknown',
571
+ sdk_version: 'Unknown',
572
+ math_backend: 'Unknown'
573
+ }
574
+ if File.exist? data_file
575
+ res = res.merge(YAML.safe_load(File.read(data_file)) || {})
576
+ # currently version_number is reported, but we don't need that in Git land
577
+ res.delete('version_number') # returns the value, not the updated hash
578
+ res
562
579
  end
563
-
564
- res = YAML.safe_load(File.read(data_file))
565
- # currently version_number is reported, but we don't need that in Git land
566
- res.delete('version_number') # returns the value, not the updated hash
567
- res
568
580
  end
569
581
 
570
582
  ## TEST SUITE METHODS
@@ -602,12 +614,16 @@ class Mesa
602
614
  num, tc_name = line.strip.split
603
615
  @names_to_numbers[mod][tc_name.strip] = num.to_i
604
616
  @test_case_names[mod] << tc_name.strip
605
- @test_cases[mod][tc_name.strip] = MesaTestCase.new(
606
- test: tc_name.strip,
607
- mod: mod,
608
- position: num.to_i,
609
- mesa: self
610
- )
617
+ begin
618
+ @test_cases[mod][tc_name.strip] = MesaTestCase.new(
619
+ test: tc_name.strip,
620
+ mod: mod,
621
+ position: num.to_i,
622
+ mesa: self
623
+ )
624
+ rescue TestCaseDirError
625
+ shell.say "No such test case #{tc_name.strip}. Skipping loading it.", :red
626
+ end
611
627
  end
612
628
  end
613
629
  end
@@ -647,11 +663,16 @@ class Mesa
647
663
  def installed?
648
664
  # assume build log reflects installation status; does not account for
649
665
  # mucking with modules after the fact
650
- downloaded? && File.read(File.join(mesa_dir, 'build.log')).include?(
666
+ build_log = File.join(mesa_dir, 'build.log')
667
+ downloaded? && File.exist?(build_log) && File.read(build_log).include?(
651
668
  'MESA installation was successful'
652
669
  )
653
670
  end
654
671
 
672
+ def install_attempted?
673
+ File.exist? File.join(mesa_dir, 'testhub.yml')
674
+ end
675
+
655
676
  private
656
677
 
657
678
  # verify that mesa_dir is valid by checking for existence of test_suite
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: 1.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Wolf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.1.2
84
+ rubygems_version: 3.0.4
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Command line tool for running and reporting the MESA test suites.