openstudio_measure_tester 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c701b7ee1c908a30adce739d1ef8e30a1b804b1
4
- data.tar.gz: 2520f8964fdeb8ea55df34d743676c56732dca46
3
+ metadata.gz: 114965f771ab5429ff6e0a47f9469143723f957a
4
+ data.tar.gz: 6880af89a1126f2474f503722ce73746074bf04d
5
5
  SHA512:
6
- metadata.gz: c419ccadea649d88baef183cb66780178dfb3b3a70be6077c08c7f1d7ca8a95657105f1a6a9ae4444e1ffc189df5c9d74ce0d3abc1f03f01783849476dde7369
7
- data.tar.gz: 7ec95e37072d0f1af63b8435d1eb283a2a9eb387a02ba0b0e544fc9f460a1ad4c177e618754caedf12d89975966766f046eb3c299f38c21cb7ab1ca6a506db81
6
+ metadata.gz: 65c48c6e8ebe186696f5a2322dde5899e84bacfadd95510b75cf03e8982bee6137f9ea4d2e36fabb7b103e9211cedb8d228c70ffe6a7f17cc16fadd850299fa2
7
+ data.tar.gz: aeb836feeafb27e169a38e1569b0f2fe606ba8df68d8133dd2c29627df23b5084d70f8245af706c09aba56621342b30fcb1192477bf2fe37887cc9e162090688
data/.gitignore CHANGED
@@ -18,7 +18,7 @@
18
18
  rspec.html
19
19
  Gemfile.lock
20
20
  **/.rubocop-http*
21
- rubocop-results.xml
21
+ /rubocop-results.xml
22
22
  !spec/files/rubocop-results.xml
23
23
  spec/files/rubocop/rubocop.json
24
24
  spec/**/.rubocop.yml
data/.travis.yml CHANGED
@@ -1,21 +1,15 @@
1
1
  sudo: true
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.4
4
+ - 2.2.4
5
5
  matrix:
6
6
  include:
7
7
  - env: OPENSTUDIO_VERSION=2.4.0 && OPENSTUDIO_SHA=f58a3e1808 && RUBYLIB=/usr/Ruby
8
8
  - env: OPENSTUDIO_VERSION=2.5.1 && OPENSTUDIO_SHA=4f268e2854 && RUBYLIB=/usr/Ruby
9
9
  before_install: gem install bundler -v 1.16.2
10
10
  before_script:
11
- - curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/docker/deployment/scripts/install_openstudio.sh
12
- - chmod +x install_openstudio.sh
13
- - sudo ./install_openstudio.sh $OPENSTUDIO_VERSION $OPENSTUDIO_SHA
11
+ - curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/docker/deployment/scripts/install_openstudio.sh
12
+ - chmod +x install_openstudio.sh
13
+ - sudo ./install_openstudio.sh $OPENSTUDIO_VERSION $OPENSTUDIO_SHA
14
14
  script:
15
- - bundle exec rake
16
- deploy:
17
- - provider: rubygems
18
- api_key:
19
- secure: IOYqPDXgaX5tZgsaeuSs2Q5hUry0l2RHrXDmuEeu7SElLDQSXS2z8c43eHg6GphtIho9NZgonXeCe1QoXb/GdHsyv2Up1XfaTtPkf7LHJo/zYPF7Yjc1mjGpKRPfk1srH8nfb6w9w7zjFlhk73a/Vh26BvdRCXqAA8W72d0ur2p8OTlGSYjcgLihWI13sSKrfHjTRXhOpv6gkziaY2pmvNWeeYdqOD3CpvlMDAMkHY/KptksaqWdBAT9Jr4gIfAGeGbKzye0OmBBrwMV4n/4KZqNNDyjiGYGoSbOhVEsAOHbeJz6IOoC93ICQi/nLuWBw+T8do79X2/GBIj2/N7eaEo4CcYsxMS0JX+dE4yL+OzQOFkDenq0WAEB7JjtBVW3sBHAIRGO2o2Cma6Ga5+86oSD0f5lAvnhiCejA1Fy9X5pnIMsk1zWlPLydPX4TwIm10JBaRLut+MFq0tL5tJunyIwlZnMgVofVdKYZHS7fVOvqSTQhM+iA0Gx5l7bKZQjpO3m91j14pKqdJij0PJ4oxy7ozc38YSUL85NKXnbf2KwnYVxMGz4yBrSalzMjftu6WfCM8liDTb0ACHby56KbPrlVlixJrrJIefZCLqaHtqL2lLlyVV36EtRbNl3It7DrOQ21HK3raOEuSxht3uuTu9FIdTx0TKraJUyToE6gbw=
20
- on:
21
- tags: true
15
+ - bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # Version 0.1.6
2
+
3
+ * Do not require git to run
4
+ * Change name of compatibility JSON to the measure name (instead of file name)
5
+
1
6
  # Version 0.1.5
2
7
 
3
8
  * Run Minitest in foreground
data/README.md CHANGED
@@ -43,26 +43,26 @@ The OpenStudio Measure Tester is a rubygem that exposes rake tasks for testing O
43
43
 
44
44
  * Require the OpenStudio-measure-tester gem
45
45
 
46
- ```ruby
47
- require 'openstudio_measure_tester'
48
- measures_dir = 'spec/test_measures/AddOverhangsByProjectionFactor'
49
- # all measures (recursively) from measures_dir will be tested
50
-
51
- runner = OpenStudioMeasureTester::Runner.new(measures_dir)
46
+ ```ruby
47
+ require 'openstudio_measure_tester'
48
+ measures_dir = 'spec/test_measures/AddOverhangsByProjectionFactor'
49
+ # all measures (recursively) from measures_dir will be tested
52
50
 
53
- # base_dir is needed for coverage results as they are written to disk on the at_exit calls
54
- base_dir = Dir.pwd
55
-
56
- result = runner.run_all(base_dir)
57
- puts result
58
- # result will be 0 or 1, 0=success, 1=failure
51
+ runner = OpenStudioMeasureTester::Runner.new(measures_dir)
59
52
 
60
- runner.run_style(false)
53
+ # base_dir is needed for coverage results as they are written to disk on the at_exit calls
54
+ base_dir = Dir.pwd
61
55
 
62
- runner.run_test(false, base_dir)
56
+ result = runner.run_all(base_dir)
57
+ puts result
58
+ # result will be 0 or 1, 0=success, 1=failure
63
59
 
64
- runner.run_rubocop(false)
65
- ```
60
+ runner.run_style(false)
61
+
62
+ runner.run_test(false, base_dir)
63
+
64
+ runner.run_rubocop(false)
65
+ ```
66
66
 
67
67
  * Results will be saved into the run directory (measures_dir from above).
68
68
 
@@ -85,5 +85,8 @@ export RUBYLIB=/usr/Ruby
85
85
 
86
86
  # Releasing
87
87
 
88
- New versions of the OpenStudio Measure Tester Gem will be automatically released for any tags. Makes sure to increment
89
- the version in `/lib/openstudio_measure_tester/version.rb` and tag the release (preferably off the master branch).
88
+ * Update change log
89
+ * Update version in `/lib/openstudio_measure_tester/version.rb`
90
+ * Merge down to master
91
+ * Release via github
92
+ * run `rake release` from master
@@ -107,7 +107,7 @@ body {
107
107
  .donut .status {
108
108
  display: block;
109
109
  position: absolute;
110
- top: 50%;
110
+ top: 43%;
111
111
  left: 50%;
112
112
  width: 30%;
113
113
  height: 0;
@@ -125,7 +125,7 @@ body {
125
125
  .donut .adjust-pos {
126
126
 
127
127
  padding-top: 10%;
128
- margin-top: -10%;
128
+ margin-top: -20%;
129
129
 
130
130
  }
131
131
 
data/dashboard/index.html CHANGED
@@ -33,22 +33,14 @@
33
33
  <div class="card-block">
34
34
  <div class="card-body">
35
35
  <h5 class="card-title">Tests</h5>
36
-
37
-
38
36
  <div class="row pt-5">
39
-
40
37
  <div class="col-sm-4 offset-sm-1 badge-height badge badge-success"><span class='large-text'>0</span></div>
41
-
42
-
43
38
  <div class="col-sm-4 offset-sm-2 badge-height badge badge-success"><span class='large-text'>0</span></div>
44
-
45
39
  </div>
46
40
  <div class="row">
47
41
  <div class="col-sm-4 offset-sm-1 center-text"><span class="badge-text">Failures</span></div>
48
42
  <div class="col-sm-4 offset-sm-2 center-text"><span class="badge-text">Errors</span></div>
49
43
  </div>
50
-
51
-
52
44
  </div>
53
45
  </div>
54
46
  </div>
@@ -59,16 +51,12 @@
59
51
  <div class="card-body">
60
52
  <h5 class="card-title">OpenStudio Style</h5>
61
53
  <div>
62
-
63
54
  <div class="row pt-5">
64
-
65
55
  <div class="col-sm-4 offset-sm-4 badge-height badge badge-danger"><span class='large-text'>34</span></div>
66
-
67
56
  </div>
68
57
  <div class="row">
69
58
  <div class="col-sm-4 offset-sm-4 center-text"><span class="badge-text">Errors</span></div>
70
59
  </div>
71
-
72
60
  </div>
73
61
  </div>
74
62
  </div>
@@ -115,16 +103,11 @@
115
103
  <tr>
116
104
  <td>ChangeBuildingLocation</td>
117
105
  <td>
118
-
119
106
  <span class="badge badge-danger">0</span>
120
107
  <span class="badge badge-warning">0</span>
121
-
122
108
  </td>
123
109
  <td>
124
-
125
- <span class="badge badge-danger">6</span>
126
-
127
-
110
+ <span class="badge badge-danger">6</span>
128
111
  </td>
129
112
  <td></td>
130
113
  <td>79.69 %</td>
@@ -552,7 +535,6 @@
552
535
  size(true);
553
536
 
554
537
  }());
555
-
556
538
  </script>
557
539
  </body>
558
540
  </html>
@@ -29,11 +29,16 @@
29
29
  require 'openstudio'
30
30
 
31
31
  require 'pp'
32
- require 'git'
33
32
  require 'rexml/document'
34
33
  require 'minitest'
35
34
  require 'simplecov'
36
35
 
36
+ begin
37
+ require 'git'
38
+ rescue LoadError => error
39
+ puts 'Could not load git, will not be able to report git information'
40
+ end
41
+
37
42
  # override the default at_exit call
38
43
  SimpleCov.at_exit do
39
44
  end
@@ -44,17 +49,17 @@ def Minitest.autorun; end
44
49
  # Rubocop loads a lot of objects, anyway to minimize would be nice.
45
50
  require 'rubocop'
46
51
 
47
- require 'openstudio_measure_tester/core_ext'
48
- require 'openstudio_measure_tester/version'
49
- require 'openstudio_measure_tester/openstudio_style'
50
- require 'openstudio_measure_tester/minitest_result'
51
- require 'openstudio_measure_tester/coverage'
52
- require 'openstudio_measure_tester/rubocop_result'
53
- require 'openstudio_measure_tester/openstudio_testing_result'
54
- require 'openstudio_measure_tester/dashboard'
55
- require 'openstudio_measure_tester/runner'
52
+ require_relative 'openstudio_measure_tester/core_ext'
53
+ require_relative 'openstudio_measure_tester/version'
54
+ require_relative 'openstudio_measure_tester/openstudio_style'
55
+ require_relative 'openstudio_measure_tester/minitest_result'
56
+ require_relative 'openstudio_measure_tester/coverage'
57
+ require_relative 'openstudio_measure_tester/rubocop_result'
58
+ require_relative 'openstudio_measure_tester/openstudio_testing_result'
59
+ require_relative 'openstudio_measure_tester/dashboard'
60
+ require_relative 'openstudio_measure_tester/runner'
56
61
 
57
- require 'openstudio_measure_tester/rake_task'
62
+ require_relative 'openstudio_measure_tester/rake_task'
58
63
 
59
64
  # Set the encoding to UTF-8. OpenStudio Docker images do not have this set by default
60
65
  Encoding.default_external = Encoding::UTF_8
@@ -64,15 +69,13 @@ module OpenStudioMeasureTester
64
69
  # No action here. Most of this will be rake_tasks at the moment.
65
70
  end
66
71
 
67
-
68
72
  class Minitest::Test
69
- def teardown
70
- before = ObjectSpace.count_objects
71
- GC.start
72
- after = ObjectSpace.count_objects
73
- delta = {}
74
- before.each {|k, v| delta[k] = v - after[k] if after.has_key? k }
75
- puts "GC Delta: #{delta}"
76
- end
73
+ def teardown
74
+ before = ObjectSpace.count_objects
75
+ GC.start
76
+ after = ObjectSpace.count_objects
77
+ delta = {}
78
+ before.each { |k, v| delta[k] = v - after[k] if after.key? k }
79
+ puts "GC Delta: #{delta}"
80
+ end
77
81
  end
78
-
@@ -35,6 +35,7 @@ module OpenStudioMeasureTester
35
35
  attr_reader :total_failures
36
36
  attr_reader :total_skipped
37
37
  attr_reader :total_tests
38
+ attr_reader :total_compatibility_errors
38
39
  attr_reader :measure_results
39
40
  attr_reader :summary
40
41
 
@@ -46,6 +47,9 @@ module OpenStudioMeasureTester
46
47
  @total_errors = 0
47
48
  @total_failures = 0
48
49
  @total_skipped = 0
50
+ @total_compatibility_errors = 0
51
+ @total_loaded = true
52
+ @total_load_errors = []
49
53
 
50
54
  @measure_results = {}
51
55
  @summary = {}
@@ -55,37 +59,76 @@ module OpenStudioMeasureTester
55
59
  end
56
60
 
57
61
  def parse_results
58
- Dir["#{@path_to_results}/reports/*.xml"].each do |file|
59
- puts "Parsing minitest report #{file}"
60
- doc = REXML::Document.new(File.open(file)).root
62
+ # use the compatibility file to find the measure name and other files
63
+ Dir["#{@path_to_results}/compatibility/*.json"].each do |file|
64
+ puts "Parsing compatibility report #{file}"
65
+ json_data = JSON.parse(File.read(file), symbolize_names: true)
61
66
 
62
- # continue if doc is empty
63
- next unless doc
64
-
65
- measure_name = file.split('/')[-1].split('.')[0].split('-')[1].gsub /-?[tT]est\z/, ''
67
+ # Test if the measure has already been parse, if so, then continue
68
+ next if @measure_results.keys.include? json_data[:measure_name]
66
69
 
67
70
  mhash = {}
68
- mhash['tested_class'] = measure_name
69
-
70
- # Note: only 1 failure and 1 error possible per test
71
- testsuite_element = doc.elements['testsuite']
72
- errors, failures = parse_measure(testsuite_element)
73
-
74
- mhash['measure_tests'] = testsuite_element.attributes['tests'].to_i
75
- mhash['measure_assertions'] = testsuite_element.attributes['assertions'].to_i
76
- mhash['measure_errors'] = testsuite_element.attributes['errors'].to_i
77
- mhash['measure_failures'] = testsuite_element.attributes['failures'].to_i
78
- mhash['measure_skipped'] = testsuite_element.attributes['skipped'].to_i
71
+ mhash[:tested_class] = json_data[:measure_name]
72
+ mhash[:openstudio_version] = json_data[:openstudio_version]
73
+ mhash[:measure_min_version] = json_data[:measure_min_version]
74
+ mhash[:measure_max_version] = json_data[:measure_max_version]
75
+ mhash[:loaded] = json_data[:loaded]
76
+ if json_data[:load_errors].nil?
77
+ mhash[:load_errors] = []
78
+ else
79
+ mhash[:load_errors] = json_data[:load_errors]
80
+ end
79
81
 
80
- mhash['issues'] = { errors: errors, failures: failures }
82
+ # initialize a bunch of data
83
+ mhash[:measure_compatibility_errors] = json_data[:compatible] ? 0 : 1
84
+ mhash[:measure_tests] = 0
85
+ mhash[:measure_assertions] = 0
86
+ mhash[:measure_errors] = 0
87
+ mhash[:measure_failures] = 0
88
+ mhash[:measure_skipped] = 0
89
+ mhash[:issues] = {
90
+ errors: [],
91
+ failures: [],
92
+ skipped: [],
93
+ compatibility_error: json_data[:compatible] ? 0 : 1
94
+ }
95
+
96
+ # find the report XML - if it exists
97
+ report_xmls = Dir["#{@path_to_results}/reports/TEST-#{json_data[:measure_name]}*.xml"]
98
+ if report_xmls.count == 1
99
+ puts "Parsing minitest report #{report_xmls[0]}"
100
+ doc = REXML::Document.new(File.open(report_xmls[0])).root
101
+
102
+ if doc
103
+ # Note: only 1 failure and 1 error possible per test
104
+ testsuite_element = doc.elements['testsuite']
105
+ errors, failures, skipped = parse_measure(testsuite_element)
106
+
107
+ mhash[:measure_tests] = testsuite_element.attributes['tests'].to_i
108
+ mhash[:measure_assertions] = testsuite_element.attributes['assertions'].to_i
109
+ mhash[:measure_errors] = testsuite_element.attributes['errors'].to_i
110
+ mhash[:measure_failures] = testsuite_element.attributes['failures'].to_i
111
+ mhash[:measure_skipped] = testsuite_element.attributes['skipped'].to_i
112
+
113
+ mhash[:issues][:errors] = errors
114
+ mhash[:issues][:failures] = failures
115
+ mhash[:issues][:skipped] = skipped
116
+ end
117
+ else
118
+ # There are more than one XMLs or there are no XML
119
+ # No XMLs is typically because the measure was not applicable to then version of OpenStudio
120
+ end
81
121
 
82
- @measure_results[measure_name] = mhash
122
+ @measure_results[mhash[:tested_class]] = mhash
83
123
 
84
- @total_tests += mhash['measure_tests']
85
- @total_assertions += mhash['measure_assertions']
86
- @total_errors += mhash['measure_errors']
87
- @total_failures += mhash['measure_failures']
88
- @total_skipped += mhash['measure_skipped']
124
+ @total_tests += mhash[:measure_tests]
125
+ @total_assertions += mhash[:measure_assertions]
126
+ @total_errors += mhash[:measure_errors]
127
+ @total_failures += mhash[:measure_failures]
128
+ @total_skipped += mhash[:measure_skipped]
129
+ @total_compatibility_errors += mhash[:measure_compatibility_errors]
130
+ @total_loaded = @total_loaded && mhash[:loaded]
131
+ @total_load_errors.concat(mhash[:load_errors])
89
132
  end
90
133
 
91
134
  @error_status = true if @total_errors > 0
@@ -94,14 +137,17 @@ module OpenStudioMeasureTester
94
137
  def to_file
95
138
  # save as a json and have something else parse it/plot it.
96
139
 
97
- @summary['test_directory'] = @path_to_results
98
- @summary['total_tests'] = @total_tests
99
- @summary['total_assertions'] = @total_assertions
100
- @summary['total_errors'] = @total_errors
101
- @summary['total_failures'] = @total_failures
102
- @summary['total_skipped'] = @total_skipped
103
- @summary['by_measure'] = @measure_results
104
-
140
+ @summary[:test_directory] = @path_to_results
141
+ @summary[:total_tests] = @total_tests
142
+ @summary[:total_assertions] = @total_assertions
143
+ @summary[:total_errors] = @total_errors
144
+ @summary[:total_failures] = @total_failures
145
+ @summary[:total_skipped] = @total_skipped
146
+ @summary[:total_compatibility_errors] = @total_compatibility_errors
147
+ @summary[:total_loaded] = @total_loaded
148
+ @summary[:total_load_errors] = @total_load_errors
149
+ @summary[:by_measure] = @measure_results
150
+
105
151
  # pp @summary
106
152
 
107
153
  FileUtils.mkdir "#{@path_to_results}/" unless Dir.exist? "#{@path_to_results}/"
@@ -115,16 +161,19 @@ module OpenStudioMeasureTester
115
161
  def parse_measure(testsuite_element)
116
162
  errors = []
117
163
  failures = []
164
+ skipped = []
118
165
 
119
166
  testsuite_element.elements.each('testcase') do |testcase|
120
167
  if testcase.elements['error']
121
168
  errors << testcase.elements['error']
122
169
  elsif testcase.elements['failure']
123
170
  failures << testcase.elements['failure']
171
+ elsif testcase.elements['skipped']
172
+ skipped << 'Skipped test: ' + testcase.elements['skipped'].attributes['type']
124
173
  end
125
174
  end
126
175
 
127
- return errors, failures
176
+ return errors, failures, skipped
128
177
  end
129
178
  end
130
179
  end
@@ -39,6 +39,20 @@ module OpenStudioMeasureTester
39
39
  type: :deprecated,
40
40
  severity: :error,
41
41
  file_type: :measure
42
+ }, {
43
+ regex: /OpenStudio::Ruleset::WorkspaceUserScript/,
44
+ check_type: :if_exists,
45
+ message: 'OpenStudio::Ruleset::WorkspaceUserScript is deprecated, use OpenStudio::Measure::EnergyPlusMeasure instead.',
46
+ type: :deprecated,
47
+ severity: :error,
48
+ file_type: :measure
49
+ }, {
50
+ regex: /OpenStudio::Ruleset::ReportingUserScript/,
51
+ check_type: :if_exists,
52
+ message: 'OpenStudio::Ruleset::ReportingUserScript is deprecated, use OpenStudio::Measure::ReportingMeasure instead.',
53
+ type: :deprecated,
54
+ severity: :error,
55
+ file_type: :measure
42
56
  }, {
43
57
  regex: /OpenStudio::Ruleset::OSRunner/,
44
58
  check_type: :if_exists,
@@ -154,7 +168,7 @@ module OpenStudioMeasureTester
154
168
  measure_info = infoExtractor(measure, OpenStudio::Model::OptionalModel.new, OpenStudio::OptionalWorkspace.new)
155
169
  rescue NameError => error
156
170
  log_message("Unable to parse info from measure. Error: '#{error}'", :general, :error)
157
- rescue => error
171
+ rescue StandardError => error
158
172
  log_message("Unknown error extracting measure info. Error #{error}", :general, :error)
159
173
  end
160
174
 
@@ -397,7 +411,6 @@ module OpenStudioMeasureTester
397
411
  result[:version_modified] = nil
398
412
  end
399
413
  result[:xml_checksum] = measure.xmlChecksum
400
- result[:name] = measure.name
401
414
  result[:display_name] = measure.displayName
402
415
  result[:class_name] = measure.className
403
416
  result[:description] = measure.description
@@ -52,7 +52,7 @@ module OpenStudioMeasureTester
52
52
  g = Git.open(Dir.pwd)
53
53
  config = g.config
54
54
  repo_name = config['remote.origin.url'] ? config['remote.origin.url'].split('/').last.chomp('.git') : nil
55
- current_branch = g.branch.name ? g.branch.name : nil
55
+ current_branch = g.branch.name || nil
56
56
  logs = g.log
57
57
  sha = nil
58
58
  if !logs.empty?
@@ -79,7 +79,7 @@ module OpenStudioMeasureTester
79
79
  # the @results hash
80
80
  filename = "#{@test_results_dir}/openstudio_style/openstudio_style.json"
81
81
  if File.exist? filename
82
- puts "Found OpenStudio Style results, parsing"
82
+ puts 'Found OpenStudio Style results, parsing'
83
83
  @results['openstudio_style'] = JSON.parse(File.read(filename))
84
84
  end
85
85
 
@@ -96,7 +96,7 @@ module OpenStudioMeasureTester
96
96
  if @test_results_dir != @orig_results_dir
97
97
  # coverage
98
98
  if Dir.exist? "#{@orig_results_dir}/coverage"
99
- puts "Found Coverage results, parsing"
99
+ puts 'Found Coverage results, parsing'
100
100
  FileUtils.rm_rf "#{@test_results_dir}/coverage" if Dir.exist? "#{@test_results_dir}/coverage"
101
101
  FileUtils.cp_r "#{@orig_results_dir}/coverage/.", "#{@test_results_dir}/coverage"
102
102
  FileUtils.rm_rf "#{@orig_results_dir}/coverage" if Dir.exist? "#{@orig_results_dir}/coverage"
@@ -108,18 +108,21 @@ module OpenStudioMeasureTester
108
108
 
109
109
  # minitest
110
110
  if Dir.exist?("#{@orig_results_dir}/test/html_reports") || Dir.exist?("#{@orig_results_dir}/test/reports")
111
- puts "Found Minitest Results, parsing"
112
- FileUtils.rm_rf "#{@test_results_dir}/minitest" if Dir.exist? "#{@test_results_dir}/minitest"
111
+ puts 'Found Minitest Results, parsing'
112
+ # Do not delete the compatibilty directory which is generated when the test is run
113
+ FileUtils.rm_rf "#{@test_results_dir}/minitest/html_reports" if Dir.exist? "#{@test_results_dir}/minitest/html_reports"
114
+ FileUtils.rm_rf "#{@test_results_dir}/minitest/reports" if Dir.exist? "#{@test_results_dir}/minitest/reports"
115
+
113
116
  FileUtils.mkdir_p "#{@test_results_dir}/minitest"
114
117
 
115
118
  # Copy the files over in case the folder is locked.
116
119
  if Dir.exist?("#{@orig_results_dir}/test/html_reports")
117
- puts "Moving Minitest HTML results to results directory"
120
+ puts 'Moving Minitest HTML results to results directory'
118
121
  FileUtils.cp_r "#{@orig_results_dir}/test/html_reports/.", "#{@test_results_dir}/minitest/html_reports"
119
122
  end
120
123
 
121
124
  if Dir.exist?("#{@orig_results_dir}/test/reports")
122
- puts "Moving Minitest XML results to results directory"
125
+ puts 'Moving Minitest XML results to results directory'
123
126
  FileUtils.cp_r "#{@orig_results_dir}/test/reports/.", "#{@test_results_dir}/minitest/reports"
124
127
  end
125
128
 
@@ -178,7 +181,7 @@ module OpenStudioMeasureTester
178
181
  end
179
182
 
180
183
  if @results['minitest']
181
- if @results['minitest']['total_errors'] > 0 || @results['minitest']['total_failures'] > 0
184
+ if @results['minitest'][:total_errors] > 0 || @results['minitest'][:total_failures] > 0
182
185
  puts 'Unit Test (Minitest) errors/failures found.'
183
186
  final_exit_code = 1
184
187
  end
@@ -79,7 +79,7 @@ module OpenStudioMeasureTester
79
79
  #
80
80
  # @param original_results_directory [string] Location of the results from coverag and minitest
81
81
  def post_process_results(original_results_directory = nil)
82
- puts " ========================= Starting Results Post Process ================================"
82
+ puts ' ========================= Starting Results Post Process ================================'
83
83
  puts "Current directory: #{@base_dir}"
84
84
  puts "Test results will be stored in: #{test_results_dir}"
85
85
 
@@ -109,7 +109,7 @@ module OpenStudioMeasureTester
109
109
  end
110
110
 
111
111
  def run_style(skip_post_process)
112
- puts " ========================= Starting Run for OpenStudio Style ================================"
112
+ puts ' ========================= Starting Run for OpenStudio Style ================================'
113
113
  pre_process_style
114
114
 
115
115
  # Run the style tests
@@ -124,7 +124,7 @@ module OpenStudioMeasureTester
124
124
  end
125
125
 
126
126
  def run_rubocop(skip_post_process, auto_correct = false)
127
- puts " ========================= Starting Run for Rubocop ================================"
127
+ puts ' ========================= Starting Run for Rubocop ================================'
128
128
  pre_process_rubocop
129
129
 
130
130
  rubocop_results_file = "#{test_results_dir}/rubocop/rubocop-results.xml"
@@ -159,7 +159,7 @@ module OpenStudioMeasureTester
159
159
 
160
160
  # The results of the coverage and minitest are stored in the root of the directory structure (if Rake)
161
161
  def run_test(skip_post_process, original_results_directory, run_coverage = true)
162
- puts " ========================= Starting Run for Minitest (and coverage) ============================"
162
+ puts ' ========================= Starting Run for Minitest (and coverage) ============================'
163
163
  # not sure what @base_dir has to be right now
164
164
  pre_process_minitest(original_results_directory)
165
165
 
@@ -194,10 +194,76 @@ module OpenStudioMeasureTester
194
194
  end
195
195
 
196
196
  num_tests = 0
197
+ openstudio_version = OpenStudio::VersionString.new(OpenStudio.openStudioVersion)
197
198
  Dir["#{@base_dir}/**/*_Test.rb", "#{@base_dir}/**/*_test.rb"].uniq.each do |file|
198
- puts "Loading file for testing: #{file}"
199
- load File.expand_path(file)
200
- num_tests += 1
199
+
200
+ begin
201
+ file = File.expand_path(file)
202
+ measure_dir = File.expand_path(File.join(File.dirname(file), '..'))
203
+
204
+ # check measure xml
205
+ compatible = {
206
+ compatible: true,
207
+ message: '',
208
+ openstudio_version: openstudio_version.str,
209
+ measure_min_version: 'None',
210
+ measure_max_version: 'None',
211
+ loaded: false,
212
+ load_errors: []
213
+ }
214
+ begin
215
+ measure = OpenStudio::BCLMeasure.new(measure_dir)
216
+ compatible[:measure_name] = measure.className
217
+ measure.files.each do |f|
218
+ if f.fileName == 'measure.rb'
219
+ if !f.minCompatibleVersion.empty?
220
+ min_version = f.minCompatibleVersion.get
221
+ compatible[:measure_min_version] = min_version.str
222
+ if openstudio_version < min_version
223
+ compatible[:compatible] = false
224
+ compatible[:message] = "OpenStudio Version #{openstudio_version.str} < Min Version #{min_version.str}"
225
+ end
226
+ end
227
+ if !f.maxCompatibleVersion.empty?
228
+ max_version = f.maxCompatibleVersion.get
229
+ compatible[:measure_max_version] = max_version.str
230
+ if openstudio_version > max_version
231
+ compatible[:compatible] = false
232
+ compatible[:message] = "OpenStudio Version #{openstudio_version.str} > Max Version #{max_version.str}"
233
+ end
234
+ end
235
+ end
236
+ end
237
+ rescue StandardError => exception
238
+ compatible[:compatible] = false
239
+ compatible[:message] = exception.message
240
+ end
241
+
242
+ if !compatible[:compatible]
243
+ puts "Measure not compatible: #{measure_dir}, #{compatible[:message]}"
244
+ next
245
+ end
246
+
247
+ # load test
248
+ puts "Loading file for testing: #{file}"
249
+ begin
250
+ load file
251
+ compatible[:loaded] = true
252
+ num_tests += 1
253
+ rescue StandardError, LoadError => exception
254
+ compatible[:load_errors] << exception.message
255
+ end
256
+
257
+ ensure
258
+ # Write out the compatibility
259
+ # write out to a file that the measure is not applicable
260
+ os_compatible_file = "#{@base_dir}/test_results/minitest/compatibility/#{compatible[:measure_name]}.json"
261
+ puts os_compatible_file
262
+ FileUtils.mkdir_p File.dirname(os_compatible_file) unless Dir.exists? File.dirname(os_compatible_file)
263
+ File.open(os_compatible_file, 'w') do |f|
264
+ f << JSON.pretty_generate(compatible)
265
+ end
266
+ end
201
267
  end
202
268
 
203
269
  if num_tests < 1
@@ -39,7 +39,23 @@
39
39
  <div class="card-block">
40
40
  <div class="card-body">
41
41
  <h5 class="card-title">Tests</h5>
42
-
42
+ <% if @hash['minitest'] && @hash['minitest']['total_load_errors'] %>
43
+ <div class="row pt-3">
44
+ <% total_load_errors = @hash['minitest']['total_load_errors'].count %>
45
+ <% if total_load_errors > 0 %>
46
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-danger"><span class='med-text'><%= total_load_errors %></span></div>
47
+ <% else %>
48
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-success"><span class='med-text'><%= total_load_errors %></span></div>
49
+ <% end %>
50
+ <div class="col-sm-3 badge-med-height badge-text">Load Errors</div>
51
+ </div>
52
+ <% else %>
53
+ <div class="row pt-3">
54
+ <div class="col-sm-6 offset-sm-3 badge-lg-height badge badge-warning badge-text"><i data-feather="alert-triangle" class="size48"></i><br><span class="pt-2">No Data</span> </div>
55
+ <div class="col-sm-3 badge-med-height badge-text">Load Errors</div>
56
+ </div>
57
+ <% end %>
58
+
43
59
  <% if @hash['minitest'] && @hash['minitest']['total_failures'] %>
44
60
  <div class="row pt-3">
45
61
  <% passed = @hash['minitest']['total_tests'] - (@hash['minitest']['total_failures'] + @hash['minitest']['total_errors'] + @hash['minitest']['total_skipped']) %>
@@ -62,6 +78,22 @@
62
78
  <% end %>
63
79
  <div class="col-sm-5 badge-med-height badge-text">Errors</div>
64
80
  </div>
81
+ <div class="row pt-2">
82
+ <% if @hash['minitest']['total_skipped'] > 0 %>
83
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-info"><span class='med-text'><%= @hash['minitest']['total_skipped'] %></span></div>
84
+ <% else %>
85
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-success"><span class='med-text'><%= @hash['minitest']['total_skipped'] %></span></div>
86
+ <% end %>
87
+ <div class="col-sm-5 badge-med-height badge-text">Skipped</div>
88
+ </div>
89
+ <div class="row pt-2">
90
+ <% if @hash['minitest']['total_compatibility_errors'] > 0 %>
91
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-info"><span class='med-text'><%= @hash['minitest']['total_compatibility_errors'] %></span></div>
92
+ <% else %>
93
+ <div class="col-sm-3 offset-sm-2 badge-med-height badge badge-success"><span class='med-text'><%= @hash['minitest']['total_compatibility_errors'] %></span></div>
94
+ <% end %>
95
+ <div class="col-sm-5 badge-med-height badge-text">Incompatible</div>
96
+ </div>
65
97
  <% else %>
66
98
  <div class="row pt-5">
67
99
  <div class="col-sm-6 offset-sm-3 badge-lg-height badge badge-warning badge-text"><i data-feather="alert-triangle" class="size48"></i><br><span class="pt-2">No Data</span> </div>
@@ -135,19 +167,30 @@
135
167
  <table class="table table-striped table-sm table-text">
136
168
  <thead>
137
169
  <tr>
138
- <th>Measure Name</th>
139
- <th>Tests<br/><span class="small-text">Passed - Failures - Errors</span></th>
140
- <th>OS Style Errors<br/><span class="small-text">Errors - Warnings - Info</span></th>
141
- <th>RuboCop<br/><span class="small-text">Errors - Warnings - Info</span></th>
142
- <th>Coverage</th>
143
- <th>&nbsp;</th>
170
+ <th rowspan="2">Measure Name</th>
171
+ <th rowspan="2">Loaded</th>
172
+ <th rowspan="2">Min OS Version</th>
173
+ <th rowspan="2">Max OS Version</th>
174
+ <th rowspan="2">Tested OS Version</th>
175
+ <th colspan="5">Tests</th>
176
+ <th rowspan="2">OS Style Errors<br/><span class="small-text">Errors - Warnings - Info</span></th>
177
+ <th rowspan="2">RuboCop<br/><span class="small-text">Errors - Warnings - Info</span></th>
178
+ <th rowspan="2">Coverage</th>
179
+ <th>&nbsp</th>
180
+ </tr>
181
+ <tr>
182
+ <th>Pass</th>
183
+ <th>Fail</th>
184
+ <th>Error</th>
185
+ <th>Skip</th>
186
+ <th>Incom</th>
144
187
  </tr>
145
188
  </thead>
146
189
  <tbody>
147
190
  <!-- use the largest 'by_measure' array, in case the tests weren't all run (coverage & minitest run together) -->
148
191
  <% max = 0 %>
149
192
  <% test_type = ''%>
150
- <% ['coverage', 'openstudio_style', 'rubocop'].each do |type| %>
193
+ <% ['coverage', 'openstudio_style', 'minitest','rubocop'].each do |type| %>
151
194
  <% if @hash[type] && @hash[type]['by_measure'] %>
152
195
  <% if @hash[type]['by_measure'].length > max %>
153
196
  <% max = @hash[type]['by_measure'].length %>
@@ -159,8 +202,36 @@
159
202
  <% @hash[test_type]['by_measure'].each do |name, measure| %>
160
203
  <tr>
161
204
  <td><%= name %></td>
205
+ <td>
206
+ <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] && @hash['minitest']['by_measure'][name]['loaded'] %>
207
+ Yes
208
+ <% else %>
209
+ False
210
+ <% end %>
211
+ </td>
212
+ <td>
213
+ <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] %>
214
+ <%= @hash['minitest']['by_measure'][name]['measure_min_version'] %>
215
+ <% else %>
216
+ Unknown
217
+ <% end %>
218
+ </td>
219
+ <td>
220
+ <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] %>
221
+ <%= @hash['minitest']['by_measure'][name]['measure_max_version'] %>
222
+ <% else %>
223
+ Unknown
224
+ <% end %>
225
+ </td>
162
226
  <td>
163
227
  <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] %>
228
+ <%= @hash['minitest']['by_measure'][name]['openstudio_version'] %>
229
+ <% else %>
230
+ Unknown
231
+ <% end %>
232
+ </td>
233
+ <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] %>
234
+ <td>
164
235
  <% passed = @hash['minitest']['by_measure'][name]['measure_tests'] - (@hash['minitest']['by_measure'][name]['measure_failures'] + @hash['minitest']['by_measure'][name]['measure_errors'] + @hash['minitest']['by_measure'][name]['measure_skipped']) %>
165
236
  <span class="badge badge-success"><%= passed %></span>
166
237
  <% if @hash['minitest']['by_measure'][name]['measure_failures'] > 0 %>
@@ -168,15 +239,21 @@
168
239
  <% else %>
169
240
  <% label = 'success' %>
170
241
  <% end %>
242
+ </td>
243
+ <td>
171
244
  <span class="badge badge-<%= label %>"><%= @hash['minitest']['by_measure'][name]['measure_failures'] %></span>
172
245
  <% if @hash['minitest']['by_measure'][name]['measure_errors'] > 0 %>
173
- <% label = 'danger' %>
246
+ <% label = 'danger' %>
174
247
  <% else %>
175
- <% label = 'success' %>
248
+ <% label = 'success' %>
176
249
  <% end %>
