Skip to content

Commit

Permalink
Make gtest-extra-test more portable
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Nov 24, 2023
1 parent bea7ecc commit ffa5b14
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/gtest-extra-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ TEST(output_redirect_test, dup_error_in_ctor) {
FMT_POSIX(close(fd));
std::unique_ptr<output_redirect> redir{nullptr};
EXPECT_SYSTEM_ERROR_NOASSERT(
redir.reset(new output_redirect(f.get())), EBADF,
redir.reset(new output_redirect(f.get(), false)), EBADF,
fmt::format("cannot duplicate file descriptor {}", fd));
copy.dup2(fd); // "undo" close or dtor will fail
}
Expand Down
4 changes: 2 additions & 2 deletions test/gtest-extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

using fmt::file;

output_redirect::output_redirect(FILE* f) : file_(f) {
flush();
output_redirect::output_redirect(FILE* f, bool flush) : file_(f) {
if (flush) this->flush();
int fd = FMT_POSIX(fileno(f));
// Create a file object referring to the original file.
original_ = file::dup(fd);
Expand Down
2 changes: 1 addition & 1 deletion test/gtest-extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class output_redirect {
void restore();

public:
explicit output_redirect(FILE* file);
explicit output_redirect(FILE* file, bool flush = true);
~output_redirect() noexcept;

output_redirect(const output_redirect&) = delete;
Expand Down

0 comments on commit ffa5b14

Please sign in to comment.