From d927a2c18537fce25798cb024f6675d3ddac45af Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 12 Jan 2015 10:43:06 -0600 Subject: [PATCH] Fix --run-tests arg handling --- jq_test.c | 4 ++-- main.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jq_test.c b/jq_test.c index 8b9588a..6a00cab 100644 --- a/jq_test.c +++ b/jq_test.c @@ -12,8 +12,8 @@ static void run_jq_tests(); int jq_testsuite(jv libdirs, int argc, char* argv[]) { FILE *testdata = stdin; jv_test(); - if (argc > 2) { - testdata = fopen(argv[2], "r"); + if (argc > 0) { + testdata = fopen(argv[0], "r"); if (!testdata) { perror("fopen"); exit(1); diff --git a/main.c b/main.c index 4c6af61..0935f53 100644 --- a/main.c +++ b/main.c @@ -419,8 +419,11 @@ int main(int argc, char* argv[]) { goto out; } if (isoption(argv[i], 0, "run-tests", &short_opts)) { + i++; + // XXX Pass program_arguments, even a whole jq_state *, through; + // could be useful for testing jv_free(program_arguments); - ret = jq_testsuite(lib_search_paths, argc - i, argv + i + 1); + ret = jq_testsuite(lib_search_paths, argc - i, argv + i); goto out; } -- 2.40.0