Now that some work is being done to get Hugo running correctly on Windows, the tests need to be updated.
@tatsushid did a test integration with appveyor, https://github.com/spf13/hugo/issues/380, which is an excellent starting point.
I have started updating the tests for helpers/path_test.go
and this post is specific to those tests. A new discussion should be started for things not related to helpers
’ tests.
Output at start:
PS C:\code\go\src\github.com\spf13\hugo\helpers> go test
--- FAIL: TestReplaceExtension (0.00 seconds)
path_test.go:124: Test 7 failed. Expected ".ext" got "mydir.ext"
path_test.go:124: Test 8 failed. Expected ".ext" got "mydir.ext"
--- FAIL: TestDirExists (0.00 seconds)
path_test.go:154: Test 6 failed. Expected true got false
path_test.go:154: Test 7 failed. Expected true got false
--- FAIL: TestAbsPathify (0.00 seconds)
path_test.go:376: Test 1 failed. Expected "/dir" but go "\\dir"
--- FAIL: TestFilename (0.00 seconds)
path_test.go:405: Test 8 failed. Expected "" got "directoy"
--- FAIL: TestFileAndExt (0.00 seconds)
path_test.go:434: Test 8 failed. Expected filename "" got "directoy".
--- FAIL: TestUrlPrep (0.00 seconds)
url_test.go:65: Test #0 failed. Expected "/section/name/" got "%5Csection%5Cname%5Cindex.html/"
--- FAIL: TestPretty (0.00 seconds)
Location: url_test.go:72
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name/index.html" (actual)
Location: url_test.go:73
Error: Not equal: "\\section\\sub\\name\\index.html" (expected)
!= "/section/sub/name/index.html" (actual)
Location: url_test.go:74
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name/index.html" (actual)
Location: url_test.go:75
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name/index.html" (actual)
Location: url_test.go:76
Error: Not equal: "\\index.html" (expected)
!= "/index.html" (actual)
Location: url_test.go:77
Error: Not equal: "\\\\name\\index.xml" (expected)
!= "/name/index.xml" (actual)
Location: url_test.go:80
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name" (actual)
Location: url_test.go:81
Error: Not equal: "\\section\\sub\\name\\index.html" (expected)
!= "/section/sub/name" (actual)
Location: url_test.go:82
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name" (actual)
Location: url_test.go:83
Error: Not equal: "\\section\\name\\index.html" (expected)
!= "/section/name" (actual)
Location: url_test.go:84
Error: Not equal: "\\index.html" (expected)
!= "/" (actual)
Location: url_test.go:85
Error: Not equal: "\\\\name\\index.xml" (expected)
!= "/name/index.xml" (actual)
FAIL
exit status 1
FAIL github.com/spf13/hugo/helpers 0.173s
I have fixed a couple of tests, but most of the remaining errors involve either the FileAndExt
function or URLs.
FileAndExt
:
--- FAIL: TestReplaceExtension (0.00 seconds)
path_test.go:125: Test 7 failed. Expected ".ext" got "mydir.ext"
path_test.go:125: Test 8 failed. Expected ".ext" got "mydir.ext"
--- FAIL: TestFilename (0.00 seconds)
path_test.go:406: Test 8 failed. Expected "" got "directoy"
--- FAIL: TestFileAndExt (0.00 seconds)
path_test.go:435: Test 8 failed. Expected filename "" got "directoy".
The URL errors are because path
functions, which should use OS specific separators are also used for URLs. I propose that the URLs get their own functions wich are specific to URLs since the separators are not OS dependent.
In addition to the above issues, there are two tests that should be removed from the TestDirExists
test table: the \tmp
and \tmp\
tests since those aren’t valid for Windows.
@spf13 any guidance on this?