Make --run-tests less verbose by default

Adding --debug-trace or --debug-dump-disasm before --run-tests now makes
it verbose.
This commit is contained in:
Nicolas Williams committed 2015-06-27 23:31:44 -05:00
1 parent 32c4759e6b
commit 6c89186437
2 files changed
+14 -10

No files matched your search

+10 -8
View File
@@ -6,10 +6,10 @@
#include "jq.h"
static void jv_test();
static void run_jq_tests();
static void run_jq_tests(jv, int, FILE *);
int jq_testsuite(jv libdirs, int argc, char* argv[]) {
int jq_testsuite(jv libdirs, int verbose, int argc, char* argv[]) {
FILE *testdata = stdin;
jv_test();
if (argc > 0) {
@@ -19,7 +19,7 @@ int jq_testsuite(jv libdirs, int argc, char* argv[]) {
exit(1);
}
}
run_jq_tests(libdirs, testdata);
run_jq_tests(libdirs, verbose, testdata);
return 0;
}
@@ -53,7 +53,7 @@ static void test_err_cb(void *data, jv e) {
jv_free(e);
}
static void run_jq_tests(jv lib_dirs, FILE *testdata) {
static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) {
char prog[4096];
char buf[4096];
struct err_data err_msg;
@@ -119,9 +119,11 @@ static void run_jq_tests(jv lib_dirs, FILE *testdata) {
}
continue;
}
printf("Disassembly:\n");
jq_dump_disassembly(jq, 2);
printf("\n");
if (verbose) {
printf("Disassembly:\n");
jq_dump_disassembly(jq, 2);
printf("\n");
}
if (!fgets(buf, sizeof(buf), testdata)) { invalid++; break; }
lineno++;
jv input = jv_parse(buf);
@@ -130,7 +132,7 @@ static void run_jq_tests(jv lib_dirs, FILE *testdata) {
invalid++;
continue;
}
jq_start(jq, input, JQ_DEBUG_TRACE);
jq_start(jq, input, verbose ? JQ_DEBUG_TRACE : 0);
while (fgets(buf, sizeof(buf), testdata)) {
lineno++;
+4 -2
View File
@@ -24,7 +24,7 @@
#include "util.h"
#include "version.h"
int jq_testsuite(jv lib_dirs, int argc, char* argv[]);
int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);
static const char* progname;
@@ -409,7 +409,9 @@ int main(int argc, char* argv[]) {
i++;
// XXX Pass program_arguments, even a whole jq_state *, through;
// could be useful for testing
ret = jq_testsuite(lib_search_paths, argc - i, argv + i);
ret = jq_testsuite(lib_search_paths,
(options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),
argc - i, argv + i);
goto out;
}