From 82d5e91a6fe856eed8bd9747e6ae49feaf479c9a Mon Sep 17 00:00:00 2001 From: ochafik Date: Thu, 31 Oct 2024 00:10:44 +0000 Subject: [PATCH] `test-cli`: greedy sampling + print exception messages --- tests/test-cli.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/test-cli.cpp b/tests/test-cli.cpp index ce934cca8..8be29c6f8 100644 --- a/tests/test-cli.cpp +++ b/tests/test-cli.cpp @@ -53,24 +53,29 @@ static Out run(const std::string & cmd) { int main(int argc, char ** argv) { std::string cli_bin = argc == 2 ? argv[1] : "./llama-cli"; - std::system("mkdir out/"); + try { + std::system("mkdir out/"); - { - auto p = run(cli_bin + " --help"); - if (!p.err.empty()) - throw std::runtime_error("llama-cli --help should not have any stderr."); - assert_contains("example usage", p.out); - } + { + auto p = run(cli_bin + " --help"); + if (!p.err.empty()) + throw std::runtime_error("llama-cli --help should not have any stderr."); + assert_contains("example usage", p.out); + } - { - auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 -ngl 0 -n 10"); - assert_equals(" hello Joe and Joe we", p.out); - assert_contains("system_info:", p.err); - } + { + 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"); + assert_equals(" hello was a big, red ball. He", p.out); + assert_contains("system_info:", p.err); + } - { - auto p = run(cli_bin + " -hfr ggml-org/models -hff tinyllamas/stories260K.gguf --prompt hello --seed 42 -ngl 0 -n 10 --log-disable"); - assert_equals(" hello Joe and Joe we", p.out); - assert_equals("", p.err); + { + 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"); + assert_equals(" hello was a big, red ball. He", p.out); + assert_equals("", p.err); + } + } catch (const std::exception & ex) { + std::cerr << "[test-cli] Error: " << ex.what() << std::endl; + return 1; } }