1- import logging
21import os
3- import traceback
42
5- from e3 .fs import sync_tree
63from e3 .os .fs import df
74from e3 .os .process import Run
8- from e3 .testsuite .driver import TestDriver
9- from e3 .testsuite .result import Log , TestStatus
5+ from e3 .testsuite .control import TestControlCreator , YAMLTestControlCreator
6+ from e3 .testsuite .driver .classic import ClassicTestDriver , ProcessResult
7+ from e3 .testsuite .result import Log
108
11- from drivers .gnatcov import GNATcov
12-
13-
14- TESTSUITE_ROOT_DIR = os .path .dirname (
15- os .path .dirname (os .path .abspath (__file__ )))
9+ TESTSUITE_ROOT_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
1610
1711PACKAGE_ROOT_DIR = os .path .dirname (TESTSUITE_ROOT_DIR )
1812
1913
20- class ALSTestDriver (TestDriver ):
14+ class ALSTestDriver (ClassicTestDriver ):
2115 """Abstract class to share some common facilities."""
2216
23- def add_test (self , dag ):
24- """
25- Default workflow for testcases.
17+ @property
18+ def test_control_creator (self ) -> TestControlCreator :
19+ eval_env = {
20+ "env" : self .env ,
21+ "test_env" : self .test_env ,
22+ "disk_space" : lambda : df (self .env .working_dir ),
23+ }
2624
27- Subclasses are free to override this if they need anything more
28- complicated.
29- """
30- self .add_fragment (dag , 'prepare' )
31- self .add_fragment (dag , 'run' , after = ['prepare' ])
25+ return YAMLTestControlCreator (eval_env )
3226
33- def prepare (self , previous_values , slot ):
34- """
35- Create the working directory to be a copy of the test directory.
36- """
37- sync_tree (self .test_env ['test_dir' ],
38- self .test_env ['working_dir' ])
39-
40- def should_skip (self ):
41- """Handle of 'skip' in test.yaml.
27+ def shell (self , * args , ** kwargs ) -> ProcessResult :
28+ if self .env .gnatcov :
29+ kwargs = self .env .gnatcov .decorate_run (self , kwargs )
4230
43- If the test should be skipped according to test.yaml, push the result
44- and return True. Otherwise, just return false.
45- """
46- status = None
47- if 'skip' in self .test_env :
48- eval_env = {
49- 'env' : self .env ,
50- 'test_env' : self .test_env ,
51- 'disk_space' : lambda : df (self .env .working_dir )}
52-
53- for candidate_status , expr in self .test_env ['skip' ]:
54- try :
55- if eval (expr , eval_env ):
56- status = TestStatus [candidate_status ]
57- break
58- except Exception :
59- logging .error (traceback .format_exc ())
60- status = TestStatus .ERROR
61- break
62-
63- if status is None :
64- return False
65- else :
66- self .result .set_status (status )
67- self .push_result ()
68- return True
31+ return super ().shell (* args , ** kwargs )
6932
7033 def run_and_log (self , cmd , ** kwargs ):
7134 """
@@ -83,11 +46,14 @@ def run_and_log(self, cmd, **kwargs):
8346
8447 process = Run (cmd , ** kwargs )
8548
86- self .result .processes .append ({
87- 'cmd' : cmd ,
88- 'run_args' : kwargs ,
89- 'status' : process .status ,
90- 'output' : Log (process .out )})
49+ self .result .processes .append (
50+ {
51+ "cmd" : cmd ,
52+ "run_args" : kwargs ,
53+ "status" : process .status ,
54+ "output" : Log (process .out ),
55+ }
56+ )
9157
9258 if "Log:" in process .out :
9359 output , log = process .out .split ("Log:" )
0 commit comments