wjones127 commented on a change in pull request #12536:
URL: https://github.com/apache/arrow/pull/12536#discussion_r833682123
##########
File path: cpp/src/arrow/public_api_test.cc
##########
@@ -103,4 +104,40 @@ TEST(Misc, BuildInfo) {
ASSERT_THAT(info.full_so_version, ::testing::HasSubstr(info.so_version));
}
+TEST(Misc, SetTimzoneConfig) {
+#ifndef _WIN32
+ GTEST_SKIP() << "Can only set the Timezone database on Windows";
+#else
+#ifndef ARROW_FILESYSTEM
+ GTEST_SKIP() << "Need filesystem support to test timezone config.";
+#else
+ auto fs = std::make_shared<arrow::fs::LocalFileSystem>();
+ auto home_raw = std::getenv("USERPROFILE");
+ std::string home = home_raw == nullptr ? "~" : std::string(home_raw);
+ ASSERT_OK_AND_ASSIGN(std::string tzdata_dir,
+ fs->NormalizePath(home + "\\Downloads\\tzdata"));
+ ASSERT_OK_AND_ASSIGN(auto tzdata_path,
+
arrow::internal::PlatformFilename::FromString(tzdata_dir));
+ if (!arrow::internal::FileExists(tzdata_path).ValueOr(false)) {
+ GTEST_SKIP() << "Couldn't find timezone database in expected dir: " <<
tzdata_dir;
+ }
+ // Create a tmp directory
+ ASSERT_OK_AND_ASSIGN(auto tempdir,
arrow::internal::TemporaryDir::Make("tzdata"));
+
+ // Validate that setting tzdb to that dir fails
+ arrow::ArrowGlobalOptions options =
{util::make_optional(tempdir->path().ToString())};
+ ASSERT_NOT_OK(arrow::Initialize(options));
+
+ // Copy tzdb data from ~/Downloads
+ auto selector = arrow::fs::FileSelector();
+ selector.base_dir = tzdata_dir;
+ selector.recursive = true;
+ ASSERT_OK(arrow::fs::CopyFiles(fs, selector, fs,
tempdir->path().ToString()));
+
+ // Validate that tzdb is working
+ ASSERT_OK(arrow::Initialize(options));
Review comment:
Good point. I'll see if I can add cleanup code to reset the
GlobalOptions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]