Skip to content

Commit 82d5e91

Browse files
author
ochafik
committed
test-cli: greedy sampling + print exception messages
1 parent 030fda0 commit 82d5e91

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

tests/test-cli.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,29 @@ static Out run(const std::string & cmd) {
5353
int main(int argc, char ** argv) {
5454
std::string cli_bin = argc == 2 ? argv[1] : "./llama-cli";
5555

56-
std::system("mkdir out/");
56+
try {
57+
std::system("mkdir out/");
5758

58-
{
59-
auto p = run(cli_bin + " --help");
60-
if (!p.err.empty())
61-
throw std::runtime_error("llama-cli --help should not have any stderr.");
62-
assert_contains("example usage", p.out);
63-
}
59+
{
60+
auto p = run(cli_bin + " --help");
61+
if (!p.err.empty())
62+
throw std::runtime_error("llama-cli --help should not have any stderr.");
63+
assert_contains("example usage", p.out);
64+
}
6465

65-
{
66-
auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 -ngl 0 -n 10");
67-
assert_equals(" hello Joe and Joe we", p.out);
68-
assert_contains("system_info:", p.err);
69-
}
66+
{
67+
auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 --samplers top-k --top-k 1 -ngl 0 -n 10");
68+
assert_equals(" hello was a big, red ball. He", p.out);
69+
assert_contains("system_info:", p.err);
70+
}
7071

71-
{
72-
auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 -ngl 0 -n 10 --log-disable");
73-
assert_equals(" hello Joe and Joe we", p.out);
74-
assert_equals("", p.err);
72+
{
73+
auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 --samplers top-k --top-k 1 -ngl 0 -n 10 --log-disable");
74+
assert_equals(" hello was a big, red ball. He", p.out);
75+
assert_equals("", p.err);
76+
}
77+
} catch (const std::exception & ex) {
78+
std::cerr << "[test-cli] Error: " << ex.what() << std::endl;
79+
return 1;
7580
}
7681
}

0 commit comments

Comments
 (0)