Skip to content

Commit

Permalink
tests: Add debugging output to resolver-paths
Browse files Browse the repository at this point in the history
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.
```
  • Loading branch information
andy5995 committed Dec 8, 2024
1 parent 8654eaf commit e37120d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
# Unclear fix to be investigated
rm subprojects/libtcc/VERSION
meson compile -C build/ vs:executable
meson test test_resolver-paths -C build -v
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions src/utils/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ std::pair<bool, std::string> resolve_path::normalizer(const char *parent, const
j++;
continue;
}
else if(child[j]=='/'){
j++;
else if(child[j]=='/' && j!=child_len-1){
j++;
}
else{
ret[ptr]=child[j];
Expand Down Expand Up @@ -157,4 +157,4 @@ std::pair<resolve_path::reason_t::t,scoped_rpath_t> resolve_path::operator()(fro
return {reason_t::MALFORMED,{rpath_type_t::NONE, ""}};
}

}
}
15 changes: 8 additions & 7 deletions test/marginal/resolver-paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ using namespace vs;

int test_normalizer(const char* expected, const char* parent, const char* child, bool allow_exit, bool base_dir){
auto tmp = resolve_path::normalizer(parent,child,allow_exit,base_dir);
std::cout<<"╭<parent> "<<parent<<"\n";
std::cout<<"├<child> "<<child<<"\n";
std::cout<<"├> "<<tmp.second<<"\n";
std::cout<<"╰>> "<<expected<<"\n";
std::cerr<<"╭<parent> "<<parent<<"\n";
std::cerr<<"├<child> "<<child<<"\n";
std::cerr<<"├> "<<tmp.second<<"\n";
std::cerr<<"╰>> "<<expected<<"\n";
//if(!tmp.first)return 1;
if(tmp.second==expected){return 0;}
else{
Expand All @@ -26,10 +26,11 @@ int main(){
ret+=test_normalizer("/quick-js/ww/a", "/hello world/banana/", "./../.././quick-js/ww/a", true, false);
ret+=test_normalizer("", "/hello world/banana/", "../../quick-js/ww/a", false, false);
ret+=test_normalizer("", "/hello world/banana/", "./../.././quick-js/ww/a", false, false);
ret+=test_normalizer("/hello world/banana/ww/a", "/hello world/banana/", "quick-js/../quick-js/ww/a", false, false);
ret+=test_normalizer("/hello world/banana/quick-js/ww/a", "/hello world/banana/", "quick-js/../quick-js/ww/a", false, false);
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);
return 0;
}
}

0 comments on commit e37120d

Please sign in to comment.