Skip to content

[Agent] Join path logic for install hooks is incorrect on windows. #17449

@ph

Description

@ph

in #17445

I've found out a bug on windows, the way we handle absolute path is incorrect.
On windows they will never be absolute path they do not have any volumes names.

		// (Windows issue) See issue:
		//"windows": {
		//	{"/", "a", "\\a", true},
		//	{"/a", "b", "\\a\\b", true},
		//	{"/a", "b/c", "\\a\\b\\c", true},
		//	//
		//	{"/a/b", "/a/c", "\\a\\c", false},
		//	{"/a/b", "/a/b/../c", "\\a\\c", false},
		//	{"/a/b", "../c", "\\a\\c", false},
		//	{"/a", "/a/b/c", "\\a\\b\\c", true},
		//	{"/a", "/A/b/c", "\\a\\b\\c", true},
		//},

failed tests:

 --- FAIL: TestIsSubpath/[windows]'/a/b-/a/c' (0.00s)

[2020-04-02T17:37:59.293Z]         steps_test.go:62: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:62
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: "\\a\\c"
[2020-04-02T17:37:59.294Z]             	            	actual  : "\\a\\b\\a\\c"
[2020-04-02T17:37:59.294Z]             	            	
[2020-04-02T17:37:59.294Z]             	            	Diff:
[2020-04-02T17:37:59.294Z]             	            	--- Expected
[2020-04-02T17:37:59.294Z]             	            	+++ Actual
[2020-04-02T17:37:59.294Z]             	            	@@ -1 +1 @@
[2020-04-02T17:37:59.294Z]             	            	-\a\c
[2020-04-02T17:37:59.294Z]             	            	+\a\b\a\c
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a/b-/a/c'
[2020-04-02T17:37:59.294Z]         steps_test.go:63: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:63
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: false
[2020-04-02T17:37:59.294Z]             	            	actual  : true
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a/b-/a/c'
[2020-04-02T17:37:59.294Z]     --- FAIL: TestIsSubpath/[windows]'/a/b-/a/b/../c' (0.00s)
[2020-04-02T17:37:59.294Z]         steps_test.go:62: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:62
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: "\\a\\c"
[2020-04-02T17:37:59.294Z]             	            	actual  : "\\a\\b\\a\\c"
[2020-04-02T17:37:59.294Z]             	            	
[2020-04-02T17:37:59.294Z]             	            	Diff:
[2020-04-02T17:37:59.294Z]             	            	--- Expected
[2020-04-02T17:37:59.294Z]             	            	+++ Actual
[2020-04-02T17:37:59.294Z]             	            	@@ -1 +1 @@
[2020-04-02T17:37:59.294Z]             	            	-\a\c
[2020-04-02T17:37:59.294Z]             	            	+\a\b\a\c
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a/b-/a/b/../c'
[2020-04-02T17:37:59.294Z]         steps_test.go:63: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:63
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: false
[2020-04-02T17:37:59.294Z]             	            	actual  : true
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a/b-/a/b/../c'
[2020-04-02T17:37:59.294Z]     --- PASS: TestIsSubpath/[windows]'/a/b-../c' (0.00s)
[2020-04-02T17:37:59.294Z]     --- FAIL: TestIsSubpath/[windows]'/a-/a/b/c' (0.00s)
[2020-04-02T17:37:59.294Z]         steps_test.go:62: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:62
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: "\\a\\b\\c"
[2020-04-02T17:37:59.294Z]             	            	actual  : "\\a\\a\\b\\c"
[2020-04-02T17:37:59.294Z]             	            	
[2020-04-02T17:37:59.294Z]             	            	Diff:
[2020-04-02T17:37:59.294Z]             	            	--- Expected
[2020-04-02T17:37:59.294Z]             	            	+++ Actual
[2020-04-02T17:37:59.294Z]             	            	@@ -1 +1 @@
[2020-04-02T17:37:59.294Z]             	            	-\a\b\c
[2020-04-02T17:37:59.294Z]             	            	+\a\a\b\c
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a-/a/b/c'
[2020-04-02T17:37:59.294Z]     --- FAIL: TestIsSubpath/[windows]'/a-/A/b/c' (0.00s)
[2020-04-02T17:37:59.294Z]         steps_test.go:62: 
[2020-04-02T17:37:59.294Z]             	Error Trace:	steps_test.go:62
[2020-04-02T17:37:59.294Z]             	Error:      	Not equal: 
[2020-04-02T17:37:59.294Z]             	            	expected: "\\a\\b\\c"
[2020-04-02T17:37:59.294Z]             	            	actual  : "\\a\\A\\b\\c"
[2020-04-02T17:37:59.294Z]             	            	
[2020-04-02T17:37:59.294Z]             	            	Diff:
[2020-04-02T17:37:59.294Z]             	            	--- Expected
[2020-04-02T17:37:59.294Z]             	            	+++ Actual
[2020-04-02T17:37:59.294Z]             	            	@@ -1 +1 @@
[2020-04-02T17:37:59.294Z]             	            	-\a\b\c
[2020-04-02T17:37:59.294Z]             	            	+\a\A\b\c
[2020-04-02T17:37:59.294Z]             	Test:       	TestIsSubpath/[windows]'/a-/A/b/c'

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions