-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-balance CI tests so the entire job finishes quicker.
- Loading branch information
Showing
6 changed files
with
189 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../hpxml-measures/HPXMLtoOpenStudio/resources/minitest_helper' | ||
require 'openstudio' | ||
require 'openstudio/measure/ShowRunnerOutput' | ||
require 'fileutils' | ||
require 'csv' | ||
require 'oga' | ||
require_relative 'util.rb' | ||
require_relative '../../rulesets/resources/constants' | ||
require_relative '../../hpxml-measures/HPXMLtoOpenStudio/resources/constants' | ||
require_relative '../../hpxml-measures/HPXMLtoOpenStudio/resources/hpxml' | ||
require_relative '../../hpxml-measures/HPXMLtoOpenStudio/resources/xmlhelper' | ||
|
||
class SampleFilesTest1 < Minitest::Test | ||
def setup | ||
@test_results_dir = File.join(File.dirname(__FILE__), 'test_results') | ||
FileUtils.mkdir_p @test_results_dir | ||
@test_files_dir = File.join(File.dirname(__FILE__), 'test_files') | ||
FileUtils.mkdir_p @test_files_dir | ||
end | ||
|
||
def test_sample_files | ||
test_name = 'sample_files1' | ||
test_results_csv = File.absolute_path(File.join(@test_results_dir, "#{test_name}.csv")) | ||
File.delete(test_results_csv) if File.exist? test_results_csv | ||
|
||
# Run simulations | ||
files = 'base*.xml' | ||
all_results = {} | ||
xmldir = "#{File.dirname(__FILE__)}/../sample_files" | ||
Dir["#{xmldir}/#{files}"].sort.each do |xml| | ||
break if xml.include? 'base-hvac-air-to-air-heat-pump-1-speed.xml' # Run first half of the sample files | ||
|
||
rundir, _hpxmls, csvs = _run_workflow(xml, test_name) | ||
all_results[File.basename(xml)] = _get_csv_results([csvs[:eri_results], | ||
csvs[:co2e_results], | ||
csvs[:es_results], | ||
csvs[:zerh_results], | ||
csvs[:iecc_eri_results]]) | ||
|
||
_rm_path(rundir) | ||
end | ||
assert(all_results.size > 0) | ||
|
||
# Write results to csv | ||
keys = [] | ||
all_results.values.each do |xml_results| | ||
xml_results.keys.each do |key| | ||
next if keys.include? key | ||
|
||
keys << key | ||
end | ||
end | ||
CSV.open(test_results_csv, 'w') do |csv| | ||
csv << ['XML'] + keys | ||
all_results.each do |xml, results| | ||
csv_line = [File.basename(xml)] | ||
keys.each do |key| | ||
csv_line << results[key] | ||
end | ||
csv << csv_line | ||
end | ||
end | ||
puts "Wrote results to #{test_results_csv}." | ||
end | ||
end |
Oops, something went wrong.