openstudio_measure_tester 0.1.7 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 873523e54e5442f1468b7398b0dff3e773fbe280
4
- data.tar.gz: 04e7b34c93d47e3af0554718bfaf52a8b97e4bb4
2
+ SHA256:
3
+ metadata.gz: fadfcba5d12f6b9ebbb36237521c99fd08ffd36cc8f14fab967e607800abf902
4
+ data.tar.gz: 41a3b63176ed3bb96554216d5dc50cd668c42648faf32ef0f36d20d30b5595f2
5
5
  SHA512:
6
- metadata.gz: 34d5ee8f5ee06c1c06cca5768e280cc0bead1fae7e3bbb85410e7c5d5256bc3bf1dd681a8cae61ee1ea7b1d258d37652fbe28113b5557967d5db136b958cdf0a
7
- data.tar.gz: b11fef30aed043abec4a4ea1931620ad8249df59e490870e17f8c13df7bbd5910203f7197b969ac51fcca48ded5dfd3e7263d860757c6c76749f1e7f2b08a870
6
+ metadata.gz: b42fc88d7ee1221a215a7fb079a7e22633e6b1f7f70b7ee9b96551325a2d9259d03998efd024a7d5e7a6ff95bd4b9f2795f4edbb03f8645577c1edc7952bd212
7
+ data.tar.gz: 2df445991da6b52f06e8bff11452a47d26003ca72491a3b6490f3fa97aabc662e32e3acdda2679d660a1f164b8fcf89cb3ddddb91767768266d737443e4e0f67
data/.rubocop.yml CHANGED
@@ -2,4 +2,4 @@ AllCops:
2
2
  Exclude:
3
3
  - 'spec/test_measures/**/*'
4
4
  inherit_from:
5
- - http://s3.amazonaws.com/openstudio-resources/styles/rubocop.yml
5
+ - http://s3.amazonaws.com/openstudio-resources/styles/rubocop_v3.yml
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # Version 0.3.0
2
+
3
+ * Upgrade to Ruby 2.7.0
4
+
5
+ # Version 0.2.3
6
+
7
+ * Use updated rubocop style (v3)
8
+ * Update instructions on running tests in Docker.
9
+
10
+ # Version 0.2.2
11
+
12
+ * Revert to using Rubocop 0.54 to support non-native gems in OpenStudio CLI.
13
+
14
+ # Version 0.2.1
15
+
16
+ * Update to SimpleCov 0.18.2
17
+ * Pessimistically version dependencies
18
+
19
+ # Version 0.2.0
20
+
21
+ * Remove support for Ruby 2.2.4. Use Ruby ~> 2.5.x
22
+ * Remove NREL's fork of simplecov
23
+ * Update copyrights
24
+ * Remove travis and leverage NREL's Jenkins CI
25
+
1
26
  # Version 0.1.7
2
27
 
3
28
  * Support running measure tester in the directory of the measure.rb with OpenStudio CLI (e.g. `openstudio measure -r .`)
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in openstudio_measure_tester.gemspec
6
8
  gemspec
7
-
8
- gem 'simplecov', github: 'NREL/simplecov'
data/Jenkinsfile ADDED
@@ -0,0 +1,10 @@
1
+ //Jenkins pipelines are stored in shared libraries. Please see: https://github.com/NREL/cbci_jenkins_libs
2
+
3
+ @Library('cbci_shared_libs@ruby_270') _
4
+
5
+ // Build for PR to develop branch only.
6
+ if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) { // check if set
7
+
8
+ openstudio_measure_tester_gem()
9
+
10
+ }
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
1
+ OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification, are permitted provided
4
4
  that the following conditions are met:
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # OpenStudio® Measure Tester
2
2
 
