1919import shutil
2020import subprocess
2121
22+ from typing import List , Optional
23+
24+ from hvcc .interpreters .pd2hv .NotificationEnum import NotificationEnum
2225from tests .framework .base_test import HvBaseTest
2326
2427
2528class TestPdControlBase (HvBaseTest ):
2629
2730 def compile_and_run (
2831 self ,
29- source_files ,
30- out_dir ,
31- num_iterations ,
32- flag = None
33- ):
32+ source_files : List [ str ] ,
33+ out_dir : str ,
34+ num_iterations : int ,
35+ flag : Optional [ str ] = None
36+ ) -> List [ str ] :
3437 exe_path = self ._compile_and_run (source_files , out_dir , flag )
3538
3639 # run executable (returns stdout)
@@ -41,21 +44,34 @@ def compile_and_run(
4144
4245 return [x .decode ('utf-8' ) for x in output ]
4346
44- def create_fail_message (self , result , golden , flag = None ):
47+ def create_fail_message (
48+ self ,
49+ result : str ,
50+ golden : str ,
51+ flag : Optional [str ] = None
52+ ) -> str :
4553 return "\n Result ({0})\n -----------\n {1}\n \n Golden\n -----------\n {2}" .format (
4654 flag or "" ,
4755 "\n " .join (result ),
4856 "\n " .join (golden ))
4957
50- def _test_control_patch_expect_error (self , pd_file , expected_enum ):
58+ def _test_control_patch_expect_error (
59+ self ,
60+ pd_file : str ,
61+ expected_enum : NotificationEnum
62+ ) -> None :
5163 pd_path = os .path .join (self .TEST_DIR , pd_file )
5264
5365 try :
5466 self ._run_hvcc (pd_path , expect_fail = True , expected_enum = expected_enum )
5567 except Exception as e :
5668 self .fail (str (e ))
5769
58- def _test_control_patch_expect_warning (self , pd_file , expected_enum ):
70+ def _test_control_patch_expect_warning (
71+ self ,
72+ pd_file : str ,
73+ expected_enum : NotificationEnum
74+ ) -> None :
5975 # setup
6076 pd_path = os .path .join (self .TEST_DIR , pd_file )
6177
@@ -64,7 +80,13 @@ def _test_control_patch_expect_warning(self, pd_file, expected_enum):
6480 except Exception as e :
6581 self .fail (str (e ))
6682
67- def _test_control_patch (self , pd_file , num_iterations = 1 , allow_warnings = True , fail_message = None ):
83+ def _test_control_patch (
84+ self ,
85+ pd_file : str ,
86+ num_iterations : int = 1 ,
87+ allow_warnings : bool = True ,
88+ fail_message : Optional [str ] = None
89+ ) -> None :
6890 """Compiles, runs, and tests a control patch.
6991 Allows warnings by default, always fails on errors.
7092 @param fail_message An optional message displayed in case of test failure.
0 commit comments