Skip to content

Conversation

@ericvergnaud
Copy link
Contributor

Fixes #6247

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice work, lgtm aside from one suggestion.

const char* exportName,
const char** segments,
bool* segmentPassive,
const char** segmentNames,
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could allow segmentNames to be NULL, and then we autogenerate the names? That's much simpler for people that don't need the names, equally as simple as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, done.

Copy link
Member

Choose a reason for hiding this comment

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

Please document this change in the comment before this declaration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kripken
Copy link
Member

kripken commented Jan 30, 2024

(looks like there's a CI error too)

@ericvergnaud
Copy link
Contributor Author

ericvergnaud commented Jan 30, 2024

(looks like there's a CI error too)

It comes from code coverage, but I have no clue how this PR's changes can possibly affect the code coverage findings...

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
@kripken
Copy link
Member

kripken commented Jan 30, 2024

Sorry, I didn't mean code coverage (that can be ignored), but the emscripten (JS) build:

https://github.com/WebAssembly/binaryen/actions/runs/7717838024/job/21037807450?pr=6254

@ericvergnaud
Copy link
Contributor Author

Sorry, I didn't mean code coverage (that can be ignored), but the emscripten (JS) build:

https://github.com/WebAssembly/binaryen/actions/runs/7717838024/job/21037807450?pr=6254

It was CodeCov in my initial submission, digging into the latest...

Signed-off-by: Eric Vergnaud <eric.vergnaud@wanadoo.fr>
@ericvergnaud
Copy link
Contributor Author

@kripken the remaining failure in emscripten make no sense to me...
It finds 2 diffs between the kitchen-sink.js output and its expected output.

The first one is:
image
Not sure why it sees a diff between // as being different from // ?! I haven't touched that area at all...

The second one is:
image
Again it sees a diff between 2 lines that are visually equal, and it's an area that I haven't touched at all.

This smells like an encoding issue unrelated to my changes...
Are this repo and the CI configured to deal with line endings ? (see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings)

@ericvergnaud
Copy link
Contributor Author

Looks like I am going to need help...
I tried forcing the update by changing non-whitespace, and then revert that change whilst adding the missing whitespace, to no end.
Git filters out the whitespace-only changes...

@ericvergnaud
Copy link
Contributor Author

I've tried running auto_update_tests.py, but it doesn't regenerate the binaryen.js txt files, maybe because of this line:
skip_by_default = ['binaryenjs']

@ericvergnaud
Copy link
Contributor Author

ok I managed to fix the trailing spaces issue by editing the file using GH web editor...
I've reverted the test harness changes

@kripken
Copy link
Member

kripken commented Feb 1, 2024

Sorry, I should have said, ./scripts/auto_update_tests.py binaryenjs should autoupdate those. (by default binaryenjs is skipped because it's a separate build, that not all devs constantly keep in sync)

try {
m();
} catch(e) {
console.trace();
Copy link
Member

Choose a reason for hiding this comment

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

How helpful is this? The stack trace of the error is on e anyhow, so I'm not sure what this can add here in this catch block, but I'm not familiar with console.trace...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in theory console.trace prints the stack trace of the last raised error, see https://developer.mozilla.org/fr/docs/Web/API/console/trace_static
but it doesn't seem to help much tbh, so I can remove it

Copy link
Member

Choose a reason for hiding this comment

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

Let's remove it then, if there isn't a clear benefit. That stack trace should be printed anyhow by node for an uncaught exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

lgtm % test question

@ericvergnaud
Copy link
Contributor Author

Sorry, I should have said, ./scripts/auto_update_tests.py binaryenjs should autoupdate those. (by default binaryenjs is skipped because it's a separate build, that not all devs constantly keep in sync)

That works but raises the question: what exactly are we testing ? If the generated data is checked against stored data that was actually generated by the same code, it only covers NR testing, but not correctness ? Is that the intent ?

(if we move forward with the merge/TypeScript proposal, I could implement (gradually) a series of granular unit tests that would check for correctness if it makes sense)

@kripken
Copy link
Member

kripken commented Feb 1, 2024

What is "NR" in this context?

Yeah, these particular tests are not "functional" tests, they only compare to "golden" outputs that we trust. That is, during review we carefully verify the updates to the test expectations, and after review and landing, if a later PR would cause a change to the output then a test fails.

We also need functional tests, of course. We get that in other parts of the test suite, by assertions and validation that happen in all tests, and via the fuzzer.

(Are there better terms for these test types?)

@kripken kripken merged commit 2b3a2e8 into WebAssembly:main Feb 1, 2024
@ericvergnaud
Copy link
Contributor Author

"NR" means non-regression.
Yes there are somewhat standard terms, at least in the information system space where I've spent most of my time:

  • unit testing, that check behavior at a granular level: function, class, component
  • integration testing, that ensure consistent behavior of connected components
  • functional testing, that check expected behavior end to end (without caring for state)
  • fuzz testing, that checks for resilience
  • performance testing, self-explanatory
  • acceptance testing, that is normally performed by the business (here it would be binaryen users)
    I suspect binaryen does a bit of all this (except acceptance) but maybe not in a structured way ? Also, the bulk testing approach makes it very difficult to identify what's causing a failure... I suspect that approach is largely driven by the fact that C++ doesn't have an equivalent of JUnit. Since that's easy to implement at the JS/TS level, that would in turn make it easier to locate an issue.

@kripken
Copy link
Member

kripken commented Feb 1, 2024

I see, thanks! I haven't seen enough usage of those terms to internalize them I guess, but most are familiar to me (and the concepts are).

We do all of the above, though performance testing of the compiler itself is not tracked (but the output is), and I guess for acceptance testing it depends how you consider Emscripten (Emscripten is a user of Binaryen and tests it heavily as part of testing itself).

For unit tests we do use gtest in the test/gtest subdir (also the older test/unit/).

@ericvergnaud ericvergnaud deleted the use-segment-names branch February 1, 2024 21:39
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Move from segment indexes to names. This is a breaking change to make the API more
capable and consistent. An effort has been made to reduce the burden on C API users
where possible (specifically, you can avoid providing names and let Binaryen make them
for you, which will basically be numbers that match the indexes from before).

Fixes WebAssembly#6247
@gkdn gkdn mentioned this pull request Aug 31, 2024
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.

API inconsistency with data segments

2 participants