Skip to content

Commit

Permalink
test(precompile): add more cases (gnolang#1640)
Browse files Browse the repository at this point in the history
Add all kinds of errors described in gnolang#1636.

To run these tests:
```
go test ./gnovm/cmd/gno -v -run Precompile
```

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

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

- [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
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] 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](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
  • Loading branch information
tbruyelle authored and leohhhn committed Feb 8, 2024
1 parent 8994287 commit 87acb86
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Run gno precompile with invalid gno files
# Run gno precompile with gno files with parse errors

! gno precompile .

! stdout .+
stderr 'precompile: parse: main.gno:3:1: expected declaration, found invalid'
stderr 'precompile: parse: sub/sub.gno:3:1: expected declaration, found invalid'

# no *.gen.go files are created
! exec test -f main.gno.gen.go
! exec test -f sub/sub.gno.gen.go

-- main.gno --
package main

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Run gno precompile with -gobuild flag on file with parse error

! gno precompile -gobuild .

! stdout .+
stderr 'main.gno: precompile: parse: main.gno:3:1: expected declaration, found invalid'

# no *.gen.go files are created
! exec test -f main.gno.gen.go

-- main.gno --
package main

invalid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Run gno precompile with gno files with whitelist errors

! gno precompile .

! stdout .+
stderr 'main.gno: precompile: import "xxx" is not in the whitelist'
stderr 'sub/sub.gno: precompile: import "xxx" is not in the whitelist'

# no *.gen.go files are created
! exec test -f main.gno.gen.go
! exec test -f sub/sub.gno.gen.go

-- main.gno --
package main

import (
"std"
"xxx"
)

func main() {}

-- sub/sub.gno --
package sub

import "xxx"

0 comments on commit 87acb86

Please sign in to comment.