Skip to content

Testing: Add verbose logging feature, and stop excessive spec logging#8684

Open
kripken wants to merge 6 commits intoWebAssembly:mainfrom
kripken:verbose.log
Open

Testing: Add verbose logging feature, and stop excessive spec logging#8684
kripken wants to merge 6 commits intoWebAssembly:mainfrom
kripken:verbose.log

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented May 8, 2026

New logging:

$ ./check.py spec
[ checking wasm-shell spec testcases... ]
Running with 14 workers
.. address-offset-range.fail.wast
.. binary.wast
.. break-drop.wast
.. atomics.wast

Old logging, available with --verbose:

$ ./check.py spec --verbose
[ checking wasm-shell spec testcases... ]
Running with 14 workers
.. address-offset-range.fail.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/address-offset-range.fail.wast
<< test failed as expected >>
.. binary.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/binary.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-binary.transformed
.. break-drop.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/break-drop.wast
        testing split module 0
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-break-drop_split0.wast -O -all -q
         (binary format check)
             /home/azakai/Dev/2-binaryen/bin/wasm-as test-spec-break-drop_split0.wast -o test-spec-break-drop-a.wasm -all -g
             /home/azakai/Dev/2-binaryen/bin/wasm-dis test-spec-break-drop-a.wasm -o test-spec-break-drop-ab.wast -all
             /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-break-drop-ab.wast -all -q
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-break-drop.transformed
.. bulk-array.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/bulk-array.wast
        testing split module 0
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-bulk-array_split0.wast -O -all -q
         (binary format check)
             /home/azakai/Dev/2-binaryen/bin/wasm-as test-spec-bulk-array_split0.wast -o test-spec-bulk-array-a.wasm -all -g
             /home/azakai/Dev/2-binaryen/bin/wasm-dis test-spec-bulk-array-a.wasm -o test-spec-bulk-array-ab.wast -all
             /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-bulk-array-ab.wast -all -q
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-bulk-array.transformed

@kripken kripken requested a review from sbc100 May 8, 2026 17:04
@kripken kripken requested a review from a team as a code owner May 8, 2026 17:04
@kripken kripken requested review from stevenfontanella and removed request for a team May 8, 2026 17:04
@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 8, 2026

If this seems good I would like to improve other test suites than spec as well. Though let's make sure to agree on the best practice here first.

@stevenfontanella
Copy link
Copy Markdown
Member

Looks great to me. Looks like there's no change to the logging if there's a failure, right? i.e. it will still print the same error message as before?

@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 8, 2026

Yes. Example output after I turned a should-be-invalid module into a valid one in e.g. cont-validation.wast:

$ ./check.py spec
[ checking wasm-shell spec testcases... ]
Running with 14 workers
.. address-offset-range.fail.wast
.. binary.wast
.. break-drop.wast
.. atomics.wast
.. br_on_cast_desc_eq.wast
.. br_if.wast
run_command `/home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/cont-validation.wast` failed (1) 0 CHECKING [line: 5]
[wasm-validator error in function 0] unexpected false: ref.test cannot cast to invalid type, on 
(ref.test contref
 (unreachable)
)
1 CHECKING [line: 11]
expected invalid module

Aborted spec test suite execution after first failure. Set --no-fail-fast to disable this.
Failed tests:
.. cont-validation.wast

This is essentially unchanged from before.

@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 8, 2026

Hmm, the import of shared from support seems to break the lit tests... 😞

Comment thread scripts/test/shared.py Outdated
disassembled_file = f"{base_name}-ab.wast" if base_name is not None else "ab.wast"

print(' (binary format check)', file=stdout)
verbose_log(' (binary format check)', file=stdout)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets drop file=stdout in all these calls too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't sys.stdout, we need to thread this through so that the threads can capture the stdout and write it in batches

Copy link
Copy Markdown
Member Author

@kripken kripken May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. edit: raced with comment above, this was for sbc100

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. In that case I think we should perhaps revisit how this works.

If stdout is being captured then its find to print as much as we want there.

I guess the problem is that some of these functions are run both in stdout-capturing and not-stdout-capturing modes?

Would it make more sense for the capturing to be done via global sys.stdout = <buffering_thing> rather than threading this stdout through like this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevenfontanella is that batching necessary? I'm not sure I see a difference after removing it, which, I admit, I did without understanding what it was 😄 - but things seem to work now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its an important part of the parallelism in the spec running I think. You don't want stdout/stderr from the different tests to be interleaved so you need to capture and present it (or hide) atomically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re:

If stdout is being captured then its find to print as much as we want there.

If we want the output to be less verbose, I think we still want the logic to be the same either way? The stdout is captured but still output to the terminal, just in batches.

re:

is that batching necessary?

+1 to Sam, it's still necessary as long as each test may output more than 1 line, which definitely seems to be the case at least in verbose mode after this PR. Maybe you didn't see any interleaving because you weren't running in verbose mode?

re:

Would it make more sense for the capturing to be done via global sys.stdout = <buffering_thing> rather than threading this stdout through like this?

Overwriting sys.stdout isn't quite enough because globals are shared among all threads and we want each thread to have its own buffer. I asked Gemini at one point and it come up with this, that could be a potential thing to look into. Another more clear fix is to move things into classes and just pass in a logging abstraction per-thread.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes I forget, this approach works in emscripten because we use multiprocessing rather than multi-threading. I suppose we could do that here too, although I'm not sure it worth it.

Comment thread scripts/test/support.py Outdated
"Can't redirect stderr if using expected_err"
stderr = subprocess.PIPE
print('executing: ', ' '.join(cmd), file=stdout)
shared.verbose_log('executing: ', ' '.join(cmd), file=stdout)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this one kind of important?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually would like to remove this because of all the noise, but maybe you're right, and it is why the lit tests broke... I removed this part. Output now looks like this:

$ ./check.py spec
[ checking wasm-shell spec testcases... ]
Running with 14 workers
.. address-offset-range.fail.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/address-offset-range.fail.wast
.. binary.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/binary.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-binary.transformed
.. br_on_cast_desc_eq.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/br_on_cast_desc_eq.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-br_on_cast_desc_eq_split0.wast -O -all -q
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-br_on_cast_desc_eq.transformed
.. break-drop.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell /home/azakai/Dev/2-binaryen/test/spec/break-drop.wast
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-opt test-spec-break-drop_split0.wast -O -all -q
executing:  /home/azakai/Dev/2-binaryen/bin/wasm-shell test-spec-break-drop.transformed

This is worse than the lit output, but better than before...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants