[post build lint] Check for absolute paths#172
Conversation
|
|
6caebcb to
a21a9c5
Compare
Yeah possible, but theoretically one could pass the params |
|
I think I agree with @Neumann-A here; or at least, I think that'd be a better check. For here, I want to check for absolute paths generally, since someone might not set |
That was now also proposed in microsoft/vcpkg#20321 |
a21a9c5 to
2d4aab1
Compare
|
Same PR but now checks for absolute paths |
2d4aab1 to
67534e1
Compare
67534e1 to
863231d
Compare
|
@autoantwort would you mind not force pushing to one commit? It makes it really difficult to review, and we're going to squash and merge at the end anyways. |
strega-nil-ms
left a comment
There was a problem hiding this comment.
Some more things to make sure this works well.
Yeah sure. I normally use gitlab where you have |
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
0689e6b to
326672e
Compare
# Conflicts: # locales/messages.en.json
BillyONeal
left a comment
There was a problem hiding this comment.
I agree with @vicroms that this needs e2e tests.
I prepared a commit with fixes for most of what I noticed I would like to see taken but it's enough change that I don't want to just push it on you:
https://github.com/BillyONeal/vcpkg-tool/tree/check-pkg-config-files /
|
|
||
| Optional<StringView> find_at_most_one_enclosed(StringView input, StringView left_tag, StringView right_tag); | ||
|
|
||
| bool contains_any_ignoring_c_comments(const std::string& source, View<StringView> to_find); |
There was a problem hiding this comment.
source should be a StringView
src/vcpkg/postbuildlint.cpp
Outdated
| for (size_t offset = 0;;) | ||
| { | ||
| const auto index = path_and_contents.second.find(path, offset); | ||
| if (index == std::string::npos) return false; | ||
| { // .py, .sh, .cmake or .pc file | ||
| const auto before = path_and_contents.second.find_last_of("\n#", index); | ||
| if (before == std::string::npos) return true; | ||
| if (path_and_contents.second[before] == '\n') return true; // not a comment | ||
| } | ||
| offset = index + path.size(); | ||
| } |
There was a problem hiding this comment.
This part looks extractable like contains_any_ignoring_c_comments. And it should handle #s not at the start of a line.
include/vcpkg/base/messages.h
Outdated
| "One or more {vendor} credential providers failed to authenticate. See '{url}' for more details " | ||
| "on how to provide credentials."); | ||
| DECLARE_MESSAGE(FeedbackAppreciated, (), "", "Thank you for your feedback!"); | ||
| DECLARE_MESSAGE(FilesContainAbsolutePath, |
There was a problem hiding this comment.
This needs to tell the user about the policy now.
There was a problem hiding this comment.
I thought the policy should only be used internally to that merging this PR does the break the world. Imho we should not tell the users how to ignore warnings that warns before broken packages.
|
I have tested your patch. It gives a lot of false positives (probably a bug somewhere) and it is 4 times slower then the current implementation (500 ms vs 2.2 seconds for qtbase) |
For example? Note that the raw string literal bug effectively causes everything after the raw string literal to be considered part of it most of the time. I also didn't write tests around the python one so there are likely issues there.
Yeah I did no perf testing yet. What I did gives up on the potential simd that find_first_of does. I just spent over 4 hours trying to prove correctness of this PR yesterday and that's as far as I got. As written the cyclomatic complexity was ... high :) |
The problem was if (!file_contains_absolute_paths(fs, file, stringview_paths))
{
failing_files.push_back(file); // mark as failing file if it does not contains an absolute paths
}
Thank you for the effort :) ❤️ |
|
OMG I flipped the answer? 🤣😂🤣 |
|
@vicroms outstanding comment is that he wants an e2e test for the failing cases. |
7798f61 to
5222349
Compare
|
Thank you for your efforts in making a better package catalog, and a better vcpkg <3 |
Prevents microsoft/vcpkg#19720