Skip to content

Commit

Permalink
chore: port tests to new system
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Touron <[email protected]>
  • Loading branch information
moul committed Apr 17, 2022
1 parent 9ba1029 commit 0f62310
Show file tree
Hide file tree
Showing 60 changed files with 209 additions and 220 deletions.
65 changes: 27 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: gnoland gnokey goscan logos

.PHONY: logos goscan gnoland gnokey gnofaucet logos reset test test1 test2 testrealm testrealm1 testrealm2 testpackages testpkgs
.PHONY: logos goscan gnoland gnokey gnofaucet logos reset

reset:
rm -rf testdir
Expand All @@ -19,7 +19,7 @@ gnokey:
echo "Building gnokey"
go build -o build/gnokey ./cmd/gnokey

install_gnokey: gnokey
install_gnokey:
echo "Installing gnokey"
go install ./cmd/gnokey

Expand All @@ -42,45 +42,34 @@ logos:
clean:
rm -rf build

test:
echo "Running tests"
go test
go test tests/*.go -v -test.short --timeout 20m

test1:
echo "Running tests"
go test
go test tests/*.go -v -test.short -run "TestFiles1"

test2:
echo "Running tests"
go test
go test tests/*.go -v -test.short -run "TestFiles2"

testrealm:
echo "Running tests"
go test
go test tests/*.go -v -run "TestFiles/^zrealm"

testrealm1:
echo "Running tests"
go test
go test tests/*.go -v -run "TestFiles1/^zrealm"

testrealm2:
echo "Running tests"
go test
go test tests/*.go -v -run "TestFiles2/^zrealm"

testpackages:
echo "Running tests"
go test tests/*.go -v -run "TestPackages"

testpkgs:
# Test suite
.PHONY: test test.go test.gno test.files1 test.files2 test.realm test.packages
test: test.gno test.go
@echo "Full test suite finished."

test.gno: test.files1 test.files2 test.realm test.packages
go test tests/*.go -v -run "TestFileStr"
go test tests/*.go -v -run "TestSelectors"

test.go:
go test . -v
# -p 1 shows test failures as they come
# maybe another way to do this?
go test ./pkgs/... -p 1 -count 1
go test ./pkgs/... -v -p 1

test.files1:
go test tests/*.go -v -test.short -run "TestFiles1/" --timeout 20m

test.files2:
go test tests/*.go -v -test.short -run "TestFiles2/" --timeout 20m

test.realm:
go test tests/*.go -v -run "TestFiles/^zrealm" --timeout 20m

test.packages:
go test tests/*.go -v -run "TestPackages" --timeout 20m

# Code gen
stringer:
stringer -type=Op

Expand Down
10 changes: 5 additions & 5 deletions pkgs/sdk/vm/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestVMKeeperOrigSend1(t *testing.T) {

// Create test package.
files := []*std.MemFile{
{"init.go", `
{"init.gno", `
package test
import "std"
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestVMKeeperOrigSend2(t *testing.T) {

// Create test package.
files := []*std.MemFile{
{"init.go", `
{"init.gno", `
package test
import "std"
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestVMKeeperOrigSend3(t *testing.T) {

// Create test package.
files := []*std.MemFile{
{"init.go", `
{"init.gno", `
package test
import "std"
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestVMKeeperRealmSend1(t *testing.T) {

// Create test package.
files := []*std.MemFile{
{"init.go", `
{"init.gno", `
package test
import "std"
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestVMKeeperRealmSend2(t *testing.T) {

// Create test package.
files := []*std.MemFile{
{"init.go", `
{"init.gno", `
package test
import "std"
Expand Down
2 changes: 1 addition & 1 deletion tests/backup/assign15.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ func main() {
}

// Error:
// _test/assign15.go:5:26: cannot use type chan<- struct{} as type <-chan struct{} in assignment
// _test/assign15.gno:5:26: cannot use type chan<- struct{} as type <-chan struct{} in assignment
2 changes: 1 addition & 1 deletion tests/backup/op9.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ func main() {
}

// Error:
// _test/op9.go:7:8: invalid operation: operator > not defined on complex128
// _test/op9.gno:7:8: invalid operation: operator > not defined on complex128
2 changes: 1 addition & 1 deletion tests/backup/range9.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ func main() {
}

// Error:
// _test/range9.go:6:16: invalid operation: range c receive from send-only channel
// _test/range9.gno:6:16: invalid operation: range c receive from send-only channel
2 changes: 1 addition & 1 deletion tests/backup/redeclaration-global2.gno
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ func main() {
}

// Error:
// ../_test/redeclaration-global2.go:5:2: time/redeclaration-global2.go redeclared in this block
// ../_test/redeclaration-global2.gno:5:2: time/redeclaration-global2.gno redeclared in this block
2 changes: 1 addition & 1 deletion tests/backup/redeclaration-global3.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func main() {
}

// Error:
// ../_test/redeclaration-global3.go:7:5: time redeclared in this block
// ../_test/redeclaration-global3.gno:7:5: time redeclared in this block
2 changes: 1 addition & 1 deletion tests/backup/redeclaration-global4.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func main() {
}

// Error:
// ../_test/redeclaration-global4.go:7:6: time redeclared in this block
// ../_test/redeclaration-global4.gno:7:6: time redeclared in this block
2 changes: 1 addition & 1 deletion tests/backup/redeclaration-global6.gno
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ func main() {
}

// Error:
// ../_test/redeclaration-global6.go:7:1: time redeclared in this block
// ../_test/redeclaration-global6.gno:7:1: time redeclared in this block
2 changes: 1 addition & 1 deletion tests/backup/redeclaration-global7.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ func main() {
}

// Error:
// ../_test/redeclaration-global7.go:5:2: quux/redeclaration-global7.go redeclared as imported package name
// ../_test/redeclaration-global7.gno:5:2: quux/redeclaration-global7.gno redeclared as imported package name
2 changes: 1 addition & 1 deletion tests/backup/restricted3.gno
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ func main() {
}

// Output:
// recover: test log logger: restricted.go:39: test log
// recover: test log logger: restricted.gno:39: test log
2 changes: 1 addition & 1 deletion tests/files/composite0.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var a = &[]*T{}

// NOTE:
// lowercase fields don't work with native funcs.
// see tests/files/composite0b.go for gno println.
// see tests/files/composite0b.gno for gno println.
type T struct{ Name string }

func main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/files/composite1.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var a = &[]*T{{}}

// NOTE:
// lowercase fields don't work with native funcs.
// see tests/files/composite1b.go for gno println.
// see tests/files/composite1b.gno for gno println.
type T struct{ Name string }

func main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/files/extern/timtadh/data-structures/tree/utils.gno
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// from https://raw.githubusercontent.com/timtadh/data-structures/master/tree/util.go
// from https://raw.githubusercontent.com/timtadh/data-structures/master/tree/util.gno

package tree

Expand Down
2 changes: 1 addition & 1 deletion tests/files/extern/timtadh/data-structures/types/types.gno
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// from https://raw.githubusercontent.com/timtadh/data-structures/master/types/types.go
// from https://raw.githubusercontent.com/timtadh/data-structures/master/types/types.gno

package types

Expand Down
8 changes: 4 additions & 4 deletions tests/files/redeclaration-global0.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ type time int
var time string

func main() {
time = "hello"
println(time)
time = "hello"
println(time)
}

// Error:
// files/redeclaration-global0.go:5:5: time redeclared in this block
// previous declaration at files/redeclaration-global0.go:3:6
// files/redeclaration-global0.gno:5:5: time redeclared in this block
// previous declaration at files/redeclaration-global0.gno:3:6
8 changes: 4 additions & 4 deletions tests/files/redeclaration-global1.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var time int
type time string

func main() {
var t time = "hello"
println(t)
var t time = "hello"
println(t)
}

// Error:
// files/redeclaration-global1.go:5:6: time redeclared in this block
// previous declaration at files/redeclaration-global1.go:3:5
// files/redeclaration-global1.gno:5:6: time redeclared in this block
// previous declaration at files/redeclaration-global1.gno:3:5
10 changes: 5 additions & 5 deletions tests/files/redeclaration-global5.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package main
var time int

func time() string {
return "hello"
return "hello"
}

func main() {
t := time()
println(t)
t := time()
println(t)
}

// Error:
// files/redeclaration-global5.go:5:6: time redeclared in this block
// previous declaration at files/redeclaration-global5.go:3:5
// files/redeclaration-global5.gno:5:6: time redeclared in this block
// previous declaration at files/redeclaration-global5.gno:3:5
16 changes: 8 additions & 8 deletions tests/files/redeclaration0.gno
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package main

func main() {
type foo struct {
yolo string
}
type foo struct {
yolo string
}

var foo int
foo = 2
println(foo)
var foo int
foo = 2
println(foo)
}

// Error:
// files/redeclaration0.go:8:6: foo redeclared in this block
// previous declaration at files/redeclaration0.go:4:7
// files/redeclaration0.gno:8:7: foo redeclared in this block
// previous declaration at files/redeclaration0.gno:4:8
10 changes: 5 additions & 5 deletions tests/files/redeclaration1.gno
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

func main() {
var foo string
var foo string

var foo int
foo = 2
println(foo)
var foo int
foo = 2
println(foo)
}

// Error:
// files/redeclaration1.go:6:6: foo redeclared in this block
// files/redeclaration1.gno:6:7: foo redeclared in this block
16 changes: 8 additions & 8 deletions tests/files/redeclaration2.gno
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package main

func main() {
var foo struct {
yolo string
}
var foo struct {
yolo string
}

var foo int
foo = 2
println(foo)
var foo int
foo = 2
println(foo)
}

// Error:
// files/redeclaration2.go:8:6: foo redeclared in this block
// previous declaration at files/redeclaration2.go:4:6
// files/redeclaration2.gno:8:7: foo redeclared in this block
// previous declaration at files/redeclaration2.gno:4:7
12 changes: 6 additions & 6 deletions tests/files/redeclaration3.gno
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

func main() {
var foo int
foo = 2
var foo int
foo = 2

type foo struct{}
var bar foo
println(bar)
type foo struct{}
var bar foo
println(bar)
}

// Error:
// files/redeclaration3.go:7:7: foo redeclared in this block
// files/redeclaration3.gno:7:8: foo redeclared in this block
14 changes: 7 additions & 7 deletions tests/files/redeclaration4.gno
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package main

func main() {
var foo struct {
yolo string
}
var foo struct {
yolo string
}

type foo struct{}
var bar foo
println(bar)
type foo struct{}
var bar foo
println(bar)
}

// Error:
// files/redeclaration4.go:8:7: foo redeclared in this block
// files/redeclaration4.gno:8:8: foo redeclared in this block
14 changes: 7 additions & 7 deletions tests/files/redeclaration5.gno
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package main

func main() {
type foo struct {
yolo string
}
type foo struct {
yolo string
}

type foo struct{}
var bar foo
println(bar)
type foo struct{}
var bar foo
println(bar)
}

// Error:
// files/redeclaration5.go:8:7: foo redeclared in this block
// files/redeclaration5.gno:8:8: foo redeclared in this block
Loading

0 comments on commit 0f62310

Please sign in to comment.