177
- <span class="badge badge-<%= label %>"><%= @hash['minitest']['by_measure'][name]['measure_errors'] %></span>
178
- <% end %>
179
- </td>
250
+ </td>
251
+ <td><span class="badge badge-<%= label %>"><%= @hash['minitest']['by_measure'][name]['measure_errors'] %></span></td>
252
+ <td><span class="badge badge-info"><%= @hash['minitest']['by_measure'][name]['measure_skipped'] %></span></td>
253
+ <td><span class="badge badge-info"><%= @hash['minitest']['by_measure'][name]['measure_compatibility_errors'] %></span></td>
254
+ <% else %>
255
+ <td></td><td></td><td></td><td></td><td></td>
256
+ <% end %>
180
257
  <td>
181
258
  <% if @hash['openstudio_style'] && @hash['openstudio_style']['by_measure'][name] %>
182
259
  <% if @hash['openstudio_style']['by_measure'][name]['measure_errors'] > 0 %>
@@ -330,11 +407,44 @@
330
407
  </div>
331
408
  </div>
332
409
 
410
+ <div class="row pb-3">
411
+ <div class="col-sm-12">
412
+ <h4>Loaded</h4>
413
+ <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] %>
414
+ <% if @hash['minitest']['by_measure'][name]['loaded'] %>
415
+ <div>True</div>
416
+ <% else %>
417
+ <div>False</div>
418
+ <% if @hash['minitest']['by_measure'][name]['load_errors'] %>
419
+ <table class="table table-striped">
420
+ <thead>
421
+ <tr>
422
+ <th>Error</th>
423
+ </tr>
424
+ </thead>
425
+ <tbody>
426
+ <% @hash['minitest']['by_measure'][name]['load_errors'].each do |load_error| %>
427
+ <tr>
428
+ <td><%= load_error %></td>
429
+ </tr>
430
+ <% end %>
431
+ </tbody>
432
+ </table>
433
+ <% end %>
434
+ <% end %>
435
+ <% else %>
436
+ <div>
437
+ <span class="badge badge-danger">NO DATA</span> Test was not run
438
+ </div>
439
+ <% end %>
440
+ </div>
441
+ </div>
442
+
333
443
  <div class="row pb-3">
334
444
  <div class="col-sm-12">
335
445
  <h4>Tests</h4>
336
446
  <% if @hash['minitest'] && @hash['minitest']['by_measure'] && @hash['minitest']['by_measure'][name] && @hash['minitest']['by_measure'][name]['issues'] %>
337
- <% if @hash['minitest']['by_measure'][name]['issues']['failures'].length > 0 || @hash['minitest']['by_measure'][name]['issues']['errors'].length > 0 %>
447
+ <% if @hash['minitest']['by_measure'][name]['issues']['failures'].length > 0 || @hash['minitest']['by_measure'][name]['issues']['errors'].length > 0 || @hash['minitest']['by_measure'][name]['issues']['skipped'].length > 0 %>
338
448
  <table class="table table-striped">
339
449
  <thead>
340
450
  <tr>
@@ -354,6 +464,12 @@
354
464
  <td><span class="badge badge-dark">Error</span></td>
355
465
  <td><%= err %></td>
356
466
  </tr>
467
+ <% end %>
468
+ <% @hash['minitest']['by_measure'][name]['issues']['skipped'].each do |skip| %>
469
+ <tr>
470
+ <td><span class="badge badge-info">Skipped</span></td>
471
+ <td><%= skip %></td>
472
+ </tr>
357
473
  <% end %>