3
- [![Build Status](https://travis-ci.org/NREL/OpenStudio-measure-tester-gem.svg?branch=develop)](https://travis-ci.org/NREL/OpenStudio-measure-tester-gem)
4
3
  [![Gem Version](https://badge.fury.io/rb/openstudio_measure_tester.svg)](https://badge.fury.io/rb/openstudio_measure_tester)
5
4
 
6
5
  The OpenStudio Measure Tester is a rubygem that exposes rake tasks for testing OpenStudio measures.
@@ -71,17 +70,22 @@ The OpenStudio Measure Tester is a rubygem that exposes rake tasks for testing O
71
70
  # Testing in Docker
72
71
 
73
72
  ```bash
73
+ docker run -it -v $(pwd):/root/test -w '/root' ubuntu:18.04 bash
74
74
 
75
+ # within container
75
76
  apt-get update && apt-get install -y curl
76
77
  curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/docker/deployment/scripts/install_ruby.sh
77
- curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/docker/deployment/scripts/install_openstudio.sh
78
+ curl -sLO https://raw.githubusercontent.com/NREL/OpenStudio-server/develop/ci/travis/install_openstudio.sh
78
79
  chmod +x install_ruby.sh
79
80
  chmod +x install_openstudio.sh
80
- ./install_ruby.sh 2.2.4 b6eff568b48e0fda76e5a36333175df049b204e91217aa32a65153cc0cdcb761
81
- ./install_openstudio.sh 2.4.0 f58a3e1808
81
+ ./install_ruby.sh 2.5.5 28a945fdf340e6ba04fc890b98648342e3cccfd6d223a48f3810572f11b2514c
82
+ ./install_openstudio.sh 3.0.0 1c9617fa4e
82
83
  export RUBYLIB=/usr/Ruby
83
- ```
84
84
 
85
+ cd /root/test
86
+ bundle update
87
+ bundle exec rake
88
+ ```
85
89
 
86
90
  # Releasing
87
91
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'openstudio_measure_tester'
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'openstudio_measure_tester'
4
5
 
@@ -12,11 +13,11 @@ end
12
13
  begin
13
14
  runner = OpenStudioMeasureTester::Runner.new(measure_dir)
14
15
  runner.run_all(Dir.pwd)
15
- rescue StandardError => exception
16
+ rescue StandardError => e
16
17
  puts
17
18
  puts '!!!!!!!!!!!!!!!!!!!!! Error Occurred !!!!!!!!!!!!!!!!!!!!!'
18
- puts exception.message
19
- puts exception.backtrace
19
+ puts e.message
20
+ puts e.backtrace
20
21
  puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
21
22
  puts
22
23
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -34,8 +36,8 @@ require 'minitest'
34
36
  require 'simplecov'
35
37
 
36
38
  begin
37
- require 'git'
38
- rescue LoadError => error
39
+ require 'git'
40
+ rescue LoadError => e
39
41
  puts 'Could not load git, will not be able to report git information'
40
42
  end
41
43
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -1,3 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################################################################
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
7
+ # following conditions are met:
8
+ #
9
+ # (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
10
+ # disclaimer.
11
+ #
12
+ # (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
13
+ # following disclaimer in the documentation and/or other materials provided with the distribution.
14
+ #
15
+ # (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
16
+ # products derived from this software without specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
19
+ # works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
20
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
+ # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR
25
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27
+ # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ ########################################################################################################################
30
+
1
31
  require 'erb'
2
32
  module OpenStudioMeasureTester
3
33
  class Dashboard
@@ -15,7 +45,7 @@ module OpenStudioMeasureTester
15
45
  end
16
46
 
17
47
  def render
18
- rendered = ERB.new(@template, 0, '', '@html').result(binding)
48
+ rendered = ERB.new(@template, 0, nil, '@html').result(binding)
19
49
  save_dir = "#{@test_results_directory}/dashboard"
20
50
 
21
51
  # Render the dashboard
@@ -24,7 +54,7 @@ module OpenStudioMeasureTester
24
54
  # copy over all the resource files to display the website correctly.
25
55
  resource_path = File.expand_path('../../dashboard', File.dirname(__FILE__))
26
56
  # KAF: for some reason, not overwriting the files. delete them from destination first
27
- FileUtils.remove_dir("#{save_dir}/css") if Dir.exist?"#{save_dir}/css"
57
+ FileUtils.remove_dir("#{save_dir}/css") if Dir.exist? "#{save_dir}/css"
28
58
  FileUtils.remove_dir("#{save_dir}/js") if Dir.exist? "#{save_dir}/js"
29
59
  FileUtils.cp_r("#{resource_path}/css", "#{save_dir}/css", remove_destination: true)
30
60
  FileUtils.cp_r("#{resource_path}/js", "#{save_dir}/js", remove_destination: true)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -65,7 +67,7 @@ module OpenStudioMeasureTester
65
67
  json_data = JSON.parse(File.read(file), symbolize_names: true)
66
68
 
67
69
  # Test if the measure has already been parse, if so, then continue
68
- next if @measure_results.keys.include? json_data[:measure_name]
70
+ next if @measure_results.key?(json_data[:measure_name])
69
71
 
70
72
  mhash = {}
71
73
  mhash[:tested_class] = json_data[:measure_name]
@@ -87,10 +89,10 @@ module OpenStudioMeasureTester
87
89
  mhash[:measure_failures] = 0
88
90
  mhash[:measure_skipped] = 0
89
91
  mhash[:issues] = {
90
- errors: [],
91
- failures: [],
92
- skipped: [],
93
- compatibility_error: json_data[:compatible] ? 0 : 1
92
+ errors: [],
93
+ failures: [],
94
+ skipped: [],
95
+ compatibility_error: json_data[:compatible] ? 0 : 1
94
96
  }
95
97
 
96
98
  # find the report XML - if it exists
@@ -127,7 +129,7 @@ module OpenStudioMeasureTester
127
129
  @total_failures += mhash[:measure_failures]
128
130
  @total_skipped += mhash[:measure_skipped]
129
131
  @total_compatibility_errors += mhash[:measure_compatibility_errors]
130
- @total_loaded = @total_loaded && mhash[:loaded]
132
+ @total_loaded &&= mhash[:loaded]
131
133
  @total_load_errors.concat(mhash[:load_errors])
132
134
  end
133
135
 
@@ -147,7 +149,7 @@ module OpenStudioMeasureTester
147
149
  @summary[:total_loaded] = @total_loaded
148
150
  @summary[:total_load_errors] = @total_load_errors
149
151
  @summary[:by_measure] = @measure_results
150
-
152
+
151
153
  # pp @summary
152
154
 
153
155
  FileUtils.mkdir "#{@path_to_results}/" unless Dir.exist? "#{@path_to_results}/"
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -96,7 +98,7 @@ module OpenStudioMeasureTester
96
98
  severity: :warning,
97
99
  file_type: :test
98
100
  }, {
99
- regex: /require .openstudio\/ruleset /,
101
+ regex: %r{require .openstudio/ruleset },
100
102
  check_type: :if_exists,
101
103
  message: "Require openstudio/ruleset/* is deprecated. Use require 'openstudio/measure/*'",
102
104
  type: :syntax,
@@ -166,10 +168,10 @@ module OpenStudioMeasureTester
166
168
  begin
167
169
  # there seems to be a race condition with the infoExtractor method
168
170
  measure_info = infoExtractor(measure, OpenStudio::Model::OptionalModel.new, OpenStudio::OptionalWorkspace.new)
169
- rescue NameError => error
170
- log_message("Unable to parse info from measure. Error: '#{error}'", :general, :error)
171
- rescue StandardError => error
172
- log_message("Unknown error extracting measure info. Error #{error}", :general, :error)
171
+ rescue NameError => e
172
+ log_message("Unable to parse info from measure. Error: '#{e}'", :general, :error)
173
+ rescue StandardError => e
174
+ log_message("Unknown error extracting measure info. Error #{e}", :general, :error)
173
175
  end
174
176
 
175
177
  measure_hash = generate_measure_hash(measure_dir, measure, measure_info)
@@ -236,11 +238,11 @@ module OpenStudioMeasureTester
236
238
  def run_regex_checks(measure_dir)
237
239
  def check(data, check)
238
240
  if check[:check_type] == :if_exists
239
- if data =~ check[:regex]
241
+ if data.match?(check[:regex])
240
242
  log_message(check[:message], check[:type], check[:severity])
241
243
  end
242
244
  elsif check[:check_type] == :if_missing
243
- if data !~ check[:regex]
245
+ if !data&.match?(check[:regex])
244
246
  log_message(check[:message], check[:type], check[:severity])
245
247
  end
246
248
  end
@@ -273,11 +275,11 @@ module OpenStudioMeasureTester
273
275
  clean_name = name
274
276
 
275
277
  # Check for parenthetical names
276
- if clean_name =~ /\(.+?\)/
278
+ if clean_name.match?(/\(.+?\)/)
277
279
  log_message("#{name_type} '#{name}' appears to have units. Set units in the setUnits method.", severity)
278
280
  end
279
281
 
280
- if clean_name =~ /\?|\.|\#/
282
+ if clean_name.match?(/\?|\.|\#/)
281
283
  log_message("#{name_type} '#{name}' cannot contain ?#.[] characters.", :syntax, severity)
282
284
  end
283
285
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -58,7 +60,7 @@ module OpenStudioMeasureTester
58
60
  if !logs.empty?
59
61
  sha = logs.first.sha
60
62
  end
61
- rescue StandardError => error
63
+ rescue StandardError => e
62
64
  puts 'Could not find .git for measure(s), will not be able to report git information'
63
65
  end
64
66
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -69,7 +71,7 @@ module OpenStudioMeasureTester
69
71
  desc 'Run RuboCop Auto Correct on Measures'
70
72
  task :auto_correct do
71
73
  # original_dir is the location where Rakefile exists, Dir.pwd is where the rake task was called.
72
- runner = OpenStudioMeasureTester::Runner.new(Rake.application.original_dir, Dir.pwd)
74
+ runner = OpenStudioMeasureTester::Runner.new(Rake.application.original_dir)
73
75
 
74
76
  exit runner.run_rubocop(false, true)
75
77
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -65,7 +67,7 @@ module OpenStudioMeasureTester
65
67
  end
66
68
 
67
69
  def parse_results
68
- Dir[File.join(@path_to_results,'rubocop-results.xml')].each do |file|
70
+ Dir[File.join(@path_to_results, 'rubocop-results.xml')].each do |file|
69
71
  puts "Parsing Rubocop report #{file}"
70
72
 
71
73
  measure_names = []
@@ -1,3 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ ########################################################################################################################
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
7
+ # following conditions are met:
8
+ #
9
+ # (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
10
+ # disclaimer.
11
+ #
12
+ # (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
13
+ # following disclaimer in the documentation and/or other materials provided with the distribution.
14
+ #
15
+ # (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
16
+ # products derived from this software without specific prior written permission from the respective party.
17
+ #
18
+ # (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
19
+ # works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
20
+ # specific prior written permission from Alliance for Sustainable Energy, LLC.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
+ # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR
25
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27
+ # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ ########################################################################################################################
30
+
1
31
  module OpenStudioMeasureTester
2
32
  # The runner is the workhorse that executes the tests. This class does not invoke Rake and can be run
3
33
  # as a library method or as a CLI call
@@ -196,73 +226,70 @@ module OpenStudioMeasureTester
196
226
  num_tests = 0
197
227
  openstudio_version = OpenStudio::VersionString.new(OpenStudio.openStudioVersion)
198
228
  Dir["#{@base_dir}/**/*_Test.rb", "#{@base_dir}/**/*_test.rb"].uniq.each do |file|
199
-
229
+ file = File.expand_path(file)
230
+ measure_dir = File.expand_path(File.join(File.dirname(file), '..'))
231
+
232
+ # check measure xml
233
+ compatible = {
234
+ compatible: true,
235
+ message: '',
236
+ openstudio_version: openstudio_version.str,
237
+ measure_min_version: 'None',
238
+ measure_max_version: 'None',
239
+ loaded: false,
240
+ load_errors: []
241
+ }
200
242
  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
243
+ measure = OpenStudio::BCLMeasure.new(measure_dir)
244
+ compatible[:measure_name] = measure.className
245
+ measure.files.each do |f|
246
+ if f.fileName == 'measure.rb'
247
+ if !f.minCompatibleVersion.empty?
248
+ min_version = f.minCompatibleVersion.get
249
+ compatible[:measure_min_version] = min_version.str
250
+ if openstudio_version < min_version
251
+ compatible[:compatible] = false
252
+ compatible[:message] = "OpenStudio Version #{openstudio_version.str} < Min Version #{min_version.str}"
226
253
  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
254
+ end
255
+ if !f.maxCompatibleVersion.empty?
256
+ max_version = f.maxCompatibleVersion.get
257
+ compatible[:measure_max_version] = max_version.str
258
+ if openstudio_version > max_version
259
+ compatible[:compatible] = false
260
+ compatible[:message] = "OpenStudio Version #{openstudio_version.str} > Max Version #{max_version.str}"
234
261
  end
235
262
  end
236
263
  end
237
- rescue StandardError => exception
238
- compatible[:compatible] = false
239
- compatible[:message] = exception.message
240
264
  end
265
+ rescue StandardError => e
266
+ compatible[:compatible] = false
267
+ compatible[:message] = e.message
268
+ end
241
269
 
242
- if !compatible[:compatible]
243
- puts "Measure not compatible: #{measure_dir}, #{compatible[:message]}"
244
- next
245
- end
270
+ if !compatible[:compatible]
271
+ puts "Measure not compatible: #{measure_dir}, #{compatible[:message]}"
272
+ next
273
+ end
246
274
 
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
275
+ # load test
276
+ puts "Loading file for testing: #{file}"
277
+ begin
278
+ load file
279
+ compatible[:loaded] = true
280
+ num_tests += 1
281
+ rescue StandardError, LoadError => e
282
+ compatible[:load_errors] << e.message
283
+ end
284
+
285
+ ensure
286
+ # Write out the compatibility
287
+ # write out to a file that the measure is not applicable
288
+ os_compatible_file = "#{@base_dir}/test_results/minitest/compatibility/#{compatible[:measure_name]}.json"
289
+ puts os_compatible_file
290
+ FileUtils.mkdir_p File.dirname(os_compatible_file) unless Dir.exist? File.dirname(os_compatible_file)
291
+ File.open(os_compatible_file, 'w') do |f|
292
+ f << JSON.pretty_generate(compatible)
266
293
  end
267
294
  end
268
295
 
@@ -295,11 +322,11 @@ module OpenStudioMeasureTester
295
322
  # openstudio_measure_tester.rb file, so it will not run.
296
323
  begin
297
324
  Minitest.run ['--verbose']
298
- rescue StandardError => exception
325
+ rescue StandardError => e
299
326
  puts
300
327
  puts '!!!!!!!!!!!!!!!!!!!!! Minitest Error Occurred !!!!!!!!!!!!!!!!!!!!!'
301
- puts exception.message
302
- puts exception.backtrace
328
+ puts e.message
329
+ puts e.backtrace
303
330
  puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
304
331
  puts
305
332
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################################################################
2
- # OpenStudio(R), Copyright (c) 2008-2018, Alliance for Sustainable Energy, LLC. All rights reserved.
4
+ # OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved.
3
5
  #
4
6
  # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5
7
  # following conditions are met:
@@ -27,5 +29,5 @@
27
29
  ########################################################################################################################
28
30
 
29
31
  module OpenStudioMeasureTester
30
- VERSION = '0.1.7'.freeze
32
+ VERSION = '0.3.0'.freeze
31
33
  end
@@ -1,38 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'openstudio_measure_tester/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = 'openstudio_measure_tester'
7
- spec.version = OpenStudioMeasureTester::VERSION
8
- spec.authors = ['Nicholas Long', 'Katherine Fleming', 'Daniel Macumber', 'Robert Guglielmetti']
9
- spec.email = ['nicholas.long@nrel.gov']
8
+ spec.name = 'openstudio_measure_tester'
9
+ spec.version = OpenStudioMeasureTester::VERSION
10
+ spec.authors = ['Nicholas Long', 'Katherine Fleming', 'Daniel Macumber', 'Robert Guglielmetti']
11
+ spec.email = ['nicholas.long@nrel.gov']
10
12
 
11
- spec.summary = 'Testing framework for OpenStudio measures'
12
- spec.description = 'Testing framework for OpenStudio measures'
13
- spec.homepage = 'https://openstudio.nrel.gov'
13
+ spec.homepage = 'https://openstudio.nrel.gov'
14
+ spec.summary = 'Testing framework for OpenStudio measures'
15
+ spec.description = 'Testing framework for OpenStudio measures'
16
+ spec.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/NREL/OpenStudio-measure-tester-gem/issues',
18
+ 'changelog_uri' => 'https://github.com/NREL/OpenStudio-measure-tester-gem/blob/develop/CHANGELOG.md',
19
+ # 'documentation_uri' => 'https://www.rubydoc.info/gems/openstudio_measure_tester/#{gem.version}',
20
+ 'source_code_uri' => "https://github.com/NREL/OpenStudio-measure-tester-gem/tree/v#{spec.version}"
21
+ }
14
22
 
15
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
24
  f.match(%r{^(test|spec|features)/})
17
25
  end
18
- spec.bindir = 'exe'
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
28
  spec.require_paths = ['lib']
21
29
 
22
- spec.add_development_dependency 'bundler', '~> 1.16'
23
- spec.add_development_dependency 'rspec', '3.7.0'
30
+ spec.required_ruby_version = '~> 2.7.0'
24
31
 
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 'rainbow', '2.2.2'
29
- spec.add_dependency 'rubocop', '0.50.0'
30
- end
31
-
32
- spec.add_dependency 'git', '1.3.0'
33
- spec.add_dependency 'minitest', '5.4.3'
34
- spec.add_dependency 'minitest-reporters', '1.2.0'
35
- spec.add_dependency 'rake', '12.3.1'
36
- spec.add_dependency 'rubocop-checkstyle_formatter', '0.4'
37
- spec.add_dependency 'simplecov', '0.16.1'
32
+ spec.add_dependency 'git', '~> 1.6.0'
33
+ spec.add_dependency 'minitest', '~> 5.14.0'
34
+ spec.add_dependency 'minitest-reporters', '~> 1.4.2'
35
+ spec.add_dependency 'rake', '~> 13.0'
36
+ spec.add_dependency 'rubocop', '~> 0.54.0'
37
+ spec.add_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
38
+ spec.add_dependency 'simplecov', '~> 0.18.2'
39
+
40
+ spec.add_development_dependency 'bundler', '>= 2.1.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.9'
38
42
  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.7
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long
@@ -11,134 +11,134 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2018-12-12 00:00:00.000000000 Z
14
+ date: 2021-02-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: bundler
17
+ name: git
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.16'
23
- type: :development
22
+ version: 1.6.0
23
+ type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '1.16'
29
+ version: 1.6.0
30
30
  - !ruby/object:Gem::Dependency
31
- name: rspec
31
+ name: minitest
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '='
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: 3.7.0
37
- type: :development
36
+ version: 5.14.0
37
+ type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '='
41
+ - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 3.7.0
43
+ version: 5.14.0
44
44
  - !ruby/object:Gem::Dependency
45
- name: rubocop
45
+ name: minitest-reporters
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '='
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: 0.54.0
50
+ version: 1.4.2
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '='
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 0.54.0
57
+ version: 1.4.2
58
58
  - !ruby/object:Gem::Dependency
59
- name: git
59
+ name: rake
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '='
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 1.3.0
64
+ version: '13.0'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '='
69
+ - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: 1.3.0
71
+ version: '13.0'
72
72
  - !ruby/object:Gem::Dependency
73
- name: minitest
73
+ name: rubocop
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '='
76
+ - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: 5.4.3
78
+ version: 0.54.0
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '='
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
- version: 5.4.3
85
+ version: 0.54.0
86
86
  - !ruby/object:Gem::Dependency
87
- name: minitest-reporters
87
+ name: rubocop-checkstyle_formatter
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '='
90
+ - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: 1.2.0
92
+ version: 0.4.0
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - '='
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 1.2.0
99
+ version: 0.4.0
100
100
  - !ruby/object:Gem::Dependency
101
- name: rake
101
+ name: simplecov
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '='
104
+ - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: 12.3.1
106
+ version: 0.18.2
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '='
111
+ - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: 12.3.1
113
+ version: 0.18.2
114
114
  - !ruby/object:Gem::Dependency
115
- name: rubocop-checkstyle_formatter
115
+ name: bundler
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: '0.4'
121
- type: :runtime
120
+ version: 2.1.0
121
+ type: :development
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: '0.4'
127
+ version: 2.1.0
128
128
  - !ruby/object:Gem::Dependency
129
- name: simplecov
129
+ name: rspec
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - '='
132
+ - - "~>"
133
133
  - !ruby/object:Gem::Version
134
- version: 0.16.1
135
- type: :runtime
134
+ version: '3.9'
135
+ type: :development
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - '='
139
+ - - "~>"
140
140
  - !ruby/object:Gem::Version
141
- version: 0.16.1
141
+ version: '3.9'
142
142
  description: Testing framework for OpenStudio measures
143
143
  email:
144
144
  - nicholas.long@nrel.gov
@@ -148,11 +148,10 @@ extra_rdoc_files: []
148
148
  files:
149
149
  - ".gitignore"
150
150
  - ".rspec"
151
- - ".rubocop-http---s3-amazonaws-com-openstudio-resources-styles-rubocop-yml"
152
151
  - ".rubocop.yml"
153
- - ".travis.yml"
154
152
  - CHANGELOG.md
155
153
  - Gemfile
154
+ - Jenkinsfile
156
155
  - LICENSE.md
157
156
  - README.md
158
157
  - Rakefile
@@ -184,24 +183,26 @@ files:
184
183
  - openstudio_measure_tester.gemspec
185
184
  homepage: https://openstudio.nrel.gov
186
185
  licenses: []
187
- metadata: {}
186
+ metadata:
187
+ bug_tracker_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/issues
188
+ changelog_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/blob/develop/CHANGELOG.md
189
+ source_code_uri: https://github.com/NREL/OpenStudio-measure-tester-gem/tree/v0.3.0
188
190
  post_install_message:
189
191
  rdoc_options: []
190
192
  require_paths:
191
193
  - lib
192
194
  required_ruby_version: !ruby/object:Gem::Requirement
193
195
  requirements:
194
- - - ">="
196
+ - - "~>"
195
197
  - !ruby/object:Gem::Version
196
- version: '0'
198
+ version: 2.7.0
197
199
  required_rubygems_version: !ruby/object:Gem::Requirement
198
200
  requirements:
199
201
  - - ">="
200
202
  - !ruby/object:Gem::Version
201
203
  version: '0'
202
204
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.4.5.1
205
+ rubygems_version: 3.1.4
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Testing framework for OpenStudio measures
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- sudo: true
2
- language: ruby
3
- rvm:
4
- - 2.2.4
5
- matrix:
6
- include:
7
- - env: OPENSTUDIO_VERSION=2.4.0 && OPENSTUDIO_SHA=f58a3e1808 && RUBYLIB=/usr/Ruby
8
- - env: OPENSTUDIO_VERSION=2.5.1 && OPENSTUDIO_SHA=4f268e2854 && RUBYLIB=/usr/Ruby
9
- before_install: gem install bundler -v 1.16.2
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
14
- script:
15
- - bundle exec rake