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

cd examples; make test fails #782

Closed
jaekwon opened this issue Apr 26, 2023 · 3 comments · Fixed by #784
Closed

cd examples; make test fails #782

jaekwon opened this issue Apr 26, 2023 · 3 comments · Fixed by #784
Labels
🐞 bug Something isn't working

Comments

@jaekwon
Copy link
Contributor

jaekwon commented Apr 26, 2023

fails with the following error:

panic: fail on gno.land/r/demo/boards/z_0_a_filetest.gno: got "unable to determine if test is a _test or a _filetest: init.0", want: "unauthorized"

all the example tests should run on CI, not sure why it isn't.

@moul moul added the bug label Apr 26, 2023
@moul
Copy link
Member

moul commented Apr 26, 2023

should be the case, we'll fix it.

@jaekwon
Copy link
Contributor Author

jaekwon commented Apr 26, 2023

fixes for the first two cases...

--- a/examples/gno.land/r/demo/releases_example/releases1_filetest.gno
+++ b/examples/gno.land/r/demo/releases_example/releases1_filetest.gno
@@ -1,7 +1,7 @@
 package main
 
 import (
-       "gno.land/r/demo/releases-example"
+       "gno.land/r/demo/releases_example"
 )
 
 func main() {
@@ -17,18 +17,18 @@ func main() {
 
 // Output:
 // -----------
-// # example-app
+// # example_app
 //
-// ## [example-app v2 (latest)](r/demo/examples_example_v2)
+// ## [example_app v2 (latest)](r/demo/examples_example_v2)
 //
 // various improvements
 //
-// ## [example-app v1](r/demo/examples_example_v1)
+// ## [example_app v1](r/demo/examples_example_v1)
 //
 // initial release
 //
 // -----------
-// ## [example-app v1](r/demo/examples_example_v1)
+// ## [example_app v1](r/demo/examples_example_v1)
 //
 // initial release
 //
diff --git a/gnovm/tests/imports.go b/gnovm/tests/imports.go
index 63ccd088..7999160d 100644
--- a/gnovm/tests/imports.go
+++ b/gnovm/tests/imports.go
@@ -457,12 +457,19 @@ func testPackageInjector(store gno.Store, pn *gno.PackageNode) {
        // Also inject stdlibs native functions.
        stdlibs.InjectPackage(store, pn)
        isOriginCall := func(m *gno.Machine) bool {
-               switch m.Frames[0].Func.Name {
+               tname := m.Frames[0].Func.Name
+               switch tname {
                case "main": // test is a _filetest
                        return len(m.Frames) == 3
                case "runtest": // test is a _test
                        return len(m.Frames) == 7
                }
+               // support init() in _filetest
+               // XXX do we need to distinguish from 'runtest'/_test?
+               // XXX pretty hacky even if not.
+               if strings.HasPrefix(string(tname), "init.") {
+                       return len(m.Frames) == 3
+               }
                panic("unable to determine if test is a _test or a _filetest")
        }
        // Test specific injections:

@moul
Copy link
Member

moul commented Apr 26, 2023

I'm on the CI thing on my side.

Edit: #784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

3 participants