Skip to content

Commit

Permalink
Patch color output (#466)
Browse files Browse the repository at this point in the history
* Corrected comparison of values

* Disabled color output on Windows as the color character are not supported
  • Loading branch information
mwetter authored Jan 26, 2022
1 parent a36a478 commit 544f750
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions buildingspy/development/regressiontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Tester(object):
:param skip_verification: Boolean (default ``False``).
If ``True``, unit test results are not verified against reference points.
:param color: Boolean (default ``False``).
If ``True``, command line output will be in color.
If ``True``, command line output will be in color (ignored on Windows).
This class can be used to run all regression tests.
Expand Down Expand Up @@ -249,6 +249,8 @@ def __init__(
skip_verification=False,
color=False
):
import platform

""" Constructor."""
if tool == 'optimica':
e = error_dictionary_optimica
Expand Down Expand Up @@ -364,8 +366,8 @@ def __init__(
# By default, do not show the GUI of the simulator
self._showGUI = False

# Enable or disable colored output
if color:
# Enable or disable colored output on non-windows
if color and (platform.system() != "Windows"):
self._color_BOLD = '\033[1m'
self._color_OK = '\033[1;32m'
self._color_GREY = '\033[90m'
Expand Down Expand Up @@ -555,9 +557,11 @@ def getModelicaCommand(self):
:return: The name of the modelica executable.
"""
import platform

if self._modelica_tool == 'openmodelica':
# get the executable for omc, depending on platform
if sys.platform == 'win32':
if platform.system() == "Windows":
try:
omc = os.path.join(env['OPENMODELICAHOME'], 'bin', 'omc')
except KeyError:
Expand Down Expand Up @@ -3121,11 +3125,10 @@ def _print_end_of_json(isLastItem, fileHandle, logFileName):
posDDE = "9" # At position 9 DDE settings should be stored.
runFil.write(f"""
// Deactivate DDE
(comp, sett) = GetDymolaCompiler();\n')
DDE_orig = sett[{posDDE}];
sett[{posDDE}] = \"DDE=0\"; // Disable DDE
SetDymolaCompiler(comp, sett);
(comp, sett) = GetDymolaCompiler();
DDE_orig = sett[{posDDE}];
sett[{posDDE}] = \"DDE=0\"; // Disable DDE
SetDymolaCompiler(comp, sett);
""")
runFil.write('cd(\"{}/{}\");\n'.format(
(self._temDir[iPro]).replace("\\", "/"),
Expand Down

0 comments on commit 544f750

Please sign in to comment.