Skip to content

test runner: the native expect-stdout path silently drops every //! args: flag it does not recognize (a fixture with --emit-c --bundle-corpus passed without exercising either) #1048

Closed

Description

@ehartford

Observed

A behavior fixture headed

//! expect-stdout: captured ok
//! args: --emit-c --bundle-corpus std/re

passed against a compiler in which with build -g0 -o out --emit-c --bundle-corpus std/re <fixture> — the exact argv run_test_compiler_command builds — fails with shadowing is not allowed for 'stderr'. The expect-stdout path never runs that command: run_test_file_with_build_settings* compiles in-process and reads the header args only by name — -O0..-O3, --prelude=*/--no-prelude, --no-std, --alloc (src/main.w:3667-3678, 3839) — and every other flag is dropped without a word. //! args: reaches the compiler argv only on the check/build directive paths (expect-check-fail, expect-build-fail, expect-check-stdout, check-only; src/main.w:3584).

So a run-mode fixture can claim to test --emit-c, --bundle-corpus, --overflow=wrap, --debug-alloc, any --dump-*, and test nothing. That is the silent-fallback class: the tool said "ok" while the thing under test never ran. test/behavior/emit_c_corpus_body_imports_stay_private.w is check-only for this reason.

Expected

One of:

  1. The native run path refuses a header arg it cannot apply (error: //! args: '--emit-c' has no effect on the run path; use check-only or expect-build-fail), so a vacuous fixture is a red test, not a green one.
  2. The run path honors the flags by running the same build argv the directive paths use (with -o and the captured binary) whenever an arg outside the known set appears — then --emit-c fixtures would exercise the C backend end to end.

(1) is the small fix and closes the blind spot; (2) is the feature. with test --emit-c (the CLI flag, opts.emit_c_mode) is set at src/main.w:398 and read nowhere in the runner — the same gap from the other side.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced.

    $ cat behav_args_probe.w
    //! expect-stdout: hi
    //! args: --no-such-flag-1048
    fn main:
        print("hi")
    $ with test behav_args_probe.w
    hi
    ok: 1 test passed in behav_args_probe.w
    

    Related finding: with build also accepts the unknown flag in either position with rc 0, while with check refuses it (error: unknown option --no-such-flag-1048 for with check).

    pre-release: a test passes without exercising what its header asks for; refusing unknown header args is small.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25: the separate finding noted above is filed as #2634.

  3. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by 3f96513 (PR #2674, stack #2678; battery green on the stack top 0008bf2). The commit message names the root-cause line and the regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions