Skip to content

Commit

Permalink
Merge 6be3e29 into df0d014
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Nov 24, 2018
2 parents df0d014 + 6be3e29 commit 4cc8460
Show file tree
Hide file tree
Showing 28 changed files with 508 additions and 100 deletions.
8 changes: 6 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[flake8]
ignore = D203
ignore =
D203,
C901
exclude =
.git,
__pycache__,
epregressions/diffs/math_diff.py,
epregressions/diffs/mycsv.py,
epregressions/diffs/table_diff.py,
epregressions/diffs/thresh_dict.py,
old,
build,
dist
max-complexity = 20
max-line-length = 120
max-line-length = 120
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ epregressions/files_to_run.txt
docs/_build
venv
.python-version
.coverage
EnergyPlusRegressionTool.egg-info
aa_testSuite_error.txt
htmlcov
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

os: linux
language: python
python:
- 2.7
- 3.6

addons:
apt:
Expand All @@ -18,8 +15,20 @@ install:
- pip install --upgrade pip
- pip install -r requirements.txt

matrix:
include:
- name: "2.7 Unit Test"
python: "2.7"
env: TEST_COMMAND=test
- name: "3.6 Unit Tests"
python: "3.6"
env: TEST_COMMAND=test
- name: "3.6 Code Quality"
python: "3.6"
env: TEST_COMMAND=flake8

script:
- coverage run setup.py test
- coverage run setup.py $TEST_COMMAND

after_success:
- coveralls
2 changes: 1 addition & 1 deletion epregressions/builds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class KnownBuildTypes:
Installation = "install"


class BaseBuildDirectoryStructure:
class BaseBuildDirectoryStructure(object):
def __init__(self):
self.build_directory = None
self.run = None
Expand Down
2 changes: 1 addition & 1 deletion epregressions/builds/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class EPlusInstallDirectory(BaseBuildDirectoryStructure):

def __init__(self):
super().__init__()
super(EPlusInstallDirectory, self).__init__()
self.source_directory = None

def set_build_directory(self, build_directory):
Expand Down
5 changes: 3 additions & 2 deletions epregressions/builds/makefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class CMakeCacheMakeFileBuildDirectory(BaseBuildDirectoryStructure):

def __init__(self):
super().__init__()
super(CMakeCacheMakeFileBuildDirectory, self).__init__()
self.source_directory = None

def set_build_directory(self, build_directory):
Expand All @@ -23,6 +23,8 @@ def set_build_directory(self, build_directory):
self.source_directory = 'unknown - invalid build directory?'
return
cmake_cache_file = os.path.join(self.build_directory, 'CMakeCache.txt')
if not os.path.exists(cmake_cache_file):
raise Exception('Could not find cache file in build directory')
with open(cmake_cache_file, 'r') as f_cache:
for this_line in f_cache.readlines():
if 'CMAKE_HOME_DIRECTORY:INTERNAL=' in this_line:
Expand Down Expand Up @@ -100,4 +102,3 @@ def get_build_tree(self):
'weather_dir': os.path.join(self.source_directory, 'weather'),
'data_sets_dir': os.path.join(self.source_directory, 'datasets')
}

5 changes: 3 additions & 2 deletions epregressions/builds/visualstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CMakeCacheVisualStudioBuildDirectory(BaseBuildDirectoryStructure):
"""

def __init__(self):
super().__init__()
super(CMakeCacheVisualStudioBuildDirectory, self).__init__()
self.source_directory = None
self.build_mode = 'Release'

Expand Down Expand Up @@ -74,7 +74,8 @@ def verify(self):
["Case %s Products Directory Exists? ", products_dir, exists]
)
build_mode_folder = 'Release'
release_folder_exists = os.path.join(self.build_directory, 'Products', build_mode_folder)
release_folder = os.path.join(self.build_directory, 'Products', build_mode_folder)
release_folder_exists = os.path.exists(release_folder)
if release_folder_exists:
self.set_build_mode(debug=False)
else:
Expand Down
66 changes: 0 additions & 66 deletions epregressions/diffs/html_data.py

This file was deleted.

69 changes: 60 additions & 9 deletions epregressions/diffs/table_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,58 @@
import os.path

from bs4 import BeautifulSoup, NavigableString, Tag
from epregressions.diffs import html_data

help_message = __doc__

path = os.path.dirname(__file__)
script_dir = os.path.abspath(path)

titlecss = """<!DOCTYPE html PUBLIC "-
//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head><title>%s</title> <style type="text/css"> %s </style>
<meta name="generator" content="BBEdit 8.2" /></head>
<body></body></html>
"""

titlehtml = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%s</title>
<meta name="generator" content="BBEdit 8.2" />
</head>
<body>
</body>
</html>
"""

thecss = """td.big {
background-color: #FF969D;
}
td.small {
background-color: #FFBE84;
}
td.equal {
background-color: #CBFFFF;
}
td.table_size_error {
background-color: #FCFF97;
}
.big {
background-color: #FF969D;
}
.small {
background-color: #FFBE84;
}
"""


class Usage(Exception):
""" usage """
Expand All @@ -57,7 +102,7 @@ def __init__(self, msg):


def thresh_abs_rel_diff(abs_thresh, rel_thresh, x, y):
if (x == y):
if x == y:
return (0, 0, 'equal')
try:
fx = float(x)
Expand Down Expand Up @@ -320,13 +365,16 @@ def table_diff(thresh_dict, inputfile1, inputfile2, abs_diff_file, rel_diff_file
comparingthis = 'Comparing<br> %s<br> vs<br> %s<br><hr>' % (inputfile1, inputfile2)

# Error soup
err_soup = BeautifulSoup(html_data.titlecss % (pagetitle + ' -- summary', html_data.thecss,), features='html.parser')
err_soup = BeautifulSoup(titlecss % (pagetitle + ' -- summary', thecss,),
features='html.parser')

# Abs diff soup
abs_diff_soup = BeautifulSoup(html_data.titlecss % (pagetitle + ' -- absolute differences', html_data.thecss,), features='html.parser')
abs_diff_soup = BeautifulSoup(titlecss % (pagetitle + ' -- absolute differences', thecss,),
features='html.parser')

# Rel diff soup
rel_diff_soup = BeautifulSoup(html_data.titlecss % (pagetitle + ' -- relative differences', html_data.thecss,), features='html.parser')
rel_diff_soup = BeautifulSoup(titlecss % (pagetitle + ' -- relative differences', thecss,),
features='html.parser')

# Make error table
tabletag = Tag(err_soup, name='table', attrs=[('border', '1')])
Expand Down Expand Up @@ -449,14 +497,16 @@ def table_diff(thresh_dict, inputfile1, inputfile2, abs_diff_file, rel_diff_file
for h in horder1:
if h not in horder2:
continue
abs_diff_dict[h] = diff_dict[h] if (h == 'DummyPlaceholder' or h == 'Subcategory') else [(x_y_z[0],x_y_z[2]) for x_y_z in diff_dict[h]]
abs_diff_dict[h] = diff_dict[h] if (h == 'DummyPlaceholder' or h == 'Subcategory') else [
(x_y_z[0], x_y_z[2]) for x_y_z in diff_dict[h]]
hdict2soup(abs_diff_soup, uheading1, count_of_tables, abs_diff_dict.copy(), h_thresh_dict, horder1)

rel_diff_dict = {}
for h in horder1:
if h not in horder2:
continue
rel_diff_dict[h] = diff_dict[h] if (h == 'DummyPlaceholder' or h == 'Subcategory') else [(x_y_z[1],x_y_z[2]) for x_y_z in diff_dict[h]]
rel_diff_dict[h] = diff_dict[h] if (h == 'DummyPlaceholder' or h == 'Subcategory') else [
(x_y_z[1], x_y_z[2]) for x_y_z in diff_dict[h]]
hdict2soup(rel_diff_soup, uheading1, count_of_tables, rel_diff_dict.copy(), h_thresh_dict, horder1)

count_of_tables_diff += 1
Expand Down Expand Up @@ -487,8 +537,9 @@ def table_diff(thresh_dict, inputfile1, inputfile2, abs_diff_file, rel_diff_file
"Case,TableCount,BigDiffCount,SmallDiffCount,EqualCount,StringDiffCount,SizeErrorCount,NotIn1Count,NotIn2Count\n")
with open(summary_file, 'a') as summarize:
summarize.write("%s,%s,%s,%s,%s,%s,%s,%s,%s\n" % (
case_name, count_of_tables, count_of_big_diff, count_of_small_diff, count_of_equal, count_of_string_diff,
count_of_size_error, count_of_not_in_1, count_of_not_in_2))
case_name, count_of_tables, count_of_big_diff, count_of_small_diff, count_of_equal,
count_of_string_diff,
count_of_size_error, count_of_not_in_1, count_of_not_in_2))

