mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Combine the functionality of jq and jq_test
One binary is much simpler. ./jq --run-tests now runs the tests.
This commit is contained in:
6
Makefile
6
Makefile
@ -27,15 +27,15 @@ main.c: version.gen.h
|
||||
JQ_SRC=parser.gen.c lexer.gen.c opcode.c bytecode.c compile.c execute.c builtin.c jv.c jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_alloc.c
|
||||
|
||||
jq_test: CFLAGS += -DJQ_DEBUG=1
|
||||
jq_test: $(JQ_SRC) jq_test.c
|
||||
jq_test: $(JQ_SRC) main.c jq_test.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_DEBUG) -o $@ $^
|
||||
|
||||
jq: CFLAGS += -O -DJQ_DEBUG=0
|
||||
jq: $(JQ_SRC) main.c
|
||||
jq: $(JQ_SRC) main.c jq_test.c
|
||||
$(CC) $(CFLAGS) $(CFLAGS_OPT) -o $@ $^
|
||||
|
||||
test: jq_test
|
||||
valgrind --error-exitcode=1 -q --leak-check=full ./jq_test >/dev/null
|
||||
valgrind --error-exitcode=1 -q --leak-check=full ./jq_test --run-tests >/dev/null
|
||||
|
||||
LIBRARIES=libjq
|
||||
BINARIES=jq jq_test
|
||||
|
@ -10,7 +10,7 @@ static void run_jq_tests();
|
||||
|
||||
FILE* testdata;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int jq_testsuite(int argc, char* argv[]) {
|
||||
jv_test();
|
||||
if (argc == 1) {
|
||||
testdata = fopen("testdata", "r");
|
||||
@ -26,6 +26,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
run_jq_tests();
|
||||
if (testdata != stdin) fclose(testdata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
6
main.c
6
main.c
@ -11,6 +11,8 @@
|
||||
#include "jv_alloc.h"
|
||||
#include "version.gen.h"
|
||||
|
||||
int jq_testsuite(int argc, char* argv[]);
|
||||
|
||||
static const char* progname;
|
||||
|
||||
static void usage() {
|
||||
@ -140,6 +142,10 @@ static int read_more(char* buf, size_t size) {
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc) progname = argv[0];
|
||||
|
||||
if (argc > 1 && !strcmp(argv[1], "--run-tests")) {
|
||||
return jq_testsuite(argc - 1, argv + 1);
|
||||
}
|
||||
|
||||
const char* program = 0;
|
||||
input_filenames = jv_mem_alloc(sizeof(const char*) * argc);
|
||||
ninput_files = 0;
|
||||
|
Reference in New Issue
Block a user