358
474
  </tbody>
359
475
  </table>
@@ -567,7 +683,6 @@
567
683
  size(true);
568
684
 
569
685
  }());
570
-
571
686
  </script>
572
687
  </body>
573
688
  </html>
@@ -27,5 +27,5 @@
27
27
  ########################################################################################################################
28
28
 
29
29
  module OpenStudioMeasureTester
30
- VERSION = '0.1.5'.freeze
30
+ VERSION = '0.1.6'.freeze
31
31
  end
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'openstudio_measure_tester/version'
@@ -23,11 +22,18 @@ Gem::Specification.new do |spec|
23
22
  spec.add_development_dependency 'bundler', '~> 1.16'
24
23
  spec.add_development_dependency 'rspec', '3.7.0'
25
24
 
25
+ if /^2\.2/.match(RUBY_VERSION)
26
+ spec.add_dependency 'rubocop', '0.54.0'
27
+ elsif /^2\.0/.match(RUBY_VERSION)
28
+ spec.add_dependency 'nokogiri', '1.6.8'
29
+ spec.add_dependency 'rainbow', '2.2.2'
30
+ spec.add_dependency 'rubocop', '0.50.0'
31
+ end
32
+
26
33
  spec.add_dependency 'git', '1.3.0'
27
34
  spec.add_dependency 'minitest', '5.4.3'
