@@ -175,7 +175,7 @@ int main(int argc, char **argv) {
175
175
atexit ([]() { console::cleanup (); });
176
176
#endif
177
177
178
- bool success = true ;
178
+ int n_failed = 0 ;
179
179
180
180
const auto k_tests = [&]() -> llama_tests {
181
181
if (!fname_text.empty ()) {
@@ -214,22 +214,27 @@ int main(int argc, char **argv) {
214
214
}
215
215
216
216
if (!correct) {
217
- fprintf (stderr, " %s : failed test: '%s'\n " , __func__, test_kv.first .c_str ());
218
- fprintf (stderr, " %s : detokenized to: '%s' instead of '%s'\n " , __func__,
219
- llama_detokenize_bpe (ctx, res).c_str (),
220
- llama_detokenize_bpe (ctx, test_kv.second ).c_str ());
221
- fprintf (stderr, " %s : expected tokens: " , __func__);
217
+ fprintf (stderr, " failed test: '%s'\n " , test_kv.first .c_str ());
218
+ auto detok = llama_detokenize_bpe (ctx, res).c_str ();
219
+ auto expected = llama_detokenize_bpe (ctx, test_kv.second ).c_str ();
220
+ fprintf (stderr, " detokenized to: '%s'\n " , detok);
221
+ if (detok != expected) {
222
+ fprintf (stderr, " but we wanted: '%s'\n " , expected);
223
+ } else {
224
+ fprintf (stderr, " (which matches the expected output)\n " , expected);
225
+ }
226
+ fprintf (stderr, " expected tokens: \n " );
222
227
for (const auto & t : test_kv.second ) {
223
- fprintf (stderr, " %6d '%s', " , t, llama_token_to_piece (ctx, t).c_str ());
228
+ fprintf (stderr, " %6d '%s'\n " , t, llama_token_to_piece (ctx, t).c_str ());
224
229
}
225
230
fprintf (stderr, " \n " );
226
- fprintf (stderr, " %s : got tokens: " , __func__ );
231
+ fprintf (stderr, " got tokens: \n " );
227
232
for (const auto & t : res) {
228
- fprintf (stderr, " %6d '%s', " , t, llama_token_to_piece (ctx, t).c_str ());
233
+ fprintf (stderr, " %6d '%s'\n " , t, llama_token_to_piece (ctx, t).c_str ());
229
234
}
230
- fprintf (stderr, " \n " );
235
+ fprintf (stderr, " \n ==================== \n " );
231
236
232
- success = false ;
237
+ n_failed ++ ;
233
238
}
234
239
}
235
240
@@ -286,7 +291,11 @@ int main(int argc, char **argv) {
286
291
llama_backend_free ();
287
292
288
293
printf (" \n " );
289
- printf (" Tests %s\n " , success ? " passed" : " failed" );
294
+ if (n_failed) {
295
+ printf (" %d tests failed\n " , n_failed);
296
+ } else {
297
+ printf (" Tests passed\n " );
298
+ }
290
299
291
- return success ? 0 : 3 ;
300
+ return !n_failed ? 0 : 3 ;
292
301
}
0 commit comments