소스 검색

fix a flaw where the first occurence didn't have to appear to pass the test.

Signed-off-by: Vivien Oddou <[email protected]>
Vivien Oddou 2 년 전
부모
커밋
233c8b685f
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      tests/Advanced/respect-emit-preprocessor-line-directives.py

+ 5 - 3
tests/Advanced/respect-emit-preprocessor-line-directives.py

@@ -29,17 +29,19 @@ def validateFilesAppearInLineDirectives(hlslContent, fileList, silent):
     """
     regexp = re.compile('#\s*line\s+\d+\s*"(.*)"$')
     hlslLines = hlslContent.splitlines()
+    found0 = False
     for hlslLine in hlslLines:
         m = regexp.match(hlslLine)
         if not m:
             continue
         f0 = m.group(1).endswith(fileList[0])  # check top of stack
-        f1 = False if len(fileList) <= 1 else m.group(1).endswith(fileList[1]) # or second position to allow progression in the list
+        f1 = len(fileList) > 1 and m.group(1).endswith(fileList[1]) # or second position to allow progression in the list
         if f0 or f1:
-            if f1: del fileList[0]  # forget about a file only after its potential repetition is finished
+            if found0 and f1: del fileList[0]  # forget about a file only after its potential repetition is finished
             if len(fileList) == 0:
                 break;
-        else: print(fg.RED + f"problem: was expecting to find {fileList[0]} or {fileList[1]}" + fg.RESET)
+            found0 = f0
+        else: print(fg.RED + f"problem: was expecting to find {fileList[0]} or {fileList[1]} (but got {m.group(1).rsplit('/',1)[-1]})" + fg.RESET)
     return len(fileList) <= 1
 
 def testSampleFileCompilationEmitsPreprocessorLineDirectives(theFile, compilerPath, silent):