kpumuk commented on code in PR #3388: URL: https://github.com/apache/thrift/pull/3388#discussion_r3089817577
########## compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc: ########## @@ -0,0 +1,64 @@ +// Licensed to the Apache Software Foundation(ASF) under one +// or more contributor license agreements.See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership.The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "../cpp/t_cpp_generator_test_utils.h" + +#include <cstdio> +#include <fstream> +#include <memory> + +using std::map; +using std::string; +using cpp_generator_test_utils::parse_thrift_for_test; +using cpp_generator_test_utils::read_file; + +TEST_CASE("t_rb_generator emits bare marker for CRLF blank RDoc lines", "[functional]") +{ + const string thrift_path = "test_rdoc_crlf.thrift"; + const string thrift_source = + "/**\r\n" + " * first line\r\n" + " *\r\n" + " * second line\r\n" + " */\r\n" + "struct Example {\r\n" + " 1: string value\r\n" + "}\r\n"; + + { + std::ofstream thrift_file(thrift_path, std::ios::binary); + REQUIRE(thrift_file.is_open()); + thrift_file << thrift_source; + } + + map<string, string> parsed_options; + std::unique_ptr<t_program> program(new t_program(thrift_path, "test_rdoc_crlf")); + parse_thrift_for_test(program.get()); + + std::unique_ptr<t_generator> gen( + t_generator_registry::get_generator(program.get(), "rb", parsed_options, "")); + REQUIRE(gen != nullptr); + REQUIRE_NOTHROW(gen->generate_program()); + + const string generated_content = read_file("gen-rb/test_rdoc_crlf_types.rb"); + REQUIRE(!generated_content.empty()); + REQUIRE(generated_content.find("\r") == string::npos); + REQUIRE(generated_content.find("# * first line\n") != string::npos); + REQUIRE(generated_content.find("# *\n") != string::npos); + Review Comment: Confirmed. After introducing a `REQUIRE(false)`, get this: ``` root@a52d56f5da39:/thrift/src/cmake_build# cmake --build . [ 5%] Built target parse [ 48%] Built target thrift-compiler [ 89%] Built target thrift_compiler [ 91%] Building CXX object compiler/cpp/tests/CMakeFiles/thrift_compiler_tests.dir/rb/t_rb_generator_functional_tests.cc.o [ 92%] Linking CXX executable bin/thrift_compiler_tests [100%] Built target thrift_compiler_tests root@a52d56f5da39:/thrift/src/cmake_build# ctest Test project /thrift/src/cmake_build Start 1: php_const1_return 1/16 Test #1: php_const1_return ................ Passed 0.01 sec Start 2: php_enum1_return 2/16 Test #2: php_enum1_return ................. Passed 0.01 sec Start 3: php_enum2_return 3/16 Test #3: php_enum2_return ................. Passed 0.01 sec Start 4: php_exception1_return 4/16 Test #4: php_exception1_return ............ Passed 0.01 sec Start 5: php_exception2_return 5/16 Test #5: php_exception2_return ............ Passed 0.01 sec Start 6: php_service1_return 6/16 Test #6: php_service1_return .............. Passed 0.00 sec Start 7: php_service2_return 7/16 Test #7: php_service2_return .............. Passed 0.00 sec Start 8: php_service3_return 8/16 Test #8: php_service3_return .............. Passed 0.00 sec Start 9: php_service4_return 9/16 Test #9: php_service4_return .............. Passed 0.00 sec Start 10: php_struct1_return 10/16 Test #10: php_struct1_return ............... Passed 0.00 sec Start 11: php_struct2_return 11/16 Test #11: php_struct2_return ............... Passed 0.00 sec Start 12: php_typedef1_return 12/16 Test #12: php_typedef1_return .............. Passed 0.00 sec Start 13: php_union1_return 13/16 Test #13: php_union1_return ................ Passed 0.00 sec Start 14: php_union2_return 14/16 Test #14: php_union2_return ................ Passed 0.00 sec Start 15: StalenessCheckTest 15/16 Test #15: StalenessCheckTest ............... Passed 3.15 sec Start 16: ThriftCompilerTests 16/16 Test #16: ThriftCompilerTests ..............***Failed 0.03 sec 94% tests passed, 1 tests failed out of 16 Total Test time (real) = 3.27 sec The following tests FAILED: 16 - ThriftCompilerTests (Failed) Errors while running CTest Output from these tests are in: /thrift/src/cmake_build/Testing/Temporary/LastTest.log Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely. ``` -- 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]
