Repository navigation
Conversation
A test that is correct but that an implementation does not pass yet had two places to go: a proposed/ directory the runner never scans, so the test runs nowhere and nothing tells anyone when the implementation is fixed, or a draft pull request. Give it a third, the way pytest's xfail does. A test file's leading comment block may carry # conformance: xfail(rs, reason="openjd-rs accepts this at check time") naming the implementations it applies to (py for openjd-cli, rs for the openjd-rs CLI). The test still runs. For a named implementation a failure is reported as XFAIL and does not fail the run; a pass is XPASS and fails the run, so the marker comes out in the change that fixes the implementation. strict=false reports an XPASS without failing the run. A '# conformance:' line that is not a well-formed marker fails the test, so a typo cannot turn a marker off. The runner applies the markers for --implementation py|rs. By default it detects which openjd is on PATH (the Rust CLI's help says 'Open Job Description CLI (Rust)'; openjd-cli's --version says 'Open Job Description CLI'), and when it cannot tell it says so and applies none, so a run behaves as before. --implementation none ignores markers. The summary line adds xfailed and xpassed counts when there are any. Unchanged: every existing test's result. Verified on mainline 2023-09 with openjd-cli (1284 passed, 70 failed, as before the change) and with the openjd-rs CLI at bfa02c2 (1354 passed, 0 failed, as before). The marker parser was exercised with a scratch suite: an xfail that fails (XFAIL), a strict and a non-strict XPASS, an unknown marker name, an unknown implementation, a missing reason, and a marker after the first YAML line (ignored). Signed-off-by: David Leong <leongdl@amazon.com>
An independent review (CONFIRMED by runs) found:
- A template file that is not valid UTF-8 stopped the whole run with a
UnicodeDecodeError, where mainline reports one failed test. The marker
reader now opens files with errors='replace', so the CLI decides as before.
- A UTF-8 byte-order mark hid every marker in the file. The reader now uses
utf-8-sig.
- Prefix typos ('## conformance:', '# Conformance:', a missing colon) were
silently ignored. Any leading comment line that starts with 'conformance'
(any case, after any number of '#') is now a marker line, and one that is
not exactly '# conformance: xfail(...)' fails the test. No fixture on
mainline has such a line.
- Two markers naming one implementation, an implementation named twice, and
reason= or strict= given twice were accepted silently. Each now fails the
test.
- A strict XPASS failed the run but was not counted in 'failed', so the
summary disagreed with the 'Failed tests' list. It is now counted in both
failed and xpassed.
- Detection had no timeout, and accepted any '--version' output containing
'Open Job Description CLI'. It now times out after 60 seconds and needs the
line to start with that banner.
- A file with '.test.' in a job_templates/ directory would have run as a job
test. Directories decide again, as on mainline; single-file mode still uses
the '.test.yaml' suffix.
- The README said '--implementation none' ignores every marker; a malformed
marker fails its test in every mode, and the README now says so.
Verified: mainline 2023-09 with openjd-cli 1284 passed, 70 failed and with the
openjd-rs CLI 1354 passed, 0 failed, the per-test lines identical to the
mainline runner's. A scratch suite covers BOM, non-UTF-8, each prefix typo,
duplicates, strict and non-strict XPASS, and a marker after the first YAML
line.
Signed-off-by: David Leong <leongdl@amazon.com>
A second independent review found no blockers and these low findings, each confirmed by a run: - On Python 3.10 a NUL byte in a marker line raised an uncaught ValueError from ast.parse, and a 100,000-character marker raised MemoryError. The parser now turns ValueError into a bad-marker failure and refuses a marker over 1000 characters before parsing it. - An ordinary comment such as '# Conformance test for section 2.1' failed its test. A marker line is now one whose text starts with 'conformance:' or that names both 'conformance' and 'xfail', so prose is left alone and the typos the first review found are still caught. - --implementation's help still said 'none (ignore markers)'. It now says a malformed marker still fails its test. - A strict XPASS was counted in both failed and xpassed, so the counts summed to more than the tests run. It now counts as failed only, as in pytest; a non-strict XPASS counts as xpassed. - README wording now matches the matcher and says an XFAIL accepts a failure of any kind. Verified with the scratch suite on Python 3.10 and 3.12; the counts sum to the tests run. Signed-off-by: David Leong <leongdl@amazon.com>
Fixture tasks are python programs, and on Windows a child python writing to a pipe encodes with the locale code page (cp1252). Fixtures that print a non-ASCII sentinel then fail on Windows whatever the CLI does: the CLI reads cp1252 bytes, so the expected UTF-8 text never appears. expr2.2.4--case-transforms-unicode and expr2.2.4--padding-unicode (in OpenJobDescription#231) fail this way on the Windows Rust job. Set PYTHONUTF8=1 for every child the runner starts, unless the caller set it. This is the environment half of OpenJobDescription#159's runner change; the explicit file and subprocess encodings it also adds are already on this branch. Signed-off-by: David Leong <leongdl@amazon.com>
| # Windows, a child python writing to a pipe encodes with the locale code page | ||
| # (cp1252) unless told otherwise, so the CLI under test reads bytes that are | ||
| # not UTF-8. Put every child in UTF-8 mode. (From #159.) | ||
| os.environ.setdefault("PYTHONUTF8", "1") |
There was a problem hiding this comment.
Nit: Setting PYTHONUTF8=1 in os.environ applies to every child process. That includes the openjd CLI under test, not only the fixture tasks. When openjd-cli (Python) is the implementation, UTF-8 mode changes its default open() encoding and its stdio encoding.
This can hide a real defect. If openjd-cli on Windows reads a template with the locale code page, run_check on a repository template that contains non-ASCII UTF-8 would fail without this setting. With it, the check passes and the conformance suite misses the bug.
Fix: pass the variable only to the task processes. If that isn't possible, document it as a requirement of the test environment rather than setting it silently. This change is also unrelated to the xfail feature and could go in its own PR.
|
Claude review · advisory Reviewed Open: 0 blocking · 0 should-fix · 1 nit. ✅ Nothing blocking. Fix or reply to each thread; the next revision's review re-checks open threads and resolves those it agrees are handled. Resolving a thread yourself also closes it. Later revisions review only what changed. |
Stacked on #234. Review the last commit (+7 lines).
Fixture tasks are python programs. On Windows, a child python writing to a pipe encodes with the locale code page (cp1252), so a fixture that prints a non-ASCII sentinel fails there whatever the CLI does.
expr2.2.4--case-transforms-unicodeandexpr2.2.4--padding-unicode(in #231) fail this way on the Windows Rust job (Missing expected output: UP_EACUTE:É) and pass on Ubuntu and macOS.The runner now sets
PYTHONUTF8=1for every child it starts, unless the caller already set it. This is the environment half of #159's runner change; the explicit file and subprocess encodings #159 also adds are already in #234.Merge before #231.