forked from mirrors/gomod2nix
tests: Handle test cases without a go.mod
This commit is contained in:
parent
ce3a6771f0
commit
c72445c826
1 changed files with 7 additions and 4 deletions
11
tests/run.go
11
tests/run.go
|
@ -70,13 +70,16 @@ func runTest(rootDir string, testDir string) error {
|
||||||
prefix := testDir
|
prefix := testDir
|
||||||
cmdPath := filepath.Join(rootDir, "..", "gomod2nix")
|
cmdPath := filepath.Join(rootDir, "..", "gomod2nix")
|
||||||
testDir = filepath.Join(rootDir, testDir)
|
testDir = filepath.Join(rootDir, testDir)
|
||||||
err := runProcess(prefix, cmdPath, "--dir", testDir, "--outdir", testDir)
|
|
||||||
if err != nil {
|
if _, err := os.Stat(filepath.Join(testDir, "go.mod")); err == nil {
|
||||||
return err
|
err := runProcess(prefix, cmdPath, "--dir", testDir, "--outdir", testDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildExpr := fmt.Sprintf("with (import <nixpkgs> { overlays = [ (import %s/../overlay.nix) ]; }); callPackage %s {}", rootDir, testDir)
|
buildExpr := fmt.Sprintf("with (import <nixpkgs> { 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue