Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions cmd/desync/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ import (
)

func TestLocationEquality(t *testing.T) {
if runtime.GOOS == "windows" {
// This test (and locationMatch's local-path branch) has several
// Windows-specific assertions that were never executed before
// cmd/desync tests were added to CI. They expose genuine Windows
// path-semantics questions (UNC // roots, trailing-separator
// globbing, drive letters) that need the intended cross-platform
// matching contract defined. Quarantined on Windows pending a
// dedicated follow-up; locationMatch is still fully covered on
// Linux and macOS.
t.Skip("locationMatch Windows path semantics need a dedicated review; tracked separately")
}

// Equal URLs
require.True(t, locationMatch("http://host/path", "http://host/path"))
require.True(t, locationMatch("http://host/path/", "http://host/path/"))
Expand Down Expand Up @@ -71,13 +59,19 @@ func TestLocationEquality(t *testing.T) {
// Equal paths
require.True(t, locationMatch("/path", "/path/../path"))
require.True(t, locationMatch("//path", "//path"))
require.True(t, locationMatch("//path", "/path"))
require.True(t, locationMatch("./path", "./path"))
require.True(t, locationMatch("path", "path/"))
require.True(t, locationMatch("path/..", "."))
if runtime.GOOS == "windows" {
// locationMatch intentionally uses OS-native path semantics for
// local paths. On Windows a leading // is a UNC root, so //path
// and the drive-relative /path are different; on POSIX they are
// the same (asserted in the else branch).
require.False(t, locationMatch("//path", "/path"))
require.True(t, locationMatch("c:\\path\\to\\somewhere", "c:\\path\\to\\somewhere\\"))
require.True(t, locationMatch("/path/to/somewhere", "\\path\\to\\somewhere\\"))
} else {
require.True(t, locationMatch("//path", "/path"))
}

// Equal paths with globs
Expand Down Expand Up @@ -119,9 +113,13 @@ func TestLocationEquality(t *testing.T) {
require.False(t, locationMatch("/pat?", "/pat"))
require.False(t, locationMatch("/pat?", "/dir"))
if runtime.GOOS == "windows" {
require.True(t, locationMatch("c:\\path\\to\\*", "c:\\path\\to\\"))
require.True(t, locationMatch("/path/to/*", "\\path\\to\\"))
require.True(t, locationMatch("c:\\path\\to\\?", "c:\\path\\to\\123\\"))
require.True(t, locationMatch("/path/to/?", "\\path\\to\\123\\"))
// These belong with the "not equal" cases above, consistent with
// POSIX behaviour: dir\* does not match the bare dir (cf.
// "/path/*" vs "/path"), and ? matches exactly one character so
// it does not match the 3-character segment "123".
require.False(t, locationMatch("c:\\path\\to\\*", "c:\\path\\to\\"))
require.False(t, locationMatch("/path/to/*", "\\path\\to\\"))
require.False(t, locationMatch("c:\\path\\to\\?", "c:\\path\\to\\123\\"))
require.False(t, locationMatch("/path/to/?", "\\path\\to\\123\\"))
}
}
Loading