From 6a119c6b8446e4b8f9e5619a7b826599f41e384a Mon Sep 17 00:00:00 2001 From: gfanton <8671905+gfanton@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:58:23 +0100 Subject: [PATCH] fix: keep ordering Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com> --- gno.land/pkg/integration/doc.go | 4 +++- gno.land/pkg/integration/testing_integration.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gno.land/pkg/integration/doc.go b/gno.land/pkg/integration/doc.go index 21833ccd9795..41d107c72b1a 100644 --- a/gno.land/pkg/integration/doc.go +++ b/gno.land/pkg/integration/doc.go @@ -32,7 +32,9 @@ // -- # Load a package `./bar` from the current testscript's working directory with the name `gno.land/r/foobar/bar`: // -- use gno.land/r/foobar/bar $WORK/bar // - If the path is not prefixed with the working directory, it is assumed to be relative to the examples directory. -// - The command should always be executed before `gnoland start` to ensure loading +// - It's important to note that the load order is significant when using +// multiple use command; packages should be loaded in the order they are +// dependent upon. // // Logging: // diff --git a/gno.land/pkg/integration/testing_integration.go b/gno.land/pkg/integration/testing_integration.go index a87fde510448..7313fbfcdc98 100644 --- a/gno.land/pkg/integration/testing_integration.go +++ b/gno.land/pkg/integration/testing_integration.go @@ -514,6 +514,15 @@ func (pkgs pkgsLoader) loadPackages(modroot string, path, name string) error { return nil // skip draft package } + // if no require pkgs are declared, use previous one to keep load order + // XXX: find a better way to achieve this + if len(pkg.Requires) == 0 { + pkg.Requires = make([]string, 0, len(pkgs)) + for name := range pkgs { + pkg.Requires = append(pkg.Requires, name) + } + } + if _, ok := pkgs[pkg.Name]; ok { return nil // we already know this pkg }