Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken in Windows #1

Closed
hairyhenderson opened this issue Mar 29, 2019 · 2 comments
Closed

Broken in Windows #1

hairyhenderson opened this issue Mar 29, 2019 · 2 comments

Comments

@hairyhenderson
Copy link

Hi @zealic!

I'm trying to fix some long-standing bugs in the Windows build of gomplate, and it looks like xignore has some bugs too which are affecting this.

I've set up a temporary AppVeyor CI in my fork and you can see the build failure here (just running go test ./...: https://ci.appveyor.com/project/hairyhenderson/xignore/builds/23459048

I'll hack on it a bit to see if I can make it work.

Here's the log:

Build started
git config --global core.autocrlf input
git clone -q https://github.com/hairyhenderson/xignore.git c:\gopath\src\github.com\zealic\xignore
git fetch -q origin +refs/pull/1/merge:
git checkout -qf FETCH_HEAD
Running Install scripts
set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
go version
go version go1.11 windows/amd64
go test -v ./... & IF ERRORLEVEL == 1 EXIT 1
=== RUN   TestMatches_Simple
--- PASS: TestMatches_Simple (0.00s)
=== RUN   TestMatches_Simple_WithBeforePatterns
--- PASS: TestMatches_Simple_WithBeforePatterns (0.00s)
=== RUN   TestMatches_Simple_WithAfterPatterns
--- PASS: TestMatches_Simple_WithAfterPatterns (0.00s)
=== RUN   TestMatches_Folder
--- FAIL: TestMatches_Folder (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:57
        	Error:      	Not equal: 
        	            	expected: []string{"foo/bar/1.txt"}
        	            	actual  : []string{}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,3 +1,2 @@
        	            	-([]string) (len=1) {
        	            	- (string) (len=13) "foo/bar/1.txt"
        	            	+([]string) {
        	            	 }
        	Test:       	TestMatches_Folder
=== RUN   TestMatches_Root
--- FAIL: TestMatches_Root (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:71
        	Error:      	Not equal: 
        	            	expected: []string{".xignore", "sub/1.txt", "sub/2.txt"}
        	            	actual  : []string{".xignore", "sub\\1.txt", "sub\\2.txt"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,4 +2,4 @@
        	            	  (string) (len=8) ".xignore",
        	            	- (string) (len=9) "sub/1.txt",
        	            	- (string) (len=9) "sub/2.txt"
        	            	+ (string) (len=9) "sub\\1.txt",
        	            	+ (string) (len=9) "sub\\2.txt"
        	            	 }
        	Test:       	TestMatches_Root
=== RUN   TestMatches_Exclusion
--- FAIL: TestMatches_Exclusion (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:83
        	Error:      	Not equal: 
        	            	expected: []string{"e1.txt", "e3.txt", "en/e3.txt"}
        	            	actual  : []string{"e1.txt", "e3.txt"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,5 +1,4 @@
        	            	-([]string) (len=3) {
        	            	+([]string) (len=2) {
        	            	  (string) (len=6) "e1.txt",
        	            	- (string) (len=6) "e3.txt",
        	            	- (string) (len=9) "en/e3.txt"
        	            	+ (string) (len=6) "e3.txt"
        	            	 }
        	Test:       	TestMatches_Exclusion
=== RUN   TestMatches_DisabledNested
--- FAIL: TestMatches_DisabledNested (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:97
        	Error:      	Not equal: 
        	            	expected: []string{"inner/foo.md"}
        	            	actual  : []string{}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,3 +1,2 @@
        	            	-([]string) (len=1) {
        	            	- (string) (len=12) "inner/foo.md"
        	            	+([]string) {
        	            	 }
        	Test:       	TestMatches_DisabledNested
=== RUN   TestMatches_Nested
--- FAIL: TestMatches_Nested (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:117
        	Error:      	Not equal: 
        	            	expected: []string{"inner/2.lst", "inner/foo.md", "inner/inner2/moss.ini"}
        	            	actual  : []string{"inner\\2.lst", "inner\\inner2\\moss.ini"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,5 +1,4 @@
        	            	-([]string) (len=3) {
        	            	- (string) (len=11) "inner/2.lst",
        	            	- (string) (len=12) "inner/foo.md",
        	            	- (string) (len=21) "inner/inner2/moss.ini"
        	            	+([]string) (len=2) {
        	            	+ (string) (len=11) "inner\\2.lst",
        	            	+ (string) (len=21) "inner\\inner2\\moss.ini"
        	            	 }
        	Test:       	TestMatches_Nested
=== RUN   TestMatches_ByName
--- FAIL: TestMatches_ByName (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:136
        	Error:      	Not equal: 
        	            	expected: []string{"aa/a1/a2/hello.txt", "aa/a1/hello.txt", "aa/hello.txt", "bb/hello.txt", "hello.txt"}
        	            	actual  : []string{"aa\\a1\\a2\\hello.txt", "aa\\a1\\hello.txt", "aa\\hello.txt", "bb\\hello.txt", "hello.txt"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,6 +1,6 @@
        	            	 ([]string) (len=5) {
        	            	- (string) (len=18) "aa/a1/a2/hello.txt",
        	            	- (string) (len=15) "aa/a1/hello.txt",
        	            	- (string) (len=12) "aa/hello.txt",
        	            	- (string) (len=12) "bb/hello.txt",
        	            	+ (string) (len=18) "aa\\a1\\a2\\hello.txt",
        	            	+ (string) (len=15) "aa\\a1\\hello.txt",
        	            	+ (string) (len=12) "aa\\hello.txt",
        	            	+ (string) (len=12) "bb\\hello.txt",
        	            	  (string) (len=9) "hello.txt"
        	Test:       	TestMatches_ByName
=== RUN   TestMatches_Bothname
--- FAIL: TestMatches_Bothname (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:151
        	Error:      	Not equal: 
        	            	expected: []string{"foo/loss.txt", "loss.txt/1.log", "loss.txt/2.log"}
        	            	actual  : []string{"foo\\loss.txt"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,5 +1,3 @@
        	            	-([]string) (len=3) {
        	            	- (string) (len=12) "foo/loss.txt",
        	            	- (string) (len=14) "loss.txt/1.log",
        	            	- (string) (len=14) "loss.txt/2.log"
        	            	+([]string) (len=1) {
        	            	+ (string) (len=12) "foo\\loss.txt"
        	            	 }
        	Test:       	TestMatches_Bothname
=== RUN   TestMatches_LeadingSpace
--- FAIL: TestMatches_LeadingSpace (0.00s)
    require.go:157: 
        	Error Trace:	matcher_test.go:166
        	Error:      	Not equal: 
        	            	expected: []string{"  what.txt", "inner2/  what.txt"}
        	            	actual  : []string{"  what.txt", "inner2\\  what.txt", "inner\\  what.txt"}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,4 +1,5 @@
        	            	-([]string) (len=2) {
        	            	+([]string) (len=3) {
        	            	  (string) (len=10) "  what.txt",
        	            	- (string) (len=17) "inner2/  what.txt"
        	            	+ (string) (len=17) "inner2\\  what.txt",
        	            	+ (string) (len=16) "inner\\  what.txt"
        	            	 }
        	Test:       	TestMatches_LeadingSpace
FAIL
FAIL	github.com/zealic/xignore	0.045s
Command exited with code 1
@zealic zealic closed this as completed in d72c65d Mar 30, 2019
@zealic
Copy link
Owner

zealic commented Mar 30, 2019

@hairyhenderson I was fix this issue on v0.3.3 release.

See test result on windows: https://ci.appveyor.com/project/zealic/xignore/builds/23476303

You need fix testcase like this:

func PathEquals(t *testing.T, expected []string, actual []string) {
	normalizedPaths := []string{}
	for _, p := range expected {
		normalizedPaths = append(normalizedPaths, filepath.FromSlash(p))
	}

	if len(normalizedPaths) == 0 {
		require.Empty(t, actual)
	} else {
		require.Equal(t, normalizedPaths, actual)
	}
}

func TestMatches_Folder(t *testing.T) {
	matcher := NewSystemMatcher()
	result, err := matcher.Matches("testdata/folder", &MatchesOptions{
		Ignorefile: ".xignore",
	})
	require.NoError(t, err)

	PathEquals(t, []string{"foo/bar/1.txt"}, result.MatchedFiles)
	PathEquals(t, []string{".xignore", "foo/bar/tool/lex.txt", "foo/tar/2.txt"}, result.UnmatchedFiles)
	PathEquals(t, []string{"foo/bar"}, result.MatchedDirs)
	PathEquals(t, []string{"foo", "foo/bar/tool", "foo/tar"}, result.UnmatchedDirs)
}

@hairyhenderson
Copy link
Author

Thanks @zealic! I appreciate it! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants