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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ func buildTestModules(root *Config, walker ModuleWalker) hcl.Diagnostics {
|
|||||||
// - file: main.tftest.hcl, run: setup - test.main.setup
|
// - file: main.tftest.hcl, run: setup - test.main.setup
|
||||||
// - file: tests/main.tftest.hcl, run: setup - test.tests.main.setup
|
// - file: tests/main.tftest.hcl, run: setup - test.tests.main.setup
|
||||||
|
|
||||||
dir := path.Dir(name)
|
dir := filepath.Dir(name)
|
||||||
base := path.Base(name)
|
base := filepath.Base(name)
|
||||||
|
|
||||||
path := addrs.Module{}
|
path := addrs.Module{}
|
||||||
path = append(path, "test")
|
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.Split(dir, "/")...)
|
||||||
}
|
}
|
||||||
path = append(path, strings.TrimSuffix(base, ".tftest.hcl"), run.Name)
|
path = append(path, strings.TrimSuffix(base, ".tftest.hcl"), run.Name)
|
||||||
|
|
||||||
req := ModuleRequest{
|
req := ModuleRequest{
|
||||||
Name: run.Name,
|
Name: run.Name,
|
||||||
Path: path,
|
Path: path,
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -281,6 +282,11 @@ func TestDirFromModule_rel_submodules(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
os.Chdir(oldDir)
|
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{}
|
hooks := &testInstallHooks{}
|
||||||
|
@ -61,7 +61,7 @@ func TestModuleInstaller(t *testing.T) {
|
|||||||
Name: "Install",
|
Name: "Install",
|
||||||
ModuleAddr: "child_a.child_b",
|
ModuleAddr: "child_a.child_b",
|
||||||
PackageAddr: "",
|
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",
|
Name: "Install",
|
||||||
ModuleAddr: "child_a.child_b",
|
ModuleAddr: "child_a.child_b",
|
||||||
PackageAddr: "",
|
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")
|
config, loadDiags := loader.LoadConfigWithTests(".", "tests")
|
||||||
assertNoDiagnostics(t, tfdiags.Diagnostics{}.Append(loadDiags))
|
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")
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer w.Close()
|
||||||
|
|
||||||
return m.WriteSnapshot(w)
|
return m.WriteSnapshot(w)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user