MCPcopy Create free account
hub / github.com/apache/thrift / parse_thrift_for_test

Function parse_thrift_for_test

compiler/cpp/tests/cpp/t_cpp_generator_test_utils.h:119–148  ·  view source on GitHub ↗

Parse a thrift program for testing

Source from the content-addressed store, hash-verified

117
118// Parse a thrift program for testing
119inline void parse_thrift_for_test(t_program* program) {
120 REQUIRE(program != nullptr);
121
122 // These globals are used by the parser; see thrift/globals.h.
123 g_program = program;
124 g_scope = program->scope();
125 g_parent_scope = nullptr;
126 g_parent_prefix = program->get_name() + ".";
127
128 g_curpath = program->get_path();
129 g_curdir = directory_name(g_curpath);
130
131 // Pass 1: scan includes (even if none) to match the compiler behavior.
132 g_parse_mode = INCLUDES;
133 yylineno = 1;
134 yyin = std::fopen(g_curpath.c_str(), "r");
135 REQUIRE(yyin != nullptr);
136 REQUIRE(yyparse() == 0);
137 std::fclose(yyin);
138 yyin = nullptr;
139
140 // Pass 2: parse program.
141 g_parse_mode = PROGRAM;
142 yylineno = 1;
143 yyin = std::fopen(g_curpath.c_str(), "r");
144 REQUIRE(yyin != nullptr);
145 REQUIRE(yyparse() == 0);
146 std::fclose(yyin);
147 yyin = nullptr;
148}
149
150} // namespace cpp_generator_test_utils
151

Calls 3

scopeMethod · 0.80
directory_nameFunction · 0.50
get_nameMethod · 0.45

Tested by

no test coverage detected