diff --git a/buildingspy/development/regressiontest.py b/buildingspy/development/regressiontest.py index 1deb9451..0e8bb110 100644 --- a/buildingspy/development/regressiontest.py +++ b/buildingspy/development/regressiontest.py @@ -287,6 +287,7 @@ def __init__( self._statistics_log = "statistics.json" self._nPro = multiprocessing.cpu_count() self._batch = False + self._createNewReferenceResultsInBatchMode = False self._pedanticModelica = False # Number of data points that are used @@ -510,15 +511,18 @@ def showGUI(self, show=True): self._showGUI = show return - def batchMode(self, batchMode): + def batchMode(self, batchMode, createNewReferenceResultsInBatchMode: bool = False): """ Set the batch mode flag. :param batchMode: Set to ``True`` to run without interactive prompts and without plot windows. + :param createNewReferenceResultsInBatchMode: Set to ``True`` to create + new results in batch mode. Default is False. By default, the regression tests require the user to respond if results differ from previous simulations. This method can be used to run the script in batch mode, suppressing all prompts that require - the user to enter a response. If run in batch mode, no new results will be stored. + the user to enter a response. + By default, if run in batch mode, no new results will be stored. To run the regression tests in batch mode, enter >>> import os @@ -529,6 +533,7 @@ def batchMode(self, batchMode): """ self._batch = batchMode + self._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode def pedanticModelica(self, pedanticModelica): """ Set the pedantic Modelica mode flag. @@ -2814,8 +2819,13 @@ def _checkReferencePoints(self, ans): noOldResults = noOldResults + list(pai.keys()) if self._batch: - self._reporter.writeError( - f"Reference file {refFilNam} does not yet exist. You need to generate it by running tests in non-batch mode.") + if self._createNewReferenceResultsInBatchMode: + updateReferenceData = True + else: + self._reporter.writeError( + f"Reference file {refFilNam} does not yet exist. " + f"You need to generate it by running tests in non-batch mode." + ) if not (self._batch or ans == "Y" or ans == "N"): if t_ref is None: