12
12
import sys
13
13
import tempfile
14
14
from collections .abc import Callable , Iterable
15
+ from typing import Final
15
16
16
17
reOPT = re .compile (r"^opt([0-9]+)_" ) # To detect -On tests
17
18
reBIN = re .compile (r"^(?:.*/)?(tzx|tap)_.*" ) # To detect tzx / tap test
39
40
import src .api .utils # noqa
40
41
from src import zxbasm , zxbc , zxbpp # noqa
41
42
43
+ DEFAULT_TIMEOUT : Final [int ] = 3 # Default test timeout in seconds
44
+
42
45
# global FLAGS
43
46
CLOSE_STDERR = False # Whether to show compiler error or not (usually not when doing tests)
44
47
PRINT_DIFF = False # Will show diff on test failure
51
54
STDERR : str = ""
52
55
INLINE : bool = True # Set to false to use system Shell
53
56
RAISE_EXCEPTIONS = False # True if we want the testing to abort on compiler crashes
54
- TIMEOUT = 3 # Max number of seconds a test should last
57
+ TIMEOUT = DEFAULT_TIMEOUT # Max number of seconds a test should last
55
58
56
59
_timeout = lambda : TIMEOUT
57
60
@@ -604,6 +607,7 @@ def main(argv=None):
604
607
global TIMEOUT
605
608
606
609
COUNTER = FAILED = EXIT_CODE = 0
610
+ TIMEOUT = DEFAULT_TIMEOUT
607
611
608
612
parser = argparse .ArgumentParser (description = "Test compiler output against source code samples" )
609
613
parser .add_argument ("-d" , "--show-diff" , action = "store_true" , help = "Shows output difference on failure" )
@@ -626,6 +630,12 @@ def main(argv=None):
626
630
action = "store_true" ,
627
631
help = "If an exception is raised (i.e." "the compiler crashes) the testing will " "stop with such exception" ,
628
632
)
633
+ parser .add_argument (
634
+ "--timeout" ,
635
+ type = int ,
636
+ default = TIMEOUT ,
637
+ help = f"Sets test timeout in seconds. Default is { TIMEOUT } . Set 0 to disable." ,
638
+ )
629
639
args = parser .parse_args (argv )
630
640
631
641
STDERR = args .stderr
@@ -643,6 +653,7 @@ def main(argv=None):
643
653
PRINT_DIFF = args .show_diff
644
654
VIM_DIFF = args .show_visual_diff
645
655
UPDATE = args .force_update
656
+ TIMEOUT = args .timeout
646
657
647
658
if VIM_DIFF :
648
659
TIMEOUT = 0 # disable timeout for Vim-dif
0 commit comments