ci: run plugin tests on Windows (#8314)

Plugin package tests previously ran only on Linux, so Windows-
specific failures were never caught. Run them in CI and make the
affected tests portable across platforms.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
Ville Vesilehto
2026-07-19 13:52:23 +03:00
committed by GitHub
parent 96ec17d5c6
commit 077774e0cd
11 changed files with 124 additions and 99 deletions

View File

@@ -72,11 +72,16 @@ func TestPrint(t *testing.T) {
f, err := os.CreateTemp(t.TempDir(), "print_test_tmp")
if err != nil {
t.Error(err)
t.Fatal(err)
}
defer os.Remove(f.Name())
//Redirect the printed results to a tmp file for later comparison
// Redirect Print output to a temp file, then restore stdout and close
// the handle so TempDir cleanup can remove it on Windows.
stdout := os.Stdout
os.Stdout = f
t.Cleanup(func() {
os.Stdout = stdout
f.Close()
})
tree.Print()
/**
@@ -85,12 +90,12 @@ func TestPrint(t *testing.T) {
server3.example.com.
*/
if _, err := f.Seek(0, 0); err != nil {
t.Fatal(err)
}
buf := make([]byte, 256)
f.Seek(0, 0)
_, err = f.Read(buf)
if err != nil {
f.Close()
t.Error(err)
if _, err := f.Read(buf); err != nil {
t.Fatal(err)
}
height := strings.Count(string(buf), ". \n")
//Compare the height of the print with the actual height of the tree