Skip to content

Commit

Permalink
Add pyinstaller back in purely for unit tests, clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Nov 18, 2022
1 parent 0136784 commit 1e74606
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
45 changes: 28 additions & 17 deletions epregressions/tests/test_runtests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import json
import os
from pathlib import Path
from platform import system
import shutil
from subprocess import check_call
from sys import executable
import tempfile
from time import sleep
import unittest

from epregressions.builds.makefile import CMakeCacheMakeFileBuildDirectory
Expand Down Expand Up @@ -42,24 +45,32 @@ def establish_build_folder(
# variables and run them all. Also, we don't want to run them for every single test, just once if the dist/
# folder hasn't been created yet.
dist_folder = os.path.join(self.resources, 'dist')
if not os.path.exists(dist_folder):
# find pyinstaller -- it should be available in path I think
pyinstaller = "pyinstaller.exe"
# pyinstaller = r"C:\EnergyPlus\repos\EnergyPlusRegressionTool\venv\Scripts\pyinstaller.exe"
# run it on all these
conversions = [
['dummy.basement.py', 'basement'],
['dummy.energyplus.py', 'energyplus'],
['dummy.expandobjects.py', 'expandobjects'],
['dummy.parametric.py', 'parametric'],
['dummy.readvars.py', 'readvars'],
['dummy.slab.py', 'slab'],
['dummy.epmacro.py', 'epmacro'],
]
working_dir = self.resources
for conv in conversions:
cmd = [pyinstaller, '--onefile', '--log-level=WARN', '-n', conv[1], conv[0]]
# find pyinstaller next to the python binary
pyinstaller_path = Path(executable).resolve().parent / 'pyinstaller.exe'
pyinstaller = str(pyinstaller_path)
# pyinstaller = r"C:\EnergyPlus\repos\EnergyPlusRegressionTool\venv\Scripts\pyinstaller.exe"
# run it on all these
conversions = [
['dummy.basement.py', 'basement'],
['dummy.energyplus.py', 'energyplus'],
['dummy.expandobjects.py', 'expandobjects'],
['dummy.parametric.py', 'parametric'],
['dummy.readvars.py', 'readvars'],
['dummy.slab.py', 'slab'],
['dummy.epmacro.py', 'epmacro'],
]
working_dir = self.resources
for conv in conversions:
if os.path.exists(os.path.join(dist_folder, conv[1] + ".exe")):
continue
cmd = [pyinstaller, '--onefile', '--log-level=WARN', '-n', conv[1], conv[0]]
try:
check_call(cmd, cwd=working_dir)
sleep(2)
except Exception as e:
print("cmd: " + ', '.join(cmd))
print("Working dir: " + working_dir)
print("Error: " + str(e))
products_map = {
os.path.join(self.resources, 'dummy.basement.idd'): os.path.join(products_dir, 'BasementGHT.idd'),
os.path.join(dist_folder, 'basement.exe'): os.path.join(products_dir, 'Basement.exe'),
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ coveralls==2.1.2
flake8==3.8.4
nose==1.3.7

# on windows, we need pyinstaller specifically for unit tests, not a part of the install requirements
pyinstaller; platform_system == "Windows"

# to generate documentation
Sphinx==3.2.1
docutils==0.16 # pinning this because it breaks at 0.18
Expand Down

0 comments on commit 1e74606

Please sign in to comment.