mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
initwd Windows tests fixes (#1723)
Signed-off-by: eduzgun <emreduz00@gmail.com> Signed-off-by: Emre Duzgun <100037959+eduzgun@users.noreply.github.com>
This commit is contained in:
parent
3fdc809050
commit
502877dbf7
@ -7,7 +7,7 @@ package configs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@ -64,8 +64,8 @@ func buildTestModules(root *Config, walker ModuleWalker) hcl.Diagnostics {
|
||||
// - file: main.tftest.hcl, run: setup - test.main.setup
|
||||
// - file: tests/main.tftest.hcl, run: setup - test.tests.main.setup
|
||||
|
||||
dir := path.Dir(name)
|
||||
base := path.Base(name)
|
||||
dir := filepath.Dir(name)
|
||||
base := filepath.Base(name)
|
||||
|
||||
path := addrs.Module{}
|
||||
path = append(path, "test")
|
||||
@ -73,7 +73,6 @@ func buildTestModules(root *Config, walker ModuleWalker) hcl.Diagnostics {
|
||||
path = append(path, strings.Split(dir, "/")...)
|
||||
}
|
||||
path = append(path, strings.TrimSuffix(base, ".tftest.hcl"), run.Name)
|
||||
|
||||
req := ModuleRequest{
|
||||
Name: run.Name,
|
||||
Path: path,
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@ -281,6 +282,11 @@ func TestDirFromModule_rel_submodules(t *testing.T) {
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
os.Chdir(oldDir)
|
||||
// Trigger garbage collection to ensure that all open file handles are closed.
|
||||
// This prevents TempDir RemoveAll cleanup errors on Windows.
|
||||
if runtime.GOOS == "windows" {
|
||||
runtime.GC()
|
||||
}
|
||||
})
|
||||
|
||||
hooks := &testInstallHooks{}
|
||||
|
@ -61,7 +61,7 @@ func TestModuleInstaller(t *testing.T) {
|
||||
Name: "Install",
|
||||
ModuleAddr: "child_a.child_b",
|
||||
PackageAddr: "",
|
||||
LocalPath: "child_a/child_b",
|
||||
LocalPath: filepath.Join("child_a", "child_b"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ func TestModuleInstaller_symlink(t *testing.T) {
|
||||
Name: "Install",
|
||||
ModuleAddr: "child_a.child_b",
|
||||
PackageAddr: "",
|
||||
LocalPath: "child_a/child_b",
|
||||
LocalPath: filepath.Join("child_a", "child_b"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -764,7 +764,7 @@ func TestModuleInstaller_fromTests(t *testing.T) {
|
||||
config, loadDiags := loader.LoadConfigWithTests(".", "tests")
|
||||
assertNoDiagnostics(t, tfdiags.Diagnostics{}.Append(loadDiags))
|
||||
|
||||
if config.Module.Tests["tests/main.tftest.hcl"].Runs[0].ConfigUnderTest == nil {
|
||||
if config.Module.Tests[filepath.Join("tests", "main.tftest.hcl")].Runs[0].ConfigUnderTest == nil {
|
||||
t.Fatalf("should have loaded config into the relevant run block but did not")
|
||||
}
|
||||
}
|
||||
|
@ -180,5 +180,7 @@ func (m Manifest) WriteSnapshotToDir(dir string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer w.Close()
|
||||
|
||||
return m.WriteSnapshot(w)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user