@@ -287,6 +287,7 @@ def __init__(
287
287
self ._statistics_log = "statistics.json"
288
288
self ._nPro = multiprocessing .cpu_count ()
289
289
self ._batch = False
290
+ self ._createNewReferenceResultsInBatchMode = False
290
291
self ._pedanticModelica = False
291
292
292
293
# Number of data points that are used
@@ -513,15 +514,18 @@ def showGUI(self, show=True):
513
514
self ._showGUI = show
514
515
return
515
516
516
- def batchMode (self , batchMode ):
517
+ def batchMode (self , batchMode , createNewReferenceResultsInBatchMode : bool = False ):
517
518
""" Set the batch mode flag.
518
519
519
520
:param batchMode: Set to ``True`` to run without interactive prompts
520
521
and without plot windows.
522
+ :param createNewReferenceResultsInBatchMode: Set to ``True`` to create
523
+ new results in batch mode. Default is False.
521
524
522
525
By default, the regression tests require the user to respond if results differ from previous simulations.
523
526
This method can be used to run the script in batch mode, suppressing all prompts that require
524
- the user to enter a response. If run in batch mode, no new results will be stored.
527
+ the user to enter a response.
528
+ By default, if run in batch mode, no new results will be stored.
525
529
To run the regression tests in batch mode, enter
526
530
527
531
>>> import os
@@ -532,6 +536,7 @@ def batchMode(self, batchMode):
532
536
533
537
"""
534
538
self ._batch = batchMode
539
+ self ._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode
535
540
536
541
def pedanticModelica (self , pedanticModelica ):
537
542
""" Set the pedantic Modelica mode flag.
@@ -2819,8 +2824,12 @@ def _checkReferencePoints(self, ans):
2819
2824
noOldResults = noOldResults + list (pai .keys ())
2820
2825
2821
2826
if self ._batch :
2822
- self ._reporter .writeError (
2823
- f"Reference file { refFilNam } does not yet exist. You need to generate it by running tests in non-batch mode." )
2827
+ if self ._createNewReferenceResultsInBatchMode :
2828
+ updateReferenceData = True
2829
+ else :
2830
+ self ._reporter .writeError (
2831
+ f"Reference file { refFilNam } does not yet exist. "
2832
+ f"You need to generate it by running tests in non-batch mode." )
2824
2833
2825
2834
if not (self ._batch or ans == "Y" or ans == "N" ):
2826
2835
if t_ref is None :
0 commit comments