Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasmprinter] support custom indent text #1963

Merged
merged 9 commits into from
Dec 30, 2024
Merged

Conversation

oovm
Copy link
Contributor

@oovm oovm commented Dec 23, 2024

Close #1962

crates/wasmprinter/tests/all.rs Outdated Show resolved Hide resolved
src/bin/wasm-tools/print.rs Show resolved Hide resolved
@oovm
Copy link
Contributor Author

oovm commented Dec 27, 2024

It seems that '\t' is not supported, so I agree to use --indent

;; RUN: print --indent-text '\t' %

---- "tests/cli\\print-custom-indent-text.wat" ----
failed test "tests/cli\\print-custom-indent-text.wat"

Caused by:
    0: failed RUN directive `` on line 1
    1: failed to check stdout expectation (auto-update with BLESS=1)
    2: failed test: result is not as expected:Diff < left / right > :
        (module
       <        (type (;0;) (func (param i32) (result i32)))
       <        (func (;0;) (type 0) (param i32) (result i32)
       <                local.get 0
       <        )
       <        (export "f" (func 0))
       >'/t'(type (;0;) (func (param i32) (result i32)))
       >'/t'(export "f" (func 0))
       >'/t'(func (;0;) (type 0) (param i32) (result i32)
       >'/t''/t'local.get 0
       >'/t')
        )

failures:
    "tests/cli\\print-custom-indent-text.wat"

test result: FAILED. 125 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.92s


Very strange, spaces are not supported either.

;; RUN: print --indent-text "    " %

---- "tests/cli\\print-custom-indent-text.wat" ----
failed test "tests/cli\\print-custom-indent-text.wat"

Caused by:
    0: failed RUN directive `` on line 1
    1: "E:\\RustroverProjects\\wasm-tools\\target\\debug\\wasm-tools.exe" "print" "--indent-text" "\"" "\"" "tests/cli\\print-custom-indent-text.wat" failed:
                    status: exit code: 2
                    stdout:
                    stderr: error: unexpected argument 'tests/cli\print-custom-indent-text.wat' found

@oovm
Copy link
Contributor Author

oovm commented Dec 27, 2024

It seems that run_test has some problems, and does not support strings and escapes, whether it is \t, '\t' or " "

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

@alexcrichton
Copy link
Member

Oh sorry, yes it's ok to not test \t or " " directly, the parser for these tests is pretty primitive. You could also test --indent-text xxxx and that'll assert "xxxx" starts each line

@alexcrichton alexcrichton added this pull request to the merge queue Dec 30, 2024
Merged via the queue into bytecodealliance:main with commit 760a03d Dec 30, 2024
30 checks passed
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.

wasmprinter: make indent character configurable
2 participants