@@ -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
@@ -510,15 +511,18 @@ def showGUI(self, show=True):
510
511
self ._showGUI = show
511
512
return
512
513
513
- def batchMode (self , batchMode ):
514
+ def batchMode (self , batchMode , createNewReferenceResultsInBatchMode : bool = False ):
514
515
""" Set the batch mode flag.
515
516
516
517
:param batchMode: Set to ``True`` to run without interactive prompts
517
518
and without plot windows.
519
+ :param createNewReferenceResultsInBatchMode: Set to ``True`` to create
520
+ new results in batch mode. Default is False.
518
521
519
522
By default, the regression tests require the user to respond if results differ from previous simulations.
520
523
This method can be used to run the script in batch mode, suppressing all prompts that require
521
- the user to enter a response. If run in batch mode, no new results will be stored.
524
+ the user to enter a response.
525
+ By default, if run in batch mode, no new results will be stored.
522
526
To run the regression tests in batch mode, enter
523
527
524
528
>>> import os
@@ -529,6 +533,7 @@ def batchMode(self, batchMode):
529
533
530
534
"""
531
535
self ._batch = batchMode
536
+ self ._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode
532
537
533
538
def pedanticModelica (self , pedanticModelica ):
534
539
""" Set the pedantic Modelica mode flag.
@@ -2814,8 +2819,12 @@ def _checkReferencePoints(self, ans):
2814
2819
noOldResults = noOldResults + list (pai .keys ())
2815
2820
2816
2821
if self ._batch :
2817
- self ._reporter .writeError (
2818
- f"Reference file { refFilNam } does not yet exist. You need to generate it by running tests in non-batch mode." )
2822
+ if self ._createNewReferenceResultsInBatchMode :
2823
+ updateReferenceData = True
2824
+ else :
2825
+ self ._reporter .writeError (
2826
+ f"Reference file { refFilNam } does not yet exist. "
2827
+ f"You need to generate it by running tests in non-batch mode." )
2819
2828
2820
2829
if not (self ._batch or ans == "Y" or ans == "N" ):
2821
2830
if t_ref is None :
0 commit comments