Index: libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp +++ libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp @@ -260,8 +260,7 @@ perms::group_exec|perms::owner_exec|perms::others_exec, perm_options::remove); - const std::error_code eacess_ec = - std::make_error_code(std::errc::permission_denied); + const std::errc eacess = std::errc::permission_denied; std::error_code ec = GetTestEC(); const recursive_directory_iterator endIt; @@ -287,7 +286,7 @@ ec = GetTestEC(); it.increment(ec); TEST_CHECK(ec); - TEST_CHECK(ec == eacess_ec); + TEST_CHECK(ErrorIs(ec, eacess)); TEST_CHECK(it == endIt); } { @@ -346,8 +345,7 @@ perms::group_exec|perms::owner_exec|perms::others_exec, perm_options::remove); - const std::error_code eacess_ec = - std::make_error_code(std::errc::permission_denied); + const std::errc eacess = std::errc::permission_denied; std::error_code ec = GetTestEC(); const recursive_directory_iterator endIt; @@ -397,7 +395,7 @@ } } else { TEST_CHECK(ec); - TEST_CHECK(ec == eacess_ec); + TEST_CHECK(ErrorIs(ec, eacess)); TEST_CHECK(it == endIt); } } @@ -430,8 +428,7 @@ perms::group_exec|perms::owner_exec|perms::others_exec, perm_options::remove); - const std::error_code eacess_ec = - std::make_error_code(std::errc::permission_denied); + const std::errc eacess = std::errc::permission_denied; std::error_code ec = GetTestEC(); const recursive_directory_iterator EndIt; @@ -488,7 +485,7 @@ TEST_CHECK(it == EndIt); } else { TEST_CHECK(ec); - TEST_CHECK(ec == eacess_ec); + TEST_CHECK(ErrorIs(ec, eacess)); TEST_CHECK(it == EndIt); } } Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp +++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp @@ -286,14 +286,14 @@ { std::error_code ec = GetTestEC(); fs::copy(dir, dest, copy_options::create_symlinks, ec); - TEST_CHECK(ec == std::make_error_code(std::errc::is_a_directory)); + TEST_CHECK(ErrorIs(ec, std::errc::is_a_directory)); TEST_CHECK(!exists(dest)); TEST_CHECK(!is_symlink(dest)); } { std::error_code ec = GetTestEC(); fs::copy(dir, dest, copy_options::create_symlinks|copy_options::recursive, ec); - TEST_CHECK(ec == std::make_error_code(std::errc::is_a_directory)); + TEST_CHECK(ErrorIs(ec, std::errc::is_a_directory)); TEST_CHECK(!exists(dest)); TEST_CHECK(!is_symlink(dest)); } Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp +++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.permissions/permissions.pass.cpp @@ -172,7 +172,10 @@ #endif std::error_code ec = GetTestEC(); permissions(sym, TC.set_perms, TC.opts | perm_options::nofollow, ec); - TEST_CHECK(ec == expected_ec); + if (expected_ec) + TEST_CHECK(ErrorIs(ec, (std::errc)expected_ec.value())); + else + TEST_CHECK(!ec); TEST_CHECK(status(file).permissions() == file_perms); TEST_CHECK(symlink_status(sym).permissions() == expected_link_perms); } Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp +++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp @@ -34,8 +34,7 @@ TEST_CASE(test_status_not_found) { static_test_env static_env; - const std::error_code expect_ec = - std::make_error_code(std::errc::no_such_file_or_directory); + const std::errc expect_errc = std::errc::no_such_file_or_directory; const path cases[] { static_env.DNE, static_env.BadSymlink @@ -44,7 +43,7 @@ std::error_code ec = std::make_error_code(std::errc::address_in_use); // test non-throwing overload. file_status st = status(p, ec); - TEST_CHECK(ec == expect_ec); + TEST_CHECK(ErrorIs(ec, expect_errc)); TEST_CHECK(st.type() == file_type::not_found); TEST_CHECK(st.permissions() == perms::unknown); // test throwing overload. It should not throw even though it reports @@ -63,27 +62,24 @@ const path sym = env.create_symlink("dir/file", "sym"); permissions(dir, perms::none); - const std::error_code set_ec = - std::make_error_code(std::errc::address_in_use); - const std::error_code perm_ec = - std::make_error_code(std::errc::permission_denied); - const std::error_code name_too_long_ec = - std::make_error_code(std::errc::filename_too_long); + const std::errc set_errc = std::errc::address_in_use; + const std::errc perm_errc = std::errc::permission_denied; + const std::errc name_too_long_errc = std::errc::filename_too_long; struct TestCase { path p; - std::error_code expect_ec; + std::errc expect_errc; } const TestCases[] = { - {file, perm_ec}, - {sym, perm_ec}, - {path(std::string(2500, 'a')), name_too_long_ec} + {file, perm_errc}, + {sym, perm_errc}, + {path(std::string(2500, 'a')), name_too_long_errc} }; for (auto& TC : TestCases) { { // test non-throwing case - std::error_code ec = set_ec; + std::error_code ec = std::make_error_code(set_errc); file_status st = status(TC.p, ec); - TEST_CHECK(ec == TC.expect_ec); + TEST_CHECK(ErrorIs(ec, TC.expect_errc)); TEST_CHECK(st.type() == file_type::none); TEST_CHECK(st.permissions() == perms::unknown); } @@ -94,7 +90,7 @@ } catch (filesystem_error const& err) { TEST_CHECK(err.path1() == TC.p); TEST_CHECK(err.path2() == ""); - TEST_CHECK(err.code() == TC.expect_ec); + TEST_CHECK(ErrorIs(err.code(), TC.expect_errc)); } } #endif Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp +++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp @@ -34,8 +34,7 @@ TEST_CASE(test_symlink_status_not_found) { static_test_env static_env; - const std::error_code expect_ec = - std::make_error_code(std::errc::no_such_file_or_directory); + const std::errc expect_errc = std::errc::no_such_file_or_directory; const path cases[] { static_env.DNE }; @@ -43,7 +42,7 @@ std::error_code ec = std::make_error_code(std::errc::address_in_use); // test non-throwing overload. file_status st = symlink_status(p, ec); - TEST_CHECK(ec == expect_ec); + TEST_CHECK(ErrorIs(ec, expect_errc)); TEST_CHECK(st.type() == file_type::not_found); TEST_CHECK(st.permissions() == perms::unknown); // test throwing overload. It should not throw even though it reports @@ -63,10 +62,8 @@ const path sym_points_in_dir = env.create_symlink("dir/file", "sym"); permissions(dir, perms::none); - const std::error_code set_ec = - std::make_error_code(std::errc::address_in_use); - const std::error_code expect_ec = - std::make_error_code(std::errc::permission_denied); + const std::errc set_errc = std::errc::address_in_use; + const std::errc expect_errc = std::errc::permission_denied; const path fail_cases[] = { file_in_dir, sym_in_dir @@ -74,9 +71,9 @@ for (auto& p : fail_cases) { { // test non-throwing case - std::error_code ec = set_ec; + std::error_code ec = std::make_error_code(set_errc); file_status st = symlink_status(p, ec); - TEST_CHECK(ec == expect_ec); + TEST_CHECK(ErrorIs(ec, expect_errc)); TEST_CHECK(st.type() == file_type::none); TEST_CHECK(st.permissions() == perms::unknown); } @@ -87,7 +84,7 @@ } catch (filesystem_error const& err) { TEST_CHECK(err.path1() == p); TEST_CHECK(err.path2() == ""); - TEST_CHECK(err.code() == expect_ec); + TEST_CHECK(ErrorIs(err.code(), expect_errc)); } } #endif @@ -95,7 +92,7 @@ // Test that a symlink that points into a directory without read perms // can be stat-ed using symlink_status { - std::error_code ec = set_ec; + std::error_code ec = std::make_error_code(set_errc); file_status st = symlink_status(sym_points_in_dir, ec); TEST_CHECK(!ec); TEST_CHECK(st.type() == file_type::symlink); Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp =================================================================== --- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp +++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp @@ -50,7 +50,7 @@ const path dir_perms = env.create_dir("bad_perms_dir"); const path nested_dir = env.create_dir("bad_perms_dir/nested"); permissions(dir_perms, perms::none); - const std::error_code expect_ec = std::make_error_code(std::errc::not_a_directory); + LIBCPP_ONLY(const std::errc expect_errc = std::errc::not_a_directory); struct TestCase { std::string name; path p; @@ -75,7 +75,7 @@ PutEnv(TC.name, dne); ec = GetTestEC(); ret = temp_directory_path(ec); - LIBCPP_ONLY(TEST_CHECK(ec == expect_ec)); + LIBCPP_ONLY(TEST_CHECK(ErrorIs(ec, expect_errc))); TEST_CHECK(ec != GetTestEC()); TEST_CHECK(ec); TEST_CHECK(ret == ""); @@ -84,7 +84,7 @@ PutEnv(TC.name, file); ec = GetTestEC(); ret = temp_directory_path(ec); - LIBCPP_ONLY(TEST_CHECK(ec == expect_ec)); + LIBCPP_ONLY(TEST_CHECK(ErrorIs(ec, expect_errc))); TEST_CHECK(ec != GetTestEC()); TEST_CHECK(ec); TEST_CHECK(ret == ""); @@ -93,7 +93,7 @@ PutEnv(TC.name, nested_dir); ec = GetTestEC(); ret = temp_directory_path(ec); - TEST_CHECK(ec == std::make_error_code(std::errc::permission_denied)); + TEST_CHECK(ErrorIs(ec, std::errc::permission_denied)); TEST_CHECK(ret == ""); // Set the env variable to point to a non-existent dir Index: libcxx/test/support/filesystem_test_helper.h =================================================================== --- libcxx/test/support/filesystem_test_helper.h +++ libcxx/test/support/filesystem_test_helper.h @@ -560,8 +560,9 @@ inline bool ErrorIsImp(const std::error_code& ec, std::vector const& errors) { + std::error_condition cond = ec.default_error_condition(); for (auto errc : errors) { - if (ec == std::make_error_code(errc)) + if (cond.value() == (int)errc) return true; } return false;