[libcxx-commits] [libcxx] [libc++][test] Make filesystem_test_helper.h more portable to Windows (PR #74182)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 1 22:45:06 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 19e068b048591feb8fa66b164669c753090dfd3a 2d2bb7c56178e7b454261aea92edfbaa9385baf0 -- libcxx/test/support/filesystem_test_helper.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index 1dedbf5f22..5f5641d4f2 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -147,11 +147,11 @@ namespace utils {
inline bool exists(std::string const& path) {
#ifdef _WIN32
- struct ::_stat tmp;
- return ::_stat(path.c_str(), &tmp) == 0;
+ struct ::_stat tmp;
+ return ::_stat(path.c_str(), &tmp) == 0;
#else
- struct ::stat tmp;
- return ::stat(path.c_str(), &tmp) == 0;
+ struct ::stat tmp;
+ return ::stat(path.c_str(), &tmp) == 0;
#endif
}
} // end namespace utils
@@ -238,12 +238,10 @@ struct scoped_test_env
std::string create_file(fs::path filename_path, std::uintmax_t size = 0) {
std::string filename = sanitize_path(filename_path.string());
- if (size >
- static_cast<typename std::make_unsigned<utils::off64_t>::type>(
- (std::numeric_limits<utils::off64_t>::max)())) {
- fprintf(stderr, "create_file(%s, %ju) too large\n",
- filename.c_str(), size);
- abort();
+ if (size > static_cast<typename std::make_unsigned<utils::off64_t>::type>(
+ (std::numeric_limits<utils::off64_t>::max)())) {
+ fprintf(stderr, "create_file(%s, %ju) too large\n", filename.c_str(), size);
+ abort();
}
#if defined(_WIN32) || defined(__MVS__)
@@ -265,10 +263,9 @@ struct scoped_test_env
#endif
if (utils::ftruncate64(fd, static_cast<utils::off64_t>(size)) == -1) {
- fprintf(stderr, "ftruncate %s %ju failed: %s\n", filename.c_str(),
- size, strerror(errno));
- fclose(file);
- abort();
+ fprintf(stderr, "ftruncate %s %ju failed: %s\n", filename.c_str(), size, strerror(errno));
+ fclose(file);
+ abort();
}
fclose(file);
``````````
</details>
https://github.com/llvm/llvm-project/pull/74182
More information about the libcxx-commits
mailing list