-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix path resolver and add debugging output #21
base: master
Are you sure you want to change the base?
Fix path resolver and add debugging output #21
Conversation
b5989c3
to
606c981
Compare
Oh, yes, it would be nice if I fixed the actual problem, and I'd be happy to do that. :) I did look at the function a few days ago but I couldn't figure out how it worked and haven't gone back to it yet. |
I looked at #10 (comment) again and see your intention is to apparently output stdout to a log file. Feel free to close this PR then. ;) |
606c981
to
d74c2d5
Compare
Usually I let it run without output as part of the suite. I don't think I am in favour or using
That function is totally broken :D. To be fair, it was quickly developed at a stage in which I had defined no formal specifications on its behaviour. For reference, this is what the high level description of it would say if documented :D
|
d74c2d5
to
e02890d
Compare
@@ -30,6 +30,7 @@ int main(){ | |||
ret+=test_normalizer("/hello world/banana/ww/a", "/hello world/banana/", "quick-js/./.././ww/a", false, false); | |||
ret+=test_normalizer("/a/b../", "/a/", "b../", false, false); | |||
|
|||
assert(ret=0); | |||
std::cerr<<"ret = "<<ret<<"\n"; | |||
assert(ret==0); |
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.
This fixes where the test fails even when ret is eq to 0 ;)
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.
LOL in theory my IDE should have warned me, somehow I missed its message.
std::cout<<"├<child> "<<child<<"\n"; | ||
std::cout<<"├> "<<tmp.second<<"\n"; | ||
std::cout<<"╰>> "<<expected<<"\n"; | ||
std::cerr<<"╭<parent> "<<parent<<"\n"; |
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 know we discussed this change. If I manage to fix the resolver, I'll revert these changes before merging.
2/4 failures are fixed with this:
Although I can't say with certainty that it will always give you the intended result. The conditions happens whether 'base_dir' is true or false. The other two failures:
I don't understand why the expected results are how you have them. I've never known a valid filename or directory to contain '..' unless the dots are by themselves. And the first failure there... I don't understand why quickjs isn't part of the expected path. |
Because the test is wrong. The expected result should have been |
dd053e5
to
e37120d
Compare
ee9c6af
to
a3bed67
Compare
I don't know much about your preferences or how you like to configure tests, but I took a guess and made a few quick changes. With the changes in this PR, when `meson test` is run with `-v`, one can see more: ``` stderr: ╭<parent> /hello world/banana/ ├<child> quick-js/././ww/aee/ ├> /hello world/banana/quick-js/ww/aee ╰>> /hello world/banana/quick-js/ww/aee/ ╭<parent> /hello world/banana/ ├<child> quick-js/././ww/aee/ ├> /hello world/banana/quick-js/ww/ ╰>> /hello world/banana/quick-js/ww/aee/ ╭<parent> /hello world/banana/ ├<child> quick-js/././ww/aee ├> /hello world/banana/quick-js/ww/ ╰>> /hello world/banana/quick-js/ww/ ╭<parent> /hello world/banana/ ├<child> ../../quick-js/ww/a ├> /quick-js/ww/a ╰>> /quick-js/ww/a ╭<parent> /hello world/banana/ ├<child> ./../.././quick-js/ww/a ├> /quick-js/ww/a ╰>> /quick-js/ww/a ╭<parent> /hello world/banana/ ├<child> ../../quick-js/ww/a ├> ╰>> ╭<parent> /hello world/banana/ ├<child> ./../.././quick-js/ww/a ├> ╰>> ╭<parent> /hello world/banana/ ├<child> quick-js/../quick-js/ww/a ├> /hello world/banana/quick-js/ww/a ╰>> /hello world/banana/ww/a ╭<parent> /hello world/banana/ ├<child> quick-js/./.././ww/a ├> /hello world/banana/ww/a ╰>> /hello world/banana/ww/a ╭<parent> /a/ ├<child> b../ ├> /a/ ╰>> /a/b../ ret = 4 test_resolver-paths: ../test/marginal/resolver-paths.cpp:33: int main(): Assertion `ret=0' failed. ```
╭<parent> /a/ ├<child> b../ ├> /a/b../ ╰>> /a/b../
e37120d
to
fe08deb
Compare
if (j > 0) { | ||
if (child[j-1] != '/') { | ||
uint8_t i = 0; | ||
for(;i<=sizeof "../";i++) { |
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.
Ok, so this you might laugh at this. ;) Something just didn't feel right about using "3" here.
In my own code, I might #define DOUBLE_DOT_DIR_SEP "../"
or something at the top, then just use that string... and then using sizeof
would seem more appropriate, but that too seems like overkill.
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.
No, that is totally fine, hardcoded numbers are just bad. That is resolved at compile time so it is not like it reduces performance or anything.
For context, in modern C++ one would define a constexpr value in place of a define if it had to be made more explicit. But it is fine as it is.
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.
Awesome! Maybe @Jammyjamjamman is right and I'm not a bad developer! :)
I will be checking and stress testing it a bit. Thank you! |
More tests added in https://github.com/KaruroChori/vs-fltk/tree/test-path show the revised implementation failing. |
61bd0a0
to
6f6c830
Compare
4cf76d6
to
ad74fb3
Compare
I don't know much about your preferences or how you like to configure tests, but I took a guess and made a few quick changes.
With the changes in this PR, when
meson test
is run with-v
, one can see more: