Generate TypeScript code
| 82 | |
| 83 | // Generate TypeScript code |
| 84 | void GenerateTsOpFileText(const string& op_def_str, const string& api_def_str, |
| 85 | string* ts_file_text) { |
| 86 | Env* env = Env::Default(); |
| 87 | OpList op_defs; |
| 88 | protobuf::TextFormat::ParseFromString( |
| 89 | op_def_str.empty() ? kBaseOpDef : op_def_str, &op_defs); |
| 90 | ApiDefMap api_def_map(op_defs); |
| 91 | |
| 92 | if (!api_def_str.empty()) { |
| 93 | TF_ASSERT_OK(api_def_map.LoadApiDef(api_def_str)); |
| 94 | } |
| 95 | |
| 96 | const string& tmpdir = testing::TmpDir(); |
| 97 | const auto ts_file_path = io::JoinPath(tmpdir, "test.ts"); |
| 98 | |
| 99 | WriteTSOps(op_defs, api_def_map, ts_file_path); |
| 100 | TF_ASSERT_OK(ReadFileToString(env, ts_file_path, ts_file_text)); |
| 101 | } |
| 102 | |
| 103 | TEST(TsOpGenTest, TestImports) { |
| 104 | string ts_file_text; |
no test coverage detected