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>
@@ -50,13 +50,15 @@ static inline std::unique_ptr<std::vector<std::string>> _get_special_tokens() {
5050 return special_tokens;
5151}
5252
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- }
53+ // static inline std::string _get_resource_path(const std::string& name) {
54+ // return std::get_env(name);
55+ // #ifdef EXECUTORCH_FB_BUCK
56+ // return facebook::xplat::testing::getPathForTestResource("resources/" +
57+ // name);
58+ // #else
59+ // return std::getenv("RESOURCES_PATH") + std::string("/") + name;
60+ // #endif
61+ // }
6062
6163} // namespace
6264
@@ -66,7 +68,7 @@ class TiktokenExtensionTest : public Test {
6668 executorch::runtime::runtime_init ();
6769 tokenizer_ = std::make_unique<Tiktoken>(
6870 _get_special_tokens (), kBOSTokenIndex , kEOSTokenIndex );
69- modelPath_ = _get_resource_path ( " test_tiktoken_tokenizer.model " );
71+ modelPath_ = std::get_env ( " TEST_TIKTOKEN_TOKENIZER " );
7072 }
7173
7274 std::unique_ptr<Tokenizer> tokenizer_;
@@ -160,30 +162,28 @@ TEST_F(TiktokenExtensionTest, LoadWithInvalidPath) {
160162}
161163
162164TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithInvalidRank) {
163- auto invalidModelPath =
164- _get_resource_path (" test_tiktoken_invalid_rank.model" );
165+ auto invalidModelPath = std::get_env (" TEST_TIKTOKEN_INVALID_RANK" );
165166 Error res = tokenizer_->load (invalidModelPath.c_str ());
166167
167168 EXPECT_EQ (res, Error::InvalidArgument);
168169}
169170
170171TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithInvalidBase64) {
171- auto invalidModelPath =
172- _get_resource_path (" test_tiktoken_invalid_base64.model" );
172+ auto invalidModelPath = std::get_env (" TEST_TIKTOKEN_INVALID_BASE64" );
173173 Error res = tokenizer_->load (invalidModelPath.c_str ());
174174
175175 EXPECT_EQ (res, Error::InvalidArgument);
176176}
177177
178178TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithNoSpace) {
179- auto invalidModelPath = _get_resource_path ( " test_tiktoken_no_space.model " );
180- Error res = tokenizer_->load (invalidModelPath.c_str ());
179+ auto invalidModelPath = std::get_env ( " TEST_TIKTOKEN_NO_SPACE " ) Error res =
180+ tokenizer_->load (invalidModelPath.c_str ());
181181
182182 EXPECT_EQ (res, Error::InvalidArgument);
183183}
184184
185185TEST_F (TiktokenExtensionTest, LoadTiktokenFileWithBPEFile) {
186- auto invalidModelPath = _get_resource_path ( " test_bpe_tokenizer.bin " );
186+ auto invalidModelPath = std::get_env ( " TEST_BPE_TOKENIZER " );
187187 Error res = tokenizer_->load (invalidModelPath.c_str ());
188188
189189 EXPECT_EQ (res, Error::InvalidArgument);
0 commit comments