Selaa lähdekoodia

fixup of a sad bug in the emission tester python, it would accept as false positive tests with swapped lines. (meaning if two lines A; B; are emitted, and the test.txt contains "B ; A ;" it would still be green). The problem was due to slicing the input string using relative values instead of absolute. Fixed using += operator. Debugging printf still present for history.

Signed-off-by: Vivien Oddou <[email protected]>
Vivien Oddou 2 vuotta sitten
vanhempi
commit
091748bc8d
3 muutettua tiedostoa jossa 10 lisäystä ja 4 poistoa
  1. 1 1
      tests/Emission/Variants.txt
  2. 3 2
      tests/Emission/option-range.txt
  3. 6 1
      tests/testhelper.py

+ 1 - 1
tests/Emission/Variants.txt

@@ -1,6 +1,6 @@
 # list lines expected to have tokens matching the patterns in the strings. each space is a separation.
 
 "enum class QualityT { Low , Medium , High , } ;"
-"enum ColorT { Red , Green , Blue , } ;"
 "static const :: QualityT Quality = GetShaderVariantKey_Quality ( ) ;"
+"enum ColorT { Red , Green , Blue , } ;"
 "static const :: ColorT Color = GetShaderVariantKey_Color ( )  ;"

+ 3 - 2
tests/Emission/option-range.txt

@@ -17,9 +17,9 @@
 "uint shaderKey = ( ( :: SRG_SRGConstantBuffer . SRG_m_SHADER_VARIANT_KEY_NAME_ [0] . x > > 0 ) & 1 ) + 10 ;"
 "return ( int16_t ) shaderKey ;"
 ":: E GetShaderVariantKey_o_s2 ( )"
-"SRG_m_SHADER_VARIANT_KEY_NAME_ [0] . x > > 1 ) & 1 ) + :: v"
+"SRG_m_SHADER_VARIANT_KEY_NAME_ [0] . x > > 1 ) & 1 ) + ( uint ) :: v"
 "GetShaderVariantKey_o_s3"
-"x > > 2 ) & 1 ) + :: F :: v ;"
+"x > > 2 ) & 1 ) + ( uint ) :: F :: v ;"
 "GetShaderVariantKey_o_s4"
 "x > > 3 ) & 3 ) ;"
 "switch ( shaderKey )"
@@ -28,3 +28,4 @@
 "case 2: shaderKey = ( :: G ) :: gv3 ; break ;"
 "} ;"
 "return ( :: G ) shaderKey ;"
+":: Empty val = ( :: Empty ) 1 ;"

+ 6 - 1
tests/testhelper.py

@@ -37,10 +37,15 @@ def found(needle, haystack, negative):
     pttrn = "\s+".join(words) # free number of spaces between each needle.
     p = re.compile(pttrn)
     consumed = haystack[lastEnd:]  # we search on the rest only. not the whole string at each time.
+    #print("consumed is", fg.YELLOW, f"{consumed[:80]}...{consumed[-20:]}", fg.RESET)
     matchObject = p.search(consumed)
     if matchObject:
-        lastEnd = matchObject.end()
+        lastEnd += matchObject.end()
+        #print(f"found {fg.MAGENTA} {matchObject} {fg.RESET} last end updated to {lastEnd}")
+        #print(f"verification: consumed[span]={fg.GREEN}{consumed[matchObject.start():matchObject.end()]}{fg.RESET}\n")
         return not negative
+    #else:
+        #print(f"searched pattern was {fg.RED}{pttrn}{fg.RESET}\n")
     return negative
 
 # parse the argument mentioned in the shader source file Ex : Cmdargs: --namespace=vk   or Cmdargs: ['--unique-idx', '--root-sig', '--root-const', '0']