28
35
  spec.add_dependency 'minitest-reporters', '1.2.0'
29
36
  spec.add_dependency 'rake', '12.3.1'
30
- spec.add_dependency 'rubocop', '0.54.0'
31
37
  spec.add_dependency 'rubocop-checkstyle_formatter', '0.4'
32
38
  spec.add_dependency 'simplecov', '0.16.1'
33
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio_measure_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2018-06-13 00:00:00.000000000 Z
14
+ date: 2018-11-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -41,6 +41,20 @@ dependencies:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
43
  version: 3.7.0
44
+ - !ruby/object:Gem::Dependency
45
+ name: rubocop
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '='
49
+ - !ruby/object:Gem::Version
50
+ version: 0.54.0
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '='
56
+ - !ruby/object:Gem::Version
57
+ version: 0.54.0
44
58
  - !ruby/object:Gem::Dependency
45
59
  name: git
46
60
  requirement: !ruby/object:Gem::Requirement
@@ -97,20 +111,6 @@ dependencies:
97
111
  - - '='
98
112
  - !ruby/object:Gem::Version
99
113
  version: 12.3.1
100
- - !ruby/object:Gem::Dependency
101
- name: rubocop
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - '='
105
- - !ruby/object:Gem::Version
106
- version: 0.54.0
107
- type: :runtime
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - '='
112
- - !ruby/object:Gem::Version
113
- version: 0.54.0
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rubocop-checkstyle_formatter
116
116
  requirement: !ruby/object:Gem::Requirement