| 100 | }; |
| 101 | |
| 102 | TEST_F(ExpressionVerifierUnitTest, persistReproInfo) { |
| 103 | filesystems::registerLocalFileSystem(); |
| 104 | auto reproFolder = exec::test::TempDirectoryPath::create(); |
| 105 | const auto reproPath = reproFolder->path; |
| 106 | auto localFs = filesystems::getFileSystem(reproPath, nullptr); |
| 107 | |
| 108 | ExpressionVerifierOptions options{false, reproPath.c_str(), false}; |
| 109 | ExpressionVerifier verifier{&execCtx_, options}; |
| 110 | |
| 111 | auto testReproPersistency = [this]( |
| 112 | ExpressionVerifier& verifier, |
| 113 | const std::string& reproPath, |
| 114 | auto& localFs, |
| 115 | const bool forUserError, |
| 116 | const bool forRuntimeError) { |
| 117 | BOLT_USER_CHECK_NE(forUserError, forRuntimeError); |
| 118 | |
| 119 | auto data = makeRowVector({makeFlatVector<int32_t>({1, 2, 3})}); |
| 120 | auto plan = parseExpression("always_throws(c0)", asRowType(data->type())); |
| 121 | |
| 122 | removeDirecrtoryIfExist(localFs, reproPath); |
| 123 | if (forUserError) { |
| 124 | BOLT_ASSERT_THROW(verifier.verify({plan}, data, nullptr, false), ""); |
| 125 | } else { |
| 126 | EXPECT_NO_THROW(verifier.verify({plan}, data, nullptr, false)); |
| 127 | } |
| 128 | |
| 129 | EXPECT_TRUE(localFs->exists(reproPath)); |
| 130 | EXPECT_FALSE(localFs->list(reproPath).empty()); |
| 131 | removeDirecrtoryIfExist(localFs, reproPath); |
| 132 | }; |
| 133 | |
| 134 | // User errors. |
| 135 | { |
| 136 | registerFunction<AlwaysThrowsUserErrorFunction, int32_t, int32_t>( |
| 137 | {"always_throws"}); |
| 138 | testReproPersistency(verifier, reproPath, localFs, true, false); |
| 139 | } |
| 140 | |
| 141 | // Runtime errors. |
| 142 | { |
| 143 | registerFunction<AlwaysThrowsRuntimeErrorFunction, int32_t, int32_t>( |
| 144 | {"always_throws"}); |
| 145 | testReproPersistency(verifier, reproPath, localFs, false, true); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | } // namespace bytedance::bolt::test |
nothing calls this directly
no test coverage detected