aglinxinyuan opened a new issue, #8401:
URL: https://github.com/apache/texera/issues/8401

   ### Task Summary
   
   `PythonTemplateBuilderSpec`'s exhaustive bad-neighbour test cannot fail.
   
   Its private helper `assertToolboxDoesNotCompile` wraps the snippet in a 
`package org.apache.texera.amber.pybuilder { ... }` clause before handing it to 
a runtime `ToolBox`. A ToolBox cannot wrap a `PackageDef` into its synthetic 
`__wrapper` method, so `tb.compile` dies during typer with a bare 
`java.lang.AssertionError: assertion failed: method wrapper` for *any* input — 
the empty string included. The helper's `intercept[Throwable]` therefore 
succeeds unconditionally. (`tb.parse` on the same input succeeds; only 
`tb.compile` dies, and it dies before macro expansion.)
   
   The helper is used twice inside the test that iterates the `isBadNeighbor` 
subset of printable ASCII (65 characters, left- and right-adjacency each). All 
130 assertions pass without the `pyb` macro ever expanding, so the exhaustive 
sweep pins nothing at all. Four single-case adjacency tests elsewhere in the 
same file use ScalaTest's own `assertDoesNotCompile` and are unaffected — three 
of them do genuinely pin the compile-time neighbour arms — but no per-character 
behaviour is covered.
   
   Two further problems in the same test:
   
   - It derives its input character set from `PythonLexerUtils.isBadNeighbor`, 
the very predicate it claims to pin. Shrinking the predicate silently shrinks 
the sweep instead of failing it. (`PythonLexerUtilsSpec` does not close the gap 
either: it only samples the predicate with `'`, `"`, `a`, `Z`, `0`, `_` and two 
negatives.)
   - Its `scalaUnicodeEscape` helper emits `\\u0041` — two backslashes — into 
the generated source, and nothing rewrites that inside the generated 
triple-quoted literal. Compiling the same snippet as a block shows what the 
macro actually sees: the neighbour is the digit `1`, never `A`. So even with a 
working helper the sweep would have fed the same wrong neighbour for all 65 
characters.
   
   Rebuild the test on the technique `BoundaryValidatorSpec` already uses and 
documents: compile a *block*, not a package clause, and assert on the captured 
`ToolBoxError` message to tell a `validateCompileTime` abort (which carries the 
specific boundary reason) apart from a benign expansion whose only failure is 
the `private[amber]` `fromInterpolated` access error. Require the specific 
reason and the specific character per case, add the discriminating direction 
(safe-neighbour characters must produce the benign outcome), and spell the 
character sets out instead of deriving them. Delete the trap helpers so they 
cannot be reused.
   
   Test-only change; no production behaviour is involved.
   
   ### Task Type
   
   - [x] Refactor / Cleanup
   
   ### Was this issue authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to