mesa_test 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/bin/mesa_test +4 -3
- data/lib/mesa_test.rb +94 -58
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b7e362b36d07cf2b8c7ded808a3b24c340b58b1
|
4
|
+
data.tar.gz: b6fef0ca5feb4591beea0eaffa03d75a18f845bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2643e83269c0a6c3b77699871968e848c996591136b68109378673eaca00940c9b06eef5fb939f34272875cd4a54ae28bce219723acb19c23ba3bff31cf7ce5
|
7
|
+
data.tar.gz: 3096f55ef13fbb1809b4c3d833992b592b8bede6e9aa4b92336aae0ba9aa092c8fb5a54efd92acd999b04b35a14eb7fd83e3e8620d2dd2d8ca3dfd9f704484d5
|
data/bin/mesa_test
CHANGED
@@ -5,15 +5,16 @@ require 'mesa_test'
|
|
5
5
|
require 'thor'
|
6
6
|
|
7
7
|
class MesaTest < Thor
|
8
|
-
desc
|
8
|
+
desc 'setup [CONFIG_FILE]', 'Setup MesaTestHub config file.'
|
9
9
|
long_desc <<-LONGDESC
|
10
10
|
If optional CONFIG_FILE is provided, search for that file and load it
|
11
11
|
to provide default values for configuration. If not provided, the default
|
12
12
|
file, ~/.mesa_test.yml, is used. The resulting config file is saved to
|
13
13
|
the same location it was read from.
|
14
14
|
LONGDESC
|
15
|
-
def setup(config_file=File.join(ENV['HOME'], '.mesa_test.yml'))
|
16
|
-
MesaTestSubmitter.new_from_config(config_file: config_file
|
15
|
+
def setup(config_file = File.join(ENV['HOME'], '.mesa_test.yml'))
|
16
|
+
MesaTestSubmitter.new_from_config(config_file: config_file,
|
17
|
+
force_setup: true)
|
17
18
|
end
|
18
19
|
|
19
20
|
desc 'test_one MESA_DIR TEST_CASE', "run, check, and submit one test case"
|
data/lib/mesa_test.rb
CHANGED
@@ -91,8 +91,9 @@ e-mail and password will be stored in plain text.'
|
|
91
91
|
|
92
92
|
def self.new_from_config(
|
93
93
|
config_file: File.join(ENV['HOME'], '.mesa_test.yml'), force_setup: false,
|
94
|
-
base_uri: 'https://mesa-test-hub.herokuapp.com'
|
95
|
-
|
94
|
+
base_uri: 'https://mesa-test-hub.herokuapp.com'
|
95
|
+
)
|
96
|
+
new_submitter = new(config_file: config_file, base_uri: base_uri)
|
96
97
|
if force_setup
|
97
98
|
new_submitter.setup
|
98
99
|
elsif not File.exist? config_file
|
@@ -110,9 +111,11 @@ e-mail and password will be stored in plain text.'
|
|
110
111
|
attr_reader :shell
|
111
112
|
|
112
113
|
# many defaults are set in body
|
113
|
-
def initialize(
|
114
|
+
def initialize(
|
115
|
+
computer_name: nil, user_name: nil, email: nil, platform: nil,
|
114
116
|
platform_version: nil, processor: nil, ram_gb: nil, compiler: nil,
|
115
|
-
compiler_version: nil, config_file: nil, base_uri: nil
|
117
|
+
compiler_version: nil, config_file: nil, base_uri: nil
|
118
|
+
)
|
116
119
|
@computer_name = computer_name || Socket.gethostname.scan(/^[^\.]+\.?/)[0]
|
117
120
|
@computer_name.chomp!('.') if @computer_name
|
118
121
|
@user_name = user_name || (ENV['USER'] || ENV['USERNAME'])
|
@@ -150,26 +153,23 @@ e-mail and password will be stored in plain text.'
|
|
150
153
|
end
|
151
154
|
|
152
155
|
def confirm_computer_data
|
153
|
-
puts
|
154
|
-
puts
|
156
|
+
puts 'Ready to submit the following data:'
|
157
|
+
puts '-------------------------------------------------------'
|
155
158
|
puts "Computer Name #{computer_name}"
|
156
159
|
puts "User Name #{user_name}"
|
157
160
|
puts "User email #{email}"
|
158
|
-
puts
|
161
|
+
puts 'Password ***********'
|
159
162
|
puts "Platform #{platform} #{platform_version}"
|
160
163
|
puts "Processor #{processor}"
|
161
164
|
puts "RAM #{ram_gb} GB"
|
162
165
|
puts "Compiler #{compiler} #{compiler_version}"
|
163
166
|
puts "Config location #{config_file}"
|
164
|
-
puts
|
165
|
-
puts
|
167
|
+
puts '-------------------------------------------------------'
|
168
|
+
puts ''
|
166
169
|
shell = Thor.new
|
167
|
-
response = shell.ask
|
168
|
-
if response.strip.
|
169
|
-
|
170
|
-
else
|
171
|
-
return false
|
172
|
-
end
|
170
|
+
response = shell.ask 'Is this correct? (y/Y = Yes, anything else = No):'
|
171
|
+
return true if response.strip.casecmp 'y'
|
172
|
+
false
|
173
173
|
end
|
174
174
|
|
175
175
|
# For one "computer" on the web server, and for [subjective] consistency
|
@@ -181,39 +181,39 @@ e-mail and password will be stored in plain text.'
|
|
181
181
|
# if you try different compilers
|
182
182
|
#
|
183
183
|
# Note this is NOT checked! The server really only uses the test-by-test
|
184
|
-
# quantities (platform version, compiler, compiler version) and the
|
184
|
+
# quantities (platform version, compiler, compiler version) and the
|
185
185
|
# computer name. Once the computer is found (by the name) all the other
|
186
|
-
# data is assumed to be fixed. The others... probably shouldn't be here,
|
186
|
+
# data is assumed to be fixed. The others... probably shouldn't be here,
|
187
187
|
# but remain so you can confirm that the computer on the web server is the
|
188
188
|
# same one you think you are working with locally.
|
189
189
|
def save_computer_data
|
190
190
|
data_hash = {
|
191
|
-
computer_name
|
192
|
-
user_name
|
193
|
-
email
|
194
|
-
password
|
195
|
-
platform
|
196
|
-
processor
|
197
|
-
ram_gb
|
198
|
-
platform_version
|
199
|
-
compiler
|
200
|
-
compiler_version
|
191
|
+
'computer_name' => computer_name,
|
192
|
+
'user_name' => user_name,
|
193
|
+
'email' => email,
|
194
|
+
'password' => password,
|
195
|
+
'platform' => platform,
|
196
|
+
'processor' => processor,
|
197
|
+
'ram_gb' => ram_gb,
|
198
|
+
'platform_version' => platform_version,
|
199
|
+
'compiler' => compiler,
|
200
|
+
'compiler_version' => compiler_version
|
201
201
|
}
|
202
202
|
File.open(config_file, 'w') { |f| f.write(YAML.dump(data_hash))}
|
203
203
|
end
|
204
204
|
|
205
205
|
def load_computer_data
|
206
|
-
data_hash = YAML
|
207
|
-
@computer_name = data_hash[
|
208
|
-
@user_name = data_hash[
|
209
|
-
@email = data_hash[
|
210
|
-
@password = data_hash[
|
211
|
-
@platform = data_hash[
|
212
|
-
@processor = data_hash[
|
213
|
-
@ram_gb = data_hash[
|
214
|
-
@platform_version = data_hash[
|
215
|
-
@compiler = data_hash[
|
216
|
-
@compiler_version = data_hash[
|
206
|
+
data_hash = YAML.safe_load(File.read(config_file), [Symbol])
|
207
|
+
@computer_name = data_hash['computer_name']
|
208
|
+
@user_name = data_hash['user_name']
|
209
|
+
@email = data_hash['email']
|
210
|
+
@password = data_hash['password']
|
211
|
+
@platform = data_hash['platform']
|
212
|
+
@processor = data_hash['processor']
|
213
|
+
@ram_gb = data_hash['ram_gb']
|
214
|
+
@platform_version = data_hash['platform_version']
|
215
|
+
@compiler = data_hash['compiler']
|
216
|
+
@compiler_version = data_hash['compiler_version']
|
217
217
|
end
|
218
218
|
|
219
219
|
# create and return hash of parameters for a TestInstance submission
|
@@ -248,9 +248,10 @@ e-mail and password will be stored in plain text.'
|
|
248
248
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
249
249
|
https.use_ssl = true if base_uri.include? 'https'
|
250
250
|
|
251
|
-
request = Net::HTTP::Post.new(
|
252
|
-
initheader = { 'Content-Type' => 'application/json' }
|
253
|
-
|
251
|
+
request = Net::HTTP::Post.new(
|
252
|
+
uri, initheader = { 'Content-Type' => 'application/json' }
|
253
|
+
)
|
254
|
+
request.body = {
|
254
255
|
email: email,
|
255
256
|
password: password,
|
256
257
|
computer_name: computer_name
|
@@ -263,7 +264,7 @@ e-mail and password will be stored in plain text.'
|
|
263
264
|
# returns true if the id is in the returned JSON (indicating success)
|
264
265
|
# otherwise returns false (maybe failed in authorization or in finding
|
265
266
|
# computer or test case) No error thrown for failure, though.
|
266
|
-
def submit(test_case
|
267
|
+
def submit(test_case)
|
267
268
|
uri = URI.parse(base_uri + '/test_instances/submit.json')
|
268
269
|
https = Net::HTTP.new(uri.hostname, uri.port)
|
269
270
|
https.use_ssl = true if base_uri.include? 'https'
|
@@ -272,8 +273,15 @@ e-mail and password will be stored in plain text.'
|
|
272
273
|
uri,
|
273
274
|
initheader = { 'Content-Type' => 'application/json' }
|
274
275
|
)
|
275
|
-
|
276
|
+
begin
|
277
|
+
request.body = submit_params(test_case).to_json
|
278
|
+
rescue TestCaseDirError
|
279
|
+
shell.say "\nPassage status for #{test_case.test_name} not yet known. " \
|
280
|
+
'Run test first and then submit.', :red
|
281
|
+
return false
|
282
|
+
end
|
276
283
|
|
284
|
+
# verbose = true
|
277
285
|
# puts "\n" if verbose
|
278
286
|
# puts JSON.parse(request.body).to_hash if verbose
|
279
287
|
|
@@ -303,15 +311,15 @@ e-mail and password will be stored in plain text.'
|
|
303
311
|
end
|
304
312
|
end
|
305
313
|
puts ''
|
306
|
-
if submitted_cases.
|
307
|
-
shell.say
|
314
|
+
if submitted_cases.empty?
|
315
|
+
shell.say 'Submitted the following cases:', :green
|
308
316
|
puts submitted_cases.join("\n")
|
309
317
|
else
|
310
|
-
shell.say
|
318
|
+
shell.say 'Did not successfully submit any cases.', :red
|
311
319
|
end
|
312
|
-
if unsubmitted_cases.
|
313
|
-
puts "\n\n\n"
|
314
|
-
shell.say
|
320
|
+
if unsubmitted_cases.empty?
|
321
|
+
puts "\n\n\n"
|
322
|
+
shell.say 'Failed to submit the following cases:', :red
|
315
323
|
puts unsubmitted_cases.join("\n")
|
316
324
|
end
|
317
325
|
# return true if all cases were submitted
|
@@ -355,19 +363,25 @@ class Mesa
|
|
355
363
|
end
|
356
364
|
|
357
365
|
def clean
|
358
|
-
|
359
|
-
"
|
360
|
-
|
361
|
-
|
366
|
+
with_MESA_DIR do
|
367
|
+
visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " +
|
368
|
+
"running `clean` in #{mesa_dir}." do
|
369
|
+
puts 'MESA_DIR = ' + ENV['MESA_DIR']
|
370
|
+
puts './clean'
|
371
|
+
system('./clean')
|
372
|
+
end
|
362
373
|
end
|
363
374
|
self
|
364
375
|
end
|
365
376
|
|
366
377
|
def install
|
367
|
-
|
368
|
-
"
|
369
|
-
|
370
|
-
|
378
|
+
with_MESA_DIR do
|
379
|
+
visit_and_check mesa_dir, MesaDirError, "Encountered a problem in " +
|
380
|
+
"running `install` in #{mesa_dir}." do
|
381
|
+
puts 'MESA_DIR = ' + ENV['MESA_DIR']
|
382
|
+
puts './install'
|
383
|
+
system('./install')
|
384
|
+
end
|
371
385
|
end
|
372
386
|
self
|
373
387
|
end
|
@@ -511,6 +525,24 @@ class Mesa
|
|
511
525
|
res
|
512
526
|
end
|
513
527
|
|
528
|
+
# change MESA_DIR for the execution of the block and then revert to the
|
529
|
+
# original value
|
530
|
+
def with_MESA_DIR
|
531
|
+
# change MESA_DIR, holding on to old value
|
532
|
+
orig_mesa_dir = ENV['MESA_DIR']
|
533
|
+
ENV['MESA_DIR'] = mesa_dir
|
534
|
+
shell.say "Temporarily changed MESA_DIR to #{ENV['MESA_DIR']}.", :blue
|
535
|
+
|
536
|
+
# do the stuff
|
537
|
+
begin
|
538
|
+
yield
|
539
|
+
# make sure we undo MESA_DIR change
|
540
|
+
ensure
|
541
|
+
ENV['MESA_DIR'] = orig_mesa_dir
|
542
|
+
shell.say "Changed MESA_DIR back to #{ENV['MESA_DIR']}.", :blue
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
514
546
|
def log_summary(mod: :all)
|
515
547
|
if mod == :all
|
516
548
|
MesaTestCase.modules.each do |this_mod|
|
@@ -769,6 +801,10 @@ class MesaTestCase
|
|
769
801
|
# purposes
|
770
802
|
load_file = File.join(test_case_dir, 'test_results.yml')
|
771
803
|
shell.say "Loading data from #{load_file}...", :blue
|
804
|
+
unless File.exist? load_file
|
805
|
+
shell.say "No such file: #{load_file}. No data loaded.", :red
|
806
|
+
return
|
807
|
+
end
|
772
808
|
data = YAML.safe_load(File.read(load_file), [Symbol])
|
773
809
|
@runtime_seconds = data['runtime_seconds']
|
774
810
|
@mesa_version = data['mesa_version']
|
@@ -1005,7 +1041,7 @@ def visit_and_check(new_dir, exception, message)
|
|
1005
1041
|
puts ''
|
1006
1042
|
shell.say "Entering #{cwd}.", :blue
|
1007
1043
|
Dir.chdir(cwd)
|
1008
|
-
return
|
1044
|
+
return if success
|
1009
1045
|
raise exception, message
|
1010
1046
|
end
|
1011
1047
|
|
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.
|
4
|
+
version: 0.0.9
|
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-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|