Skip to content

Commit

Permalink
fix: keep order if outside example
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Jan 30, 2024
1 parent 8d1848f commit 07025a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gno.land/pkg/integration/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down
10 changes: 10 additions & 0 deletions gno.land/pkg/integration/testing_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,22 @@ func (pkgs pkgsLoader) loadPackages(modroot string, path, name string) error {
for _, req := range gnoMod.Require {
pkg.Requires = append(pkg.Requires, req.Mod.Path)
}

Check warning on line 510 in gno.land/pkg/integration/testing_integration.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/testing_integration.go#L509-L510

Added lines #L509 - L510 were not covered by tests

}

if pkg.Draft {
return nil // skip draft package
}

Check warning on line 516 in gno.land/pkg/integration/testing_integration.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/integration/testing_integration.go#L515-L516

Added lines #L515 - L516 were not covered by tests

// if no require pkgs are declared, use previous one to keep load order
// XXX: find a better way to achieve this
if !strings.HasPrefix(pkg.Dir, modroot) && 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
}
Expand Down

0 comments on commit 07025a7

Please sign in to comment.