wgtmac commented on code in PR #55407:
URL: https://github.com/apache/arrow/pull/55407#discussion_r4475900307
##########
cpp/src/parquet/encryption/write_configurations_test.cc:
##########
@@ -93,6 +116,35 @@ class TestEncryptionConfiguration : public ::testing::Test {
std::string file_name) {
std::string file = temp_dir->path().ToString() + file_name;
encryptor_.EncryptFile(file, encryption_configurations);
+ CopyToOutputDir(file, file_name);
+ }
+
+ static std::optional<std::string> GetOutputDir() {
+ auto maybe_output_dir =
+ ::arrow::internal::GetEnvVar("PARQUET_ENCRYPTION_TEST_OUTPUT_DIR");
+ if (!maybe_output_dir.ok()) {
+ return std::nullopt;
+ }
+ return maybe_output_dir.MoveValueUnsafe();
+ }
+
+ // Copy the file to the output directory if it is set, so the parquet-testing
+ // files can be regenerated.
+ void CopyToOutputDir(const std::string& file, const std::string& file_name)
const {
+ if (!output_dir_.has_value()) {
+ return;
+ }
+ std::string output_name = file_name;
+ const std::string tmp_prefix = "tmp_";
+ if (output_name.rfind(tmp_prefix, 0) == 0) {
+ output_name = output_name.substr(tmp_prefix.size());
+ }
+ std::ifstream src(file, std::ios::binary);
+ std::ofstream dst(*output_dir_ + "/" + output_name, std::ios::binary);
+ ASSERT_TRUE(src.good() && dst.good())
+ << "Failed to copy " << file << " to " << *output_dir_;
+ dst << src.rdbuf();
+ ASSERT_TRUE(dst.good()) << "Failed to write " << output_name;
Review Comment:
nit: please close `dst` explicitly and check its state afterwards, otherwise
it may report success with an incomplete file.
--
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]