fix(tests): be more relaxed in testing pathnames#769
fix(tests): be more relaxed in testing pathnames#769mcepl wants to merge 1 commit intolunarmodules:masterfrom
Conversation
The path in my case is in fact versioned, so the test fails with
Failure -> spec/fixtures_spec.lua @ 7
fixtures: path() returns the absolute fixture path
spec/fixtures_spec.lua:9: Expected strings to match.
Passed in:
(string) '/home/abuild/rpmbuild/BUILD/lua55-busted-2.3.0-build/busted-2.3.0/spec/fixtures/myfile.txt'
Expected:
(string) '^.-busted[/\]spec[/\]fixtures[/\]myfile.txt$'
stack traceback:
spec/fixtures_spec.lua:9: in function <spec/fixtures_spec.lua:7>
Failure -> spec/fixtures_spec.lua @ 12
fixtures: path() returns the absolute fixture path normalized
spec/fixtures_spec.lua:14: Expected strings to match.
Passed in:
(string) '/home/abuild/rpmbuild/BUILD/lua55-busted-2.3.0-build/busted-2.3.0/fixtures/myfile.txt'
Expected:
(string) '^.-busted[/\]fixtures[/\]myfile.txt$'
stack traceback:
spec/fixtures_spec.lua:14: in function <spec/fixtures_spec.lua:12>
Fixes: lunarmodules#768
Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
| it("returns the absolute fixture path", function() | ||
| local path = fixtures.path("fixtures/myfile.txt") | ||
| assert.match("^.-busted[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path) | ||
| assert.match("^.-busted[^/\\]*[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path) |
There was a problem hiding this comment.
this works for your specific case, where you checkout busted in a directory busted-xyz but it is not a generic solution.
This problem exists because you use a non-default git checkout directory. So if we fix it, we should fix it generically, by grabbing the name of the current directory, and injecting that dynamically.
There was a problem hiding this comment.
Well, the question is, why there is that busted[/] part at all? Why should we be concerned about anything outside of the tarball itself? And by the way, that busted-2.3.0/ is part of your tarball, not something I would invent on my own.
There was a problem hiding this comment.
ok, but that's a different solution, then we should skip the busted or bustedXXX part alltogether.
Something like this? (untested)
| assert.match("^.-busted[^/\\]*[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path) | |
| assert.match("^.-[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path) |
The path in my case is in fact versioned, so the test fails with
Fixes: #768