From c72445c826ac25385c5cdfcd48f473cd434f9c85 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 30 May 2022 18:33:22 +0800 Subject: [PATCH] tests: Handle test cases without a go.mod --- tests/run.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/run.go b/tests/run.go index a75f399..8702046 100644 --- a/tests/run.go +++ b/tests/run.go @@ -70,13 +70,16 @@ func runTest(rootDir string, testDir string) error { prefix := testDir cmdPath := filepath.Join(rootDir, "..", "gomod2nix") testDir = filepath.Join(rootDir, testDir) - err := runProcess(prefix, cmdPath, "--dir", testDir, "--outdir", testDir) - if err != nil { - return err + + if _, err := os.Stat(filepath.Join(testDir, "go.mod")); err == nil { + err := runProcess(prefix, cmdPath, "--dir", testDir, "--outdir", testDir) + if err != nil { + return err + } } buildExpr := fmt.Sprintf("with (import { overlays = [ (import %s/../overlay.nix) ]; }); callPackage %s {}", rootDir, testDir) - err = runProcess(prefix, "nix-build", "--no-out-link", "--expr", buildExpr) + err := runProcess(prefix, "nix-build", "--no-out-link", "--expr", buildExpr) if err != nil { return err }