Skip to content

Commit

Permalink
test(precompile): add more cases
Browse files Browse the repository at this point in the history
Add all kinds of errors described in #1636.
  • Loading branch information
tbruyelle committed Feb 8, 2024
1 parent 059a3b8 commit a0eaf67
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 a0eaf67

Please sign in to comment.