Skip to content

Commit 25ed2a4

Browse files
howjmayfgsch
andauthored
test: Conduct testify testing framework (#129)
* test: Conduct testify testing framework * test: Conduct require package too * fix: Fix bazel Co-Authored-By: fgsch <[email protected]> Co-authored-by: fgsch <[email protected]>
1 parent 4b0dc3c commit 25ed2a4

27 files changed

+718
-1243
lines changed

BUILD.bazel

+4-24
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,9 @@ go_library(
6868

6969
go_test(
7070
name = "go_default_test",
71-
srcs = [
72-
"config_test.go",
73-
"doc_test.go",
74-
"engine_test.go",
75-
"exporttype_test.go",
76-
"func_test.go",
77-
"functype_test.go",
78-
"global_test.go",
79-
"globaltype_test.go",
80-
"importtype_test.go",
81-
"instance_test.go",
82-
"linker_test.go",
83-
"memorytype_test.go",
84-
"module_test.go",
85-
"reftypes_test.go",
86-
"slab_test.go",
87-
"store_test.go",
88-
"table_test.go",
89-
"tabletype_test.go",
90-
"trap_test.go",
91-
"valtype_test.go",
92-
"wasi_test.go",
93-
"wasm2wat_test.go",
94-
],
71+
srcs = glob(["**/*_test.go"]),
9572
embed = [":go_default_library"],
73+
deps = [
74+
"@com_github_stretchr_testify//require:go_default_library",
75+
]
9676
)

WORKSPACE

+56-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,67 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22

33
http_archive(
44
name = "io_bazel_rules_go",
5-
sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc",
5+
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
66
urls = [
7-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
8-
"https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz",
7+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
8+
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
9+
],
10+
)
11+
12+
http_archive(
13+
name = "bazel_gazelle",
14+
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
15+
urls = [
16+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
17+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.25.0/bazel-gazelle-v0.25.0.tar.gz",
918
],
1019
)
1120

1221
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
22+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
23+
24+
go_repository(
25+
name = "com_github_davecgh_go_spew",
26+
build_file_proto_mode = "disable_global",
27+
importpath = "github.com/davecgh/go-spew",
28+
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
29+
version = "v1.1.1",
30+
)
31+
32+
go_repository(
33+
name = "com_github_pmezard_go_difflib",
34+
build_file_proto_mode = "disable_global",
35+
importpath = "github.com/pmezard/go-difflib",
36+
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
37+
version = "v1.0.0",
38+
)
39+
40+
go_repository(
41+
name = "com_github_stretchr_testify",
42+
build_file_proto_mode = "disable_global",
43+
importpath = "github.com/stretchr/testify",
44+
sum = "h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=",
45+
version = "v1.8.0",
46+
)
47+
48+
go_repository(
49+
name = "in_gopkg_yaml_v3",
50+
build_file_proto_mode = "disable_global",
51+
importpath = "gopkg.in/yaml.v3",
52+
sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=",
53+
version = "v3.0.0-20200313102051-9f266ea9e77c",
54+
)
55+
56+
go_repository(
57+
name = "com_github_stretchr_objx",
58+
build_file_proto_mode = "disable_global",
59+
importpath = "github.com/stretchr/objx",
60+
sum = "h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=",
61+
version = "v0.4.0",
62+
)
1363

1464
go_rules_dependencies()
1565

16-
go_register_toolchains(version = "1.16")
66+
go_register_toolchains(version = "1.16")
67+
68+
gazelle_dependencies()

config_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package wasmtime
22

3-
import "testing"
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
48

59
func TestConfig(t *testing.T) {
610
NewConfig().SetDebugInfo(true)
@@ -19,11 +23,7 @@ func TestConfig(t *testing.T) {
1923
NewConfig().SetCraneliftOptLevel(OptLevelSpeedAndSize)
2024
NewConfig().SetProfiler(ProfilingStrategyNone)
2125
err := NewConfig().CacheConfigLoadDefault()
22-
if err != nil {
23-
panic(err)
24-
}
26+
require.NoError(t, err)
2527
err = NewConfig().CacheConfigLoad("nonexistent.toml")
26-
if err == nil {
27-
panic("expected an error")
28-
}
28+
require.Error(t, err)
2929
}

0 commit comments

Comments
 (0)