MCPcopy Create free account
hub / github.com/apache/arrow / CheckExpectedErrno

Method CheckExpectedErrno

cpp/src/arrow/filesystem/azurefs_test.cc:1883–1925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1881 }
1882
1883 Status CheckExpectedErrno(const std::string& src, const std::string& dest,
1884 std::optional<int> expected_errno,
1885 const char* expected_errno_name, FileInfo* out_src_info) {
1886 auto the_fs = fs();
1887 const bool src_trailing_slash = internal::HasTrailingSlash(src);
1888 const bool dest_trailing_slash = internal::HasTrailingSlash(dest);
1889 const auto src_path = std::string{internal::RemoveTrailingSlash(src)};
1890 const auto dest_path = std::string{internal::RemoveTrailingSlash(dest)};
1891 ARROW_ASSIGN_OR_RAISE(*out_src_info, the_fs->GetFileInfo(src_path));
1892 ARROW_ASSIGN_OR_RAISE(auto dest_info, the_fs->GetFileInfo(dest_path));
1893 bool dest_is_empty_dir = false;
1894 if (dest_info.type() == FileType::Directory) {
1895 FileSelector select;
1896 select.base_dir = dest_path;
1897 select.recursive = false;
1898 // TODO(ARROW-40014): investigate why this can't be false here
1899 select.allow_not_found = true;
1900 ARROW_ASSIGN_OR_RAISE(auto dest_contents, the_fs->GetFileInfo(select));
1901 if (dest_contents.empty()) {
1902 dest_is_empty_dir = true;
1903 }
1904 }
1905 auto paths_are_equal = src_path == dest_path;
1906 auto truly_expected_errno =
1907 RenameSemantics(out_src_info->type(), src_trailing_slash, dest_info.type(),
1908 dest_trailing_slash, dest_is_empty_dir, paths_are_equal);
1909 if (truly_expected_errno != expected_errno) {
1910 if (expected_errno.has_value()) {
1911 return Status::Invalid("expected_errno=", expected_errno_name, "=",
1912 *expected_errno,
1913 " used in ASSERT_MOVE is incorrect. "
1914 "POSIX semantics for this scenario require errno=",
1915 strerror(truly_expected_errno.value_or(0)));
1916 } else {
1917 DCHECK(truly_expected_errno.has_value());
1918 return Status::Invalid(
1919 "ASSERT_MOVE used to assert success in a scenario for which "
1920 "POSIX semantics requires errno=",
1921 strerror(*truly_expected_errno));
1922 }
1923 }
1924 return Status::OK();
1925 }
1926
1927 void AssertAfterMove(const std::string& src, const std::string& dest, FileType type) {
1928 if (internal::RemoveTrailingSlash(src) != internal::RemoveTrailingSlash(dest)) {

Callers

nothing calls this directly

Calls 9

fsFunction · 0.85
HasTrailingSlashFunction · 0.85
RemoveTrailingSlashFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
InvalidFunction · 0.50
OKFunction · 0.50
GetFileInfoMethod · 0.45
typeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected