66 * LICENSE file in the root directory of this source tree.
77 */
88
9- #ifdef EXECUTORCH_FB_BUCK
10- #include < TestResourceUtils/TestResourceUtils.h>
11- #endif
9+ // #ifdef EXECUTORCH_FB_BUCK
10+ // #include <TestResourceUtils/TestResourceUtils.h>
11+ // #endif
1212#include < executorch/extension/llm/tokenizer/tiktoken.h>
1313#include < executorch/runtime/platform/runtime.h>
1414#include < gmock/gmock.h>
1515#include < gtest/gtest.h>
1616#include < vector>
1717
18+ #include < gtest/gtest.h>
19+
1820using namespace ::testing;
1921using ::executorch::extension::llm::Tiktoken;
2022using ::executorch::extension::llm::Tokenizer;
@@ -50,13 +52,15 @@ static inline std::unique_ptr<std::vector<std::string>> _get_special_tokens() {
5052 return special_tokens;
5153}
5254
53- static inline std::string _get_resource_path (const std::string& name) {
54- #ifdef EXECUTORCH_FB_BUCK
55- return facebook::xplat::testing::getPathForTestResource (" resources/" + name);
56- #else
57- return std::getenv (" RESOURCES_PATH" ) + std::string (" /" ) + name;
58- #endif
59- }
55+ // static inline std::string _get_resource_path(const std::string& name) {
56+ // return std::get_env(name);
57+ // #ifdef EXECUTORCH_FB_BUCK
58+ // return facebook::xplat::testing::getPathForTestResource("resources/" +
59+ // name);
60+ // #else
61+ // return std::getenv("RESOURCES_PATH") + std::string("/") + name;
62+ // #endif
63+ // }
6064
6165} // namespace
6266
@@ -66,7 +70,7 @@ class TiktokenExtensionTest : public Test {
6670 executorch::runtime::runtime_init ();
6771 tokenizer_ = std::make_unique<Tiktoken>(
6872 _get_special_tokens (), kBOSTokenIndex , kEOSTokenIndex );
69- modelPath_ = _get_resource_path ( " test_tiktoken_tokenizer.model " );
73+ modelPath_ = std::get_env ( " TEST_TIKTOKEN_TOKENIZER " );
7074 }
7175
7276 std::unique_ptr<Tokenizer> tokenizer_;
@@ -160,30 +164,28 @@ TEST_F(TiktokenExtensionTest, LoadWithInvalidPath) {
160164}
161165
162166TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithInvalidRank) {
163- auto invalidModelPath =
164- _get_resource_path (" test_tiktoken_invalid_rank.model" );
167+ auto invalidModelPath = std::get_env (" TEST_TIKTOKEN_INVALID_RANK" );
165168 Error res = tokenizer_->load (invalidModelPath.c_str ());
166169
167170 EXPECT_EQ (res, Error::InvalidArgument);
168171}
169172
170173TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithInvalidBase64) {
171- auto invalidModelPath =
172- _get_resource_path (" test_tiktoken_invalid_base64.model" );
174+ auto invalidModelPath = std::get_env (" TEST_TIKTOKEN_INVALID_BASE64" );
173175 Error res = tokenizer_->load (invalidModelPath.c_str ());
174176
175177 EXPECT_EQ (res, Error::InvalidArgument);
176178}
177179
178180TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithNoSpace) {
179- auto invalidModelPath = _get_resource_path ( " test_tiktoken_no_space.model " );
180- Error res = tokenizer_->load (invalidModelPath.c_str ());
181+ auto invalidModelPath = std::get_env ( " TEST_TIKTOKEN_NO_SPACE " ) Error res =
182+ tokenizer_->load (invalidModelPath.c_str ());
181183
182184 EXPECT_EQ (res, Error::InvalidArgument);
183185}
184186
185187TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithBPEFile) {
186- auto invalidModelPath = _get_resource_path ( " test_bpe_tokenizer.bin " );
188+ auto invalidModelPath = std::get_env ( " TEST_BPE_TOKENIZER " );
187189 Error res = tokenizer_->load (invalidModelPath.c_str ());
188190
189191 EXPECT_EQ (res, Error::InvalidArgument);
0 commit comments