Skip to content
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

configuration: refactorize code scanning for executables #416

Merged

Conversation

perillo
Copy link
Contributor

@perillo perillo commented Mar 8, 2024

Add the look_path function for searching executable in directories named by the PATH environment variable in the utils source file.

Refactorize the parse function in configuration.cc, using the new look_path function. This greatly simplify the code.

This PR implements an idea discussed #415.

The new change should behave the same as the current implementation, but unfortunately I can not verify this, because many tests fails on my system, probably due to incorrectly building the test suite.

src/utils.cc Outdated Show resolved Hide resolved

// Searches for an executable named file in the directories named by the PATH
// environment variable.
int look_path(const std::string &file, std::string *out);
Copy link
Owner

Choose a reason for hiding this comment

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

You don't have to do that here and now, but I think it's high time to ditch c++03 in kcov (and the MacOS port already depends on newer), and then this would be better to write as

std::optional<std::string> look_path(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at CMake, for building kcov you use --std=c++17, for tests --std=c++0x and, only once, --std=c++1y (that is deprecated after C++14).

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, the C++1y was used for the unit tests, which are sort of stale now anyway. I moved to c++17 after som MacOS rewrites, but forgot that it was done everywhere and not just for the Mac build (which is probably all code that needs it).

Anyway, you don't have to make that change here, I think it's fine as it is.

Add the look_path function for searching executables in directories
named by the PATH environment variable in the utils source file.

Refactorize the parse function in configuration.cc, using the new
look_path function.  This greatly simplify the code.
@perillo perillo force-pushed the handle-out-dir-correctly-2 branch from e0f42ee to 720eb98 Compare March 9, 2024 11:13
@perillo
Copy link
Contributor Author

perillo commented Mar 9, 2024

Is seems that this change is also incorrect: https://github.com/SimonKagstrom/kcov/actions/runs/8208545224.

I was sure that the behavior was the same as the original code.

@SimonKagstrom
Copy link
Owner

Let's merge this anyway, I'll resolve the test errors later. Thanks a lot!

@SimonKagstrom SimonKagstrom merged commit 317bb4a into SimonKagstrom:master Mar 9, 2024
3 of 7 checks passed
@perillo
Copy link
Contributor Author

perillo commented Mar 9, 2024

Thanks to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants