Skip to content

fix(tests): be more relaxed in testing pathnames#769

Open
mcepl wants to merge 1 commit intolunarmodules:masterfrom
openSUSE-Python:768-failed-fixtures_spec
Open

fix(tests): be more relaxed in testing pathnames#769
mcepl wants to merge 1 commit intolunarmodules:masterfrom
openSUSE-Python:768-failed-fixtures_spec

Conversation

@mcepl
Copy link

@mcepl mcepl commented Feb 28, 2026

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: #768

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

@mcepl mcepl Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but that's a different solution, then we should skip the busted or bustedXXX part alltogether.

Something like this? (untested)

Suggested change
assert.match("^.-busted[^/\\]*[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path)
assert.match("^.-[/\\]spec[/\\]fixtures[/\\]myfile.txt$", path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

spec/fixtures_spec.lua test to fail

2 participants