11import os
2+ from e3 .testsuite .result import FailureReason
23
34from drivers .base_driver import BaseDriver
45
@@ -21,6 +22,7 @@ class InterpreterDriver(BaseDriver):
2122
2223 perf_supported = True
2324 flag_checking_supported = False
25+ lkt_output = None
2426
2527 def base_args (self ):
2628 return self .lkql_exe
@@ -41,6 +43,26 @@ def build_args(self, script_path):
4143 return args
4244
4345
46+ def compute_failures (self ):
47+ filename , baseline , is_regexp = self .baseline
48+
49+ # Normal test
50+ result = self .compute_diff (filename , baseline , self .output .log )
51+
52+ # Lkt Refactor test
53+ if self .lkt_output :
54+ result += self .compute_diff (
55+ None ,
56+ baseline ,
57+ self .lkt_output ,
58+ failure_message = "execution after refactor TO_LKQL_V2: unexpected output"
59+ )
60+
61+ if result :
62+ self .result .failure_reasons .add (FailureReason .DIFF )
63+
64+ return result
65+
4466 def run (self ) -> None :
4567
4668 lkql_path = [
@@ -53,10 +75,7 @@ def run(self) -> None:
5375 # This way we can compare the results of the rewritten script
5476 # with the original
5577 if self .test_env .get ('lkt_refactor' , False ):
56- self .output += 'lkql to lkt\n '
57- self .output += '===========\n '
58-
59- # Translate "script.lkql" to "refactored.lkt"
78+ # Translate "script.lkql" to "refactored.lkql"
6079 refactored_file_path = self .working_dir ('refactored.lkql' )
6180 with open (refactored_file_path , 'w' ) as file :
6281 file .write (self .shell (
@@ -65,11 +84,13 @@ def run(self) -> None:
6584 ).out )
6685
6786 # Run test on refactored script
68- self .check_run (self .build_args (refactored_file_path ), lkql_path = os .pathsep .join (lkql_path ))
87+ lkt_result = self .check_run (
88+ self .build_args (refactored_file_path ),
89+ lkql_path = os .pathsep .join (lkql_path ),
90+ analyze_output = False
91+ )
6992
70- self .output += '\n '
71- self .output += 'lkql run\n '
72- self .output += '========\n '
93+ self .lkt_output = lkt_result .out
7394
7495 # Run the interpreter
7596 self .check_run (self .build_args ('script.lkql' ), lkql_path = os .pathsep .join (lkql_path ))
0 commit comments