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

fix(cmd/gno): allow testing packages which contain test files with package x_test #1330

Merged
merged 19 commits into from
Nov 23, 2023

Conversation

albttx
Copy link
Member

@albttx albttx commented Nov 2, 2023

Reproduce error from #638 package ./. already exists in cache

EDIT: And fixed it 🎉

$ go run ./gnovm/cmd/gno test --verbose ./examples/gno.land/p/demo/lol
panic: package gno.land/p/demo/lol already exists in cache

goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.(*defaultStore).SetCachePackage(0x1400020a240, 0x14005f23e00)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/store.go:207 +0x10c
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMemPackage(0x14006aba6c0, 0x1400038ff80, 0x1)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:225 +0x190
main.gnoTestPkg({0x16fa42ab0, 0x1e}, {0x1400025f4a0?, 0x1, 0x100a8567c?}, {0x0, 0x0, 0x101374df8?}, 0x1400038e640, 0x14000306820)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:354 +0x3f8
main.execTest(0x1400038e640, {0x1400025f3b0, 0x1, 0x1}, 0x0?)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:255 +0x804
main.newTestCmd.func1({0x0?, 0x0?}, {0x1400025f3b0?, 0x14000696e58?, 0x0?})
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:97 +0x38
github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x0?, {0x100e55608?, 0x14000190010?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:233 +0x17c
github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x14000696b00?, {0x100e55608?, 0x14000190010?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:237 +0x12c
github.com/gnolang/gno/tm2/pkg/commands.(*Command).ParseAndRun(0x14000180000?, {0x100e55608, 0x14000190010}, {0x140001a6050?, 0x60?, 0x0?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:118 +0x4c
main.main()
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/main.go:14 +0x74
exit status 2
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.

@albttx albttx requested a review from a team as a code owner November 2, 2023 20:25
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Nov 2, 2023
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (6d05a37) 55.89% compared to head (eb71b04) 56.12%.

Files Patch % Lines
gnovm/cmd/gno/test.go 91.66% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1330      +/-   ##
==========================================
+ Coverage   55.89%   56.12%   +0.22%     
==========================================
  Files         422      422              
  Lines       65386    65658     +272     
==========================================
+ Hits        36548    36849     +301     
+ Misses      25976    25937      -39     
- Partials     2862     2872      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@albttx albttx force-pushed the albttx/package-already-in-cache branch from f043c79 to d4316f6 Compare November 6, 2023 01:44
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Nov 6, 2023
@albttx albttx force-pushed the albttx/package-already-in-cache branch from d4316f6 to 19413b2 Compare November 6, 2023 01:46
gnovm/cmd/gno/test.go Outdated Show resolved Hide resolved
@albttx albttx changed the title chore: reproduce error from #638 package ./. already exists in cache chore: gno test packages_test fixed Nov 6, 2023
@albttx albttx force-pushed the albttx/package-already-in-cache branch from 19413b2 to 84c9af2 Compare November 6, 2023 01:52
@albttx albttx changed the title chore: gno test packages_test fixed chore: gno test packages suffixed with _test fixed Nov 6, 2023
@albttx albttx force-pushed the albttx/package-already-in-cache branch from 84c9af2 to 7c0b1cf Compare November 6, 2023 01:57
@albttx albttx force-pushed the albttx/package-already-in-cache branch from 7c0b1cf to 4758132 Compare November 6, 2023 11:26
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
albttx and others added 3 commits November 6, 2023 17:53
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
@zivkovicmilos zivkovicmilos self-requested a review November 7, 2023 13:28
@zivkovicmilos zivkovicmilos linked an issue Nov 7, 2023 that may be closed by this pull request
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 fix 🙏

gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
gnovm/cmd/gno/test.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
@thehowl thehowl changed the title chore: gno test packages suffixed with _test fixed fix(cmd/gno): allow testing packages which contain test files with package x_test Nov 7, 2023
@albttx
Copy link
Member Author

albttx commented Nov 9, 2023

@thehowl All good for me :)

@albttx
Copy link
Member Author

albttx commented Nov 15, 2023

@thehowl Could this be moved to last-review / to merge :)

@tbruyelle
Copy link
Contributor

Agree with @thehowl , a txtar would be appreciated :)

@thehowl thehowl merged commit 01a8c14 into gnolang:master Nov 23, 2023
186 checks passed
@tbruyelle
Copy link
Contributor

@thehowl @albttx Don't understand why this was reverted here 9d77b42

Before it was possible to run a test using a private package outside the examples directory. Now it's no longer possible.

gfanton pushed a commit to moul/gno that referenced this pull request Jan 18, 2024
…ackage x_test` (gnolang#1330)

Reproduce error from gnolang#638 package ./. already exists in cache

EDIT: And fixed it 🎉

```
$ go run ./gnovm/cmd/gno test --verbose ./examples/gno.land/p/demo/lol
panic: package gno.land/p/demo/lol already exists in cache

goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.(*defaultStore).SetCachePackage(0x1400020a240, 0x14005f23e00)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/store.go:207 +0x10c
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMemPackage(0x14006aba6c0, 0x1400038ff80, 0x1)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:225 +0x190
main.gnoTestPkg({0x16fa42ab0, 0x1e}, {0x1400025f4a0?, 0x1, 0x100a8567c?}, {0x0, 0x0, 0x101374df8?}, 0x1400038e640, 0x14000306820)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:354 +0x3f8
main.execTest(0x1400038e640, {0x1400025f3b0, 0x1, 0x1}, 0x0?)
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:255 +0x804
main.newTestCmd.func1({0x0?, 0x0?}, {0x1400025f3b0?, 0x14000696e58?, 0x0?})
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:97 +0x38
github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x0?, {0x100e55608?, 0x14000190010?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:233 +0x17c
github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x14000696b00?, {0x100e55608?, 0x14000190010?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:237 +0x12c
github.com/gnolang/gno/tm2/pkg/commands.(*Command).ParseAndRun(0x14000180000?, {0x100e55608, 0x14000190010}, {0x140001a6050?, 0x60?, 0x0?})
	/Users/albttx/go/src/github.com/gnolang/gno/tm2/pkg/commands/command.go:118 +0x4c
main.main()
	/Users/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/main.go:14 +0x74
exit status 2
```

<details><summary>Contributors' checklist...</summary>

- [ ] 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](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
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 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Archived in project
Development

Successfully merging this pull request may close these issues.

panic: package ./. already exists in cache
6 participants