mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
IsMtExe() looked for the last '\\' in the target executable path to find the bare filename, but vintner passes toolExePath straight from Go's filepath.Join (forward slashes) all the way through to CreateProcessW - so the path toolrelay.exe actually receives has no backslash in it at all, and IsMtExe() compared the *entire path* against "mt.exe", which of course never matched. The whole point of this file - translating mt.exe's CMake-compatibility exit code (0x41020001 -> 0xbb) before Wine's own exit-code truncation destroys it - has silently never fired in real usage. This had gone unnoticed because MSBuild's rawStdout path bypasses toolrelay.exe entirely, and every real end-to-end test so far (msbuild-driven builds, including the KMDF driver) went through that path. Found while getting a CMake+Ninja-generated MSVC build of a real project (Ogre3D) past its `cmake -E vs_link_exe` manifest step, which depends on exactly this translation. Now checks for both '\\' and '/' and uses whichever separator occurs last in the path. Verified directly: `mt /manifest ... /notify_update` through the wrapper now exits 187 (0xbb) instead of 1, and the Ogre build gets past the manifest-embedding step it was failing at.
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package download
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRetryBackoff(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
attempt int
|
|
want time.Duration
|
|
}{
|
|
{1, 1 * time.Second},
|
|
{2, 2 * time.Second},
|
|
{3, 4 * time.Second},
|
|
{4, 8 * time.Second},
|
|
{5, 10 * time.Second}, // capped
|
|
{10, 10 * time.Second},
|
|
} {
|
|
if got := retryBackoff(tc.attempt); got != tc.want {
|
|
t.Errorf("retryBackoff(%d) = %v, want %v", tc.attempt, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSHA256File(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "f")
|
|
if err := os.WriteFile(path, []byte("hello"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := sha256File(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// echo -n hello | sha256sum
|
|
want := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
|
|
if got != want {
|
|
t.Errorf("sha256File(hello) = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestEqualFoldHex(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
a, b string
|
|
want bool
|
|
}{
|
|
{"ABCDEF", "abcdef", true},
|
|
{"abc123", "ABC123", true},
|
|
{"abc123", "abc124", false},
|
|
{"abc", "abcd", false},
|
|
{"", "", true},
|
|
} {
|
|
if got := equalFoldHex(tc.a, tc.b); got != tc.want {
|
|
t.Errorf("equalFoldHex(%q, %q) = %v, want %v", tc.a, tc.b, got, tc.want)
|
|
}
|
|
}
|
|
}
|