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

test(gnovm): fix TestPackages #964

Merged
merged 6 commits into from
Aug 17, 2023
Merged

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Jul 10, 2023

TestPackages wasn't actually reporting test failures, due to a bug in the underlying function machine.TestMemPackage().

TestMemPackage was running the gno tests by just calling the test function with a new testing.T, but then it's not possible to detect if there's any failure, because testing.T has only private fields.

The fix is to change that to a call to testing.RunTest() function, which is already used by gno test, and returns a testing.Report on which we can detect failures.

A test has been added (see TestMachineTestMemPackage()) in gnovm/tests folder (because a TestStore is needed). On master, this test is failing.

go test ./gnovm/tests -v -run TestMachineTestMemPackage

The next step should be to merge the 2 ways that currently exists to run gno tests, i.e. gno test and go test -run TestPackages. Potentially this could fix #896.

Contributors Checklist

  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

Maintainers Checklist

  • Checked that the author followed the guidelines in CONTRIBUTING.md
  • Checked the conventional-commit (especially PR title and verb, presence of BREAKING CHANGE: in the body)
  • Ensured that this PR is not a significant change or confirmed that the review/consideration process was appropriate for the change

`TestPackages` wasn't actually reporting test failures, due to a bug in
the underlying function `machine.TestMemPackage()`.

`TestMemPackage` was running the found gno tests by just calling the test
function with a new `testing.T`, but then it's not possible to detect if
there's any failure, because `testing.T` has only private fields.

The fix is to change that to a call to `testing.RunTest()` function,
which is already used by `gno test`, and returns a `testing.Report` on
which we can detect failures.

A test has been added (see `TestMachineTestMemPackage()`) in gnovm/tests
folder (because a TestStore is needed). On master, this test is failing.

The next step should be to merge the 2 ways that currently exists to run
gno tests, i.e. `gno test` and `go test -run TestPackages`. Potentially
this could fix gnolang#896.
@tbruyelle tbruyelle requested review from jaekwon, moul and a team as code owners July 10, 2023 17:32
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jul 10, 2023
@zivkovicmilos zivkovicmilos self-requested a review July 11, 2023 07:28
@tbruyelle
Copy link
Contributor Author

tbruyelle commented Jul 24, 2023

Note that TestPackages also runs the tests located in examples/gno.land/..., and they're failing now (before that PR, the error was swallowed).

We don't see the error in the CI because TestPackages/examples aren't part of any of the _test.gnolang.pkg0/1/2 recipes from the gnovm/Makefile (probably on purpose!)

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looks good 💯

Thank you for the detailed in-code explanations 🙏

@moul moul merged commit 9d9143d into gnolang:master Aug 17, 2023
46 of 48 checks passed
Doozers pushed a commit to Doozers/gno that referenced this pull request Aug 31, 2023
`TestPackages` wasn't actually reporting test failures, due to a bug in
the underlying function `machine.TestMemPackage()`.

`TestMemPackage` was running the gno tests by just calling the test
function with a new `testing.T`, but then it's not possible to detect if
there's any failure, because `testing.T` has only private fields.

The fix is to change that to a call to `testing.RunTest()` function,
which is already used by `gno test`, and returns a `testing.Report` on
which we can detect failures.

A test has been added (see `TestMachineTestMemPackage()`) in gnovm/tests
folder (because a `TestStore` is needed). On master, this test is
failing.

```
go test ./gnovm/tests -v -run TestMachineTestMemPackage
```

The next step should be to merge the 2 ways that currently exists to run
gno tests, i.e. `gno test` and `go test -run TestPackages`. Potentially
this could fix gnolang#896.


## Contributors Checklist

- [x] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](../.benchmarks/README.md).

## Maintainers Checklist

- [x] Checked that the author followed the guidelines in
`CONTRIBUTING.md`
- [x] Checked the conventional-commit (especially PR title and verb,
presence of `BREAKING CHANGE:` in the body)
- [x] Ensured that this PR is not a significant change or confirmed that
the review/consideration process was appropriate for the change
</details>

---------

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 16, 2023
@tbruyelle tbruyelle deleted the test/fix-TestPackages branch February 22, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants