From 37ab807315fa751531e69d28d533524b49ffb8b6 Mon Sep 17 00:00:00 2001 From: Morgan Date: Thu, 6 Feb 2025 15:40:06 +0100 Subject: [PATCH] test(cmd/gnoland): add test to ensure to not import tests/stdlibs (#3589) Fixes #3585 --- gno.land/cmd/gnoland/imports_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gno.land/cmd/gnoland/imports_test.go diff --git a/gno.land/cmd/gnoland/imports_test.go b/gno.land/cmd/gnoland/imports_test.go new file mode 100644 index 00000000000..c5ae81599b4 --- /dev/null +++ b/gno.land/cmd/gnoland/imports_test.go @@ -0,0 +1,20 @@ +package main + +import ( + "os/exec" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNoTestingStdlibImport(t *testing.T) { + // See: https://github.com/gnolang/gno/issues/3585 + // The gno.land binary should not import testing stdlibs, which contain unsafe + // code in the respective native bindings. + + res, err := exec.Command("go", "list", "-f", `{{ join .Deps "\n" }}`, ".").CombinedOutput() + require.NoError(t, err) + assert.Contains(t, string(res), "github.com/gnolang/gno/gnovm/stdlibs\n", "should contain normal stdlibs") + assert.NotContains(t, string(res), "github.com/gnolang/gno/gnovm/tests/stdlibs\n", "should not contain test stdlibs") +}