return ('', count_of_tables, count_of_big_diff, count_of_small_diff, count_of_equal, count_of_string_diff,
count_of_size_error, count_of_not_in_1, count_of_not_in_2)
Expand Down
8 changes: 3 additions & 5 deletions epregressions/energyplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ def execute_energyplus(build_tree, entry_name, test_run_directory,

# Run EPMacro as necessary
if os.path.exists('in.imf'):
print("IMF file exists")
with open('in.imf', 'rb') as f:
lines = f.readlines()
newlines = []
for line in lines:
encoded_line = line.decode('UTF-8', 'ignore')
if '##fileprefix' in encoded_line:
newlines.append('')
print("Replaced fileprefix line with a blank")
else:
newlines.append(encoded_line)
with open('in.imf', 'w') as f:
Expand All @@ -73,7 +71,7 @@ def execute_energyplus(build_tree, entry_name, test_run_directory,
os.remove('in.idf')
os.rename(file_to_run_here, 'in.idf')
else:
return [build_tree['build_dir'], entry_name, False, current_process().name]
return [build_tree['build_dir'], entry_name, False, False, current_process().name]

# Run ExpandObjects and process as necessary
expand_objects_run = subprocess.Popen(expandobjects, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -162,8 +160,8 @@ def execute_energyplus(build_tree, entry_name, test_run_directory,
return [build_tree['build_dir'], entry_name, True, False, current_process().name]

except Exception as e:
f = open("aa_testSuite_error.txt", 'w')
print(e, file=f)
with open("aa_testSuite_error.txt", 'w') as f:
print(e, file=f)
return [build_tree['build_dir'], entry_name, False, False, current_process().name]

finally:
Expand Down
11 changes: 4 additions & 7 deletions epregressions/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import gi
gi.require_version('Gdk', '3.0') # unfortunately these have to go before the import
gi.require_version("Gtk", "3.0")
from gi.repository import Gdk, Gtk, GObject
from gi.repository import Gdk, Gtk, GObject # noqa

path = os.path.dirname(__file__)
script_dir = os.path.abspath(path)
Expand Down Expand Up @@ -1542,18 +1542,15 @@ def gui_update_label_for_run_config(self):
current_config = self.force_run_type
if current_config == ForceRunType.NONE:
self.suite_dir_struct_info.set_markup(
"A 'Tests' directory will be created in each run directory.\n" +
" Comparison results will be in run directory 1."
"A 'Tests' dir will be created in each run directory. Comparison results will be in run dir 1."
)
elif current_config == ForceRunType.DD:
self.suite_dir_struct_info.set_markup(
"A 'Tests-DDOnly' directory will be created in each run directory.\n" + # TODO: Clean this out
" Comparison results will be in run directory 1."
"A 'Tests-DDOnly' dir will be created in each run directory. Comparison results will be in run dir 1."
)
elif current_config == ForceRunType.ANNUAL:
self.suite_dir_struct_info.set_markup(
"A 'Tests-Annual' directory will be created in each run directory.\n" +
" Comparison results will be in run directory 1."
"A 'Tests-Annual' dir will be created in each run directory. Comparison results will be in run dir 1."
)
else:
pass # gonna go ahead and say this won't happen
Expand Down
2 changes: 1 addition & 1 deletion epregressions/tests/builds/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from epregressions.builds.base import BaseBuildDirectoryStructure


class TestBaseWorkflowMethods(unittest.TestCase):
class TestBaseBuildMethods(unittest.TestCase):

def setUp(self):
self.base_build = BaseBuildDirectoryStructure()
Expand Down
Loading

0 comments on commit 4cc8460

Please sign in to comment.