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 fails on dev machine. #1258

Closed
jaekwon opened this issue Oct 19, 2023 · 6 comments · Fixed by #1261
Closed

Test fails on dev machine. #1258

jaekwon opened this issue Oct 19, 2023 · 6 comments · Fixed by #1261
Assignees

Comments

@jaekwon
Copy link
Contributor

jaekwon commented Oct 19, 2023

master, OSX, gnovm test fails.

gnovm % go test ./cmd/... -v -run TestBuild/invalid_go_files
=== RUN   TestBuild
=== RUN   TestBuild/invalid_go_files
=== PAUSE TestBuild/invalid_go_files
=== CONT  TestBuild/invalid_go_files
    testscript.go:534: WORK=$WORK
        PATH=/usr/local/go/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/jk/gopath/bin:/usr/local/go/bin
        GOTRACEBACK=system
        HOME=/var/folders/19/85srrz214qlbd122_0jzskvw0000gn/T/TestBuild3366989911/002
        TMPDIR=$WORK/.tmp
        devnull=/dev/null
        /=/
        :=:
        $=$
        GOCOVERDIR=
        exe=
        GNOROOT=/Users/jk/gopath/src/github.com/gnolang/gno
        
        # Run gno build with invalid go files (0.727s)
        > ! gno build .
        [stderr]
        command-line-arguments
        # command-line-arguments
        ./file1.go:3:1: syntax error: non-declaration statement outside function body
        
        ./.: build pkg: std go compiler: exit status 2
        
        command-line-arguments
        # command-line-arguments
        sub/file2.go:3:1: syntax error: non-declaration statement outside function body
        
        ./sub: build pkg: std go compiler: exit status 2
        
        2 go build errors
        
        [exit status 1]
        > ! stdout .+
        > stderr '\./file1\.go:3:1: syntax error: non-declaration statement outside function body'
        > stderr '\./\.: build pkg: std go compiler: exit status 1'
        FAIL: testdata/gno_build/invalid_go_files.txtar:7: no match for `\./\.: build pkg: std go compiler: exit status 1` found in stderr
        
--- FAIL: TestBuild (0.90s)
    --- FAIL: TestBuild/invalid_go_files (0.73s)
@tbruyelle
Copy link
Contributor

So the reason of the error is because the expected output is exit status 1 and you got exit status 2. Under the hood, gno build executes go build so I assume you have a version of go where the exit code is different, which sounds weird.

What's your go version ?

@tbruyelle
Copy link
Contributor

Command to test this behavior using directly the go command:

 $ rm -rf /tmp/xxx && go run github.com/rogpeppe/go-internal/cmd/txtar-x@latest -C /tmp/xxx ./gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar && go build -C /tmp/xxx .; echo $?

Which returns :

# gnobuild
./file1.go:3:1: syntax error: non-declaration statement outside function body
1

We can see the exit code is 1 here.

@jaekwon
Copy link
Contributor Author

jaekwon commented Oct 19, 2023

go version go1.19.4 darwin/amd64

% rm -rf /tmp/xxx && go run github.com/rogpeppe/go-internal/cmd/txtar-x@latest -C /tmp/xxx ./gnovm/cmd/gno/testdata/gno_build/invalid_go_files.txtar && go build -C /tmp/xxx .; echo $?

flag provided but not defined: -C
usage: go build [-o output] [build flags] [packages]
Run 'go help build' for details.
2

@jaekwon
Copy link
Contributor Author

jaekwon commented Oct 19, 2023

Sounds like we just need a version check for better error messaging.

@tbruyelle
Copy link
Contributor

Fair enough, asserting this exit code doesn't really matter actually, I'll change that.

tbruyelle added a commit to tbruyelle/gno that referenced this issue Oct 19, 2023
Closes gnolang#1258

Can't explain why but Jae has exit code 2 where most people have exit
code 1.

Decided to remove the code assertion since it doesn't really matter.
@tbruyelle
Copy link
Contributor

#1261 should fix the test on your machine :)

@gnolang gnolang deleted a comment from tbruyelle Oct 19, 2023
thehowl pushed a commit that referenced this issue Oct 19, 2023
Closes #1258

Can't explain why but Jae has exit code 2 where most people have exit
code 1.

Decided to remove the code assertion since it doesn't really matter.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<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>
thehowl pushed a commit to thehowl/gno that referenced this issue Oct 21, 2023
Closes gnolang#1258

Can't explain why but Jae has exit code 2 where most people have exit
code 1.

Decided to remove the code assertion since it doesn't really matter.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<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>
gfanton pushed a commit to gfanton/gno that referenced this issue Nov 9, 2023
Closes gnolang#1258

Can't explain why but Jae has exit code 2 where most people have exit
code 1.

Decided to remove the code assertion since it doesn't really matter.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants