From 9a2a61ca289aeee256e104dda807431380eba319 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Wed, 17 Jun 2026 03:29:44 +0200 Subject: cli: reject unknown --options instead of treating them as text --- tests/test_cli.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/test_cli.c b/tests/test_cli.c index 8d56f09..7543717 100644 --- a/tests/test_cli.c +++ b/tests/test_cli.c @@ -178,6 +178,16 @@ int main(int argc, char **argv) { for (size_t i = 0; i < sizeof(bad) / sizeof(bad[0]); i++) expect(run_cli(bad[i].args, NULL) == 1, bad[i].what); + /* Unknown --options fail loudly instead of being silently embedded as text + * (guards against typos and removed flags like --backend). A bare -- ends + * option parsing so dash-prefixed text can still be embedded. */ + snprintf(args, sizeof(args), "-d '%s' --backend cuda hi", g_dir); + expect(run_cli(args, NULL) == 1, "unknown --option exits 1"); + expect(file_contains(g_err, "unknown option"), "unknown --option names the flag"); + snprintf(args, sizeof(args), "-d '%s' -- '-dashy text'", g_dir); + expect(run_cli(args, NULL) == 0, "-- terminator allows dash-prefixed text"); + expect(stdout_is_embedding(dims.hidden), "dash text after -- embeds as one input"); + if (g_failures) { fprintf(stderr, "%d CLI check(s) failed\n", g_failures); return 1; -- cgit v1.3.1