Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
  • Loading branch information
Ericson2314 and roberth authored Aug 7, 2024
1 parent 1216778 commit 20acf6b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/libutil/executable-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ExecutablePath ExecutablePath::parse(const OsString & path)
// ("::"), as an initial <colon> preceding the rest
// of the list, or as a trailing <colon> following
// the rest of the list."
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
? OS_STR(".")
: std::move(str),
};
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/executable-path.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct ExecutablePath
*/
std::optional<std::filesystem::path> find(
const OsString & exe,
std::function<bool(const std::filesystem::path &)> isExecutable = isExecutableAmbient) const;
std::function<bool(const std::filesystem::path &)> isExecutableFile = isExecutableFileAmbient) const;

bool operator==(const ExecutablePath &) const = default;
};
Expand Down
3 changes: 2 additions & 1 deletion src/libutil/file-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ void moveFile(const Path & oldName, const Path & newName)

//////////////////////////////////////////////////////////////////////

bool isExecutableAmbient(const fs::path & exe) {
bool isExecutableFileAmbient(const fs::path & exe) {
// FIXME: access probably returns the wrong thing on directories
return access(exe.string().c_str(),
#ifdef WIN32
0 // TODO do better
Expand Down
14 changes: 2 additions & 12 deletions tests/unit/libutil/strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,8 @@ std::string concatStringsSep2(const std::string_view sep, const C & ss)
// concatStringsSep sep . splitString sep = id if sep is 1 char
RC_GTEST_PROP(splitString, recoveredByConcatStringsSep, (const std::string & s))
{
if (!s.empty()) {
// See FIXME in concatStringsSep tests
// RC_ASSERT(
// concatStringsSep(std::string(1, s[0]), splitString<Strings>(s, std::string(1, s[0]))) == s
// );

// Work around the bug. Make sure it doesn't start with the separate, because that's broken.
RC_ASSERT(concatStringsSep2(std::string(1, s[0]), splitString<Strings>(s, std::string(1, s[0]))) == s);
}

RC_ASSERT(concatStringsSep2("/", splitString<Strings>(s, "/")) == s);
RC_ASSERT(concatStringsSep2("a", splitString<Strings>(s, "a")) == s);
RC_ASSERT(concatStringsSep("/", splitString<Strings>(s, "/")) == s);
RC_ASSERT(concatStringsSep("a", splitString<Strings>(s, "a")) == s);
}

} // namespace nix

0 comments on commit 20acf6b

Please sign in to comment.