diff options
| author | ruki <[email protected]> | 2020-07-25 00:46:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-07-25 00:46:52 +0800 |
| commit | 5d7d07a9d1a2f4728a0857ff42d9a8f09b34bee2 (patch) | |
| tree | f7666b6c27cde535c6e89601a55070ea002e516e | |
| parent | 85d358dce2bcf06a31e87407391175cea6b7c7e6 (diff) | |
add more go tests
6 files changed, 56 insertions, 3 deletions
diff --git a/tests/projects/go/console_with_deps/src/main.go b/tests/projects/go/console_with_deps/src/main.go index cf33b2d7f..194d6ac86 100644 --- a/tests/projects/go/console_with_deps/src/main.go +++ b/tests/projects/go/console_with_deps/src/main.go @@ -5,7 +5,5 @@ import ( ) func main() { - log.WithFields(log.Fields{ - "animal": "walrus", - }).Info("A walrus appears") + log.WithFields(log.Fields{"animal": "walrus"}).Info("A walrus appears") } diff --git a/tests/projects/go/static_library_with_deps/src/main.go b/tests/projects/go/static_library_with_deps/src/main.go new file mode 100644 index 000000000..f2b477453 --- /dev/null +++ b/tests/projects/go/static_library_with_deps/src/main.go @@ -0,0 +1,7 @@ +package main + +func main() { + + Run() +} + diff --git a/tests/projects/go/static_library_with_deps/src/test.go b/tests/projects/go/static_library_with_deps/src/test.go new file mode 100644 index 000000000..cf10523f9 --- /dev/null +++ b/tests/projects/go/static_library_with_deps/src/test.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "module" +) + +func Run() { + + fmt.Printf("add: %d\n", module.Add(1, 2)); + fmt.Printf("sub: %d\n", module.Sub(1, 2)); +} diff --git a/tests/projects/go/static_library_with_deps/src/test/add.go b/tests/projects/go/static_library_with_deps/src/test/add.go new file mode 100644 index 000000000..b87b21138 --- /dev/null +++ b/tests/projects/go/static_library_with_deps/src/test/add.go @@ -0,0 +1,11 @@ +package module + +import ( + log "github.com/sirupsen/logrus" +) + +func Add(a int, b int) int { + log.WithFields(log.Fields{"animal": "walrus"}).Info("A walrus appears") + return a + b; +} + diff --git a/tests/projects/go/static_library_with_deps/src/test/sub.go b/tests/projects/go/static_library_with_deps/src/test/sub.go new file mode 100644 index 000000000..a24a9abb7 --- /dev/null +++ b/tests/projects/go/static_library_with_deps/src/test/sub.go @@ -0,0 +1,6 @@ +package module + +func Sub(a int, b int) int { + return a - b; +} + diff --git a/tests/projects/go/static_library_with_deps/xmake.lua b/tests/projects/go/static_library_with_deps/xmake.lua new file mode 100644 index 000000000..6943a29aa --- /dev/null +++ b/tests/projects/go/static_library_with_deps/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.debug", "mode.release") + +add_requires("go::github.com/sirupsen/logrus", {alias = "logrus"}) +add_requires("go::golang.org/x/sys/internal/unsafeheader", {alias = "unsafeheader"}) +if is_plat("windows") then + add_requires("go::golang.org/x/sys/windows", {alias = "syshost"}) +else + add_requires("go::golang.org/x/sys/unix", {alias = "syshost"}) +end + +target("module") + set_kind("static") + add_files("src/test/*.go") + add_packages("logrus", "syshost", "unsafeheader") + +target("test") + set_kind("binary") + add_deps("module") + add_files("src/*.go") |
