-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Allow referencing assets from the root of the project. #707
Conversation
@@ -11,7 +11,7 @@ Dir | |||
sample, expected = File.read(file).split("-" * 80) | |||
|
|||
# Parse the sample | |||
ast = Mint::Parser.parse(sample, file) | |||
ast = Mint::Parser.parse(sample, File.dirname(__FILE__) + file.lchop("./spec")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of chopping off the ./spec
from the filepath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.dirname(__FILE__)
is the spec
directory, so we need to remove that from the test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what's wrong with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not find the assets defined in specs.
/path/to/spec/.spec/test-file
where /path/to/spec/.spec
is not a file or a directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't because you've added a mint.json
file to the spec/
folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the spec folder becomes the root folder /
for the tests. So for example /fixtures/data.txt
is reachable so as ../../fixtures/data.txt
from spec/compilers/directives/inline
test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why don't you reference the files from the root folder instead? Unless I'm mistaken this way it wouldn't need any hacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow. We would still need to chop ./spec
off. It doesn't matter if it's absolute or relative. And we still need to find the closest mint.json
to figure out the root folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I don't fully grok the situation. I'm gonna approve it and come back to it later, once I familiarize myself with the recent changes - and there's a lot of 'em 😅
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
Currently, assets an only be referenced relative to the file which references them. As per the issue, if there is a file deep in the source directory, referencing a file in the project root requires a lot of
../
.The PR makes it so that the root path
/
is the project root directory which have themint.json
file.Resolves #459