Skip to content

Commit 77fcd66

Browse files
committed
Implement the entire test suite into Rig
This is the first step in making the test suite work on Windows. And after this point, Rig is now the official way to develop `bc` and `dc because it's the only thing that runs the full test suite. Yes, I actually stopped the POSIX make build from running the whole test suite. The reason I did that is because some tests were one-offs, and I don't want to maintain those one-offs in two places. Instead, I put them all into Rig. However, most tests are basically plain text files (input for the calculators) with shell scripts or Rig to marshall them. I kept those in the POSIX make build by hooking them into the `tests/all.sh` script and having the POSIX make build use that instead. So POSIX make will still run the test suite, and most of it, but it doesn't have *all* of it anymore. This allowed me to take out some gnarly generation code in the configure script as well. I also did some refactoring in the Rig test suite. I also made the `dc` Easter script an actual script test. Signed-off-by: Gavin D. Howard <[email protected]>
1 parent 002f5dd commit 77fcd66

File tree

17 files changed

+1408
-1755
lines changed

17 files changed

+1408
-1755
lines changed

Makefile.in

Lines changed: 18 additions & 261 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ BC_FUZZER_C = $(BIN)/$(BC)_fuzzer_C
101101
DC_FUZZER = $(BIN)/$(DC)_fuzzer_c
102102
DC_FUZZER_C = $(BIN)/$(DC)_fuzzer_C
103103

104-
BC_TEST_OUTPUTS = tests/bc_outputs
105104
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
106-
DC_TEST_OUTPUTS = tests/dc_outputs
107105
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
108106

109107
LIB = libbcl
110108
LIB_NAME = $(LIB).a
111109
LIBBC = $(BIN)/$(LIB_NAME)
112110
BCL = bcl
113-
BCL_TEST = $(BIN)/$(BCL)
114-
BCL_TEST_C = $(TESTSDIR)/$(BCL).c
111+
112+
GENERATE_TESTS = %%GENERATE_TESTS%%
113+
PROBLEMATIC_TESTS = %%PROBLEMATIC_TESTS%%
115114

116115
MANUALS = manuals
117116
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
@@ -154,11 +153,11 @@ BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
154153
BC_ENABLE_NLS = %%NLS%%
155154
BC_EXCLUDE_EXTRA_MATH = %%EXCLUDE_EXTRA_MATH%%
156155

157-
BC_ENABLE_AFL = %%FUZZ%%
158-
BC_ENABLE_OSSFUZZ = %%OSSFUZZ%%
159-
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
156+
BC_ENABLE_AFL = 0
157+
BC_ENABLE_OSSFUZZ = 0
158+
BC_ENABLE_MEMCHECK = 0
160159

161-
LIB_FUZZING_ENGINE = %%LIB_FUZZING_ENGINE%%
160+
LIB_FUZZING_ENGINE = 0
162161

163162
BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
164163
BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
@@ -191,10 +190,6 @@ KARATSUBA = $(SCRIPTSDIR)/karatsuba.py
191190
LOCALE_INSTALL = $(SCRIPTSDIR)/locale_install.sh
192191
LOCALE_UNINSTALL = $(SCRIPTSDIR)/locale_uninstall.sh
193192

194-
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
195-
196-
TEST_STARS = ***********************************************************************
197-
198193
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
199194

200195
BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
@@ -295,236 +290,10 @@ help:
295290
@printf ' check alias for `make test`\n'
296291
@printf ' clean removes all build files\n'
297292
@printf ' clean_config removes all build files as well as the generated Makefile\n'
298-
@printf ' clean_tests removes all build files, the generated Makefile,\n'
299-
@printf ' and generated tests\n'
300293
@printf ' install installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
301294
@printf ' and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
302-
@printf ' karatsuba runs the karatsuba script (requires Python 3)\n'
303-
@printf ' karatsuba_test runs the karatsuba script while running tests\n'
304-
@printf ' (requires Python 3)\n'
305295
@printf ' uninstall uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
306296
@printf ' and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
307-
@printf ' test runs the test suite\n'
308-
@printf ' test_bc runs the bc test suite, if bc has been built\n'
309-
@printf ' test_dc runs the dc test suite, if dc has been built\n'
310-
@printf ' time_test runs the test suite, displaying times for some things\n'
311-
@printf ' time_test_bc runs the bc test suite, displaying times for some things\n'
312-
@printf ' time_test_dc runs the dc test suite, displaying times for some things\n'
313-
@printf ' timeconst runs the test on the Linux timeconst.bc script,\n'
314-
@printf ' if it exists and bc has been built\n'
315-
316-
run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
317-
318-
run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np
319-
320-
bc_all_tests:
321-
%%BC_ALL_TESTS%%
322-
323-
bc_all_tests_np:
324-
%%BC_ALL_TESTS_NP%%
325-
326-
timeconst_all_tests:
327-
%%TIMECONST_ALL_TESTS%%
328-
329-
dc_all_tests:
330-
%%DC_ALL_TESTS%%
331-
332-
dc_all_tests_np:
333-
%%DC_ALL_TESTS_NP%%
334-
335-
history_all_tests:
336-
%%HISTORY_TESTS%%
337-
338-
check: test
339-
340-
test: %%TESTS%%
341-
342-
test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other
343-
@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
344-
345-
test_bc_tests:%%BC_TESTS%%
346-
347-
test_bc_scripts:%%BC_SCRIPT_TESTS%%
348-
349-
test_bc_stdin:
350-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh bc %%BC_TEST_EXEC%%
351-
352-
test_bc_read:
353-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh bc %%BC_TEST_EXEC%%
354-
355-
test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%
356-
357-
test_bc_error_lines:
358-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh bc %%BC_TEST_EXEC%%
359-
360-
test_bc_other:
361-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%%
362-
363-
test_bc_header:
364-
@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
365-
366-
test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other
367-
@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
368-
369-
test_dc_tests:%%DC_TESTS%%
370-
371-
test_dc_scripts:%%DC_SCRIPT_TESTS%%
372-
373-
test_dc_stdin:
374-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh dc %%DC_TEST_EXEC%%
375-
376-
test_dc_read:
377-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh dc %%DC_TEST_EXEC%%
378-
379-
test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%
380-
381-
test_dc_error_lines:
382-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh dc %%DC_TEST_EXEC%%
383-
384-
test_dc_other:
385-
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%%
386-
387-
test_dc_header:
388-
@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
389-
390-
timeconst:
391-
%%TIMECONST%%
392-
393-
test_history: test_history_header test_bc_history test_dc_history
394-
@printf '\nAll history tests passed.\n\n$(TEST_STARS)\n'
395-
396-
test_bc_history:%%BC_HISTORY_TEST_PREREQS%%
397-
398-
test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21
399-
400-
test_bc_history_skip:
401-
@printf 'No bc history tests to run\n'
402-
403-
test_bc_history0:
404-
@sh $(TESTSDIR)/history.sh bc 0 %%BC_TEST_EXEC%%
405-
406-
test_bc_history1:
407-
@sh $(TESTSDIR)/history.sh bc 1 %%BC_TEST_EXEC%%
408-
409-
test_bc_history2:
410-
@sh $(TESTSDIR)/history.sh bc 2 %%BC_TEST_EXEC%%
411-
412-
test_bc_history3:
413-
@sh $(TESTSDIR)/history.sh bc 3 %%BC_TEST_EXEC%%
414-
415-
test_bc_history4:
416-
@sh $(TESTSDIR)/history.sh bc 4 %%BC_TEST_EXEC%%
417-
418-
test_bc_history5:
419-
@sh $(TESTSDIR)/history.sh bc 5 %%BC_TEST_EXEC%%
420-
421-
test_bc_history6:
422-
@sh $(TESTSDIR)/history.sh bc 6 %%BC_TEST_EXEC%%
423-
424-
test_bc_history7:
425-
@sh $(TESTSDIR)/history.sh bc 7 %%BC_TEST_EXEC%%
426-
427-
test_bc_history8:
428-
@sh $(TESTSDIR)/history.sh bc 8 %%BC_TEST_EXEC%%
429-
430-
test_bc_history9:
431-
@sh $(TESTSDIR)/history.sh bc 9 %%BC_TEST_EXEC%%
432-
433-
test_bc_history10:
434-
@sh $(TESTSDIR)/history.sh bc 10 %%BC_TEST_EXEC%%
435-
436-
test_bc_history11:
437-
@sh $(TESTSDIR)/history.sh bc 11 %%BC_TEST_EXEC%%
438-
439-
test_bc_history12:
440-
@sh $(TESTSDIR)/history.sh bc 12 %%BC_TEST_EXEC%%
441-
442-
test_bc_history13:
443-
@sh $(TESTSDIR)/history.sh bc 13 %%BC_TEST_EXEC%%
444-
445-
test_bc_history14:
446-
@sh $(TESTSDIR)/history.sh bc 14 %%BC_TEST_EXEC%%
447-
448-
test_bc_history15:
449-
@sh $(TESTSDIR)/history.sh bc 15 %%BC_TEST_EXEC%%
450-
451-
test_bc_history16:
452-
@sh $(TESTSDIR)/history.sh bc 16 %%BC_TEST_EXEC%%
453-
454-
test_bc_history17:
455-
@sh $(TESTSDIR)/history.sh bc 17 %%BC_TEST_EXEC%%
456-
457-
test_bc_history18:
458-
@sh $(TESTSDIR)/history.sh bc 18 %%BC_TEST_EXEC%%
459-
460-
test_bc_history19:
461-
@sh $(TESTSDIR)/history.sh bc 19 %%BC_TEST_EXEC%%
462-
463-
test_bc_history20:
464-
@sh $(TESTSDIR)/history.sh bc 20 %%BC_TEST_EXEC%%
465-
466-
test_bc_history21:
467-
@sh $(TESTSDIR)/history.sh bc 21 %%BC_TEST_EXEC%%
468-
469-
test_dc_history:%%DC_HISTORY_TEST_PREREQS%%
470-
471-
test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 test_dc_history10
472-
473-
test_dc_history_skip:
474-
@printf 'No dc history tests to run\n'
475-
476-
test_dc_history0:
477-
@sh $(TESTSDIR)/history.sh dc 0 %%DC_TEST_EXEC%%
478-
479-
test_dc_history1:
480-
@sh $(TESTSDIR)/history.sh dc 1 %%DC_TEST_EXEC%%
481-
482-
test_dc_history2:
483-
@sh $(TESTSDIR)/history.sh dc 2 %%DC_TEST_EXEC%%
484-
485-
test_dc_history3:
486-
@sh $(TESTSDIR)/history.sh dc 3 %%DC_TEST_EXEC%%
487-
488-
test_dc_history4:
489-
@sh $(TESTSDIR)/history.sh dc 4 %%DC_TEST_EXEC%%
490-
491-
test_dc_history5:
492-
@sh $(TESTSDIR)/history.sh dc 5 %%DC_TEST_EXEC%%
493-
494-
test_dc_history6:
495-
@sh $(TESTSDIR)/history.sh dc 6 %%DC_TEST_EXEC%%
496-
497-
test_dc_history7:
498-
@sh $(TESTSDIR)/history.sh dc 7 %%DC_TEST_EXEC%%
499-
500-
test_dc_history8:
501-
@sh $(TESTSDIR)/history.sh dc 8 %%DC_TEST_EXEC%%
502-
503-
test_dc_history9:
504-
@sh $(TESTSDIR)/history.sh dc 9 %%DC_TEST_EXEC%%
505-
506-
test_dc_history10:
507-
@sh $(TESTSDIR)/history.sh dc 10 %%DC_TEST_EXEC%%
508-
509-
test_history_header:
510-
@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'
511-
512-
library_test: $(LIBBC)
513-
$(CC) $(CFLAGS) -lpthread $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
514-
515-
test_library: library_test
516-
%%BCL_TEST_EXEC%%
517-
518-
karatsuba:
519-
%%KARATSUBA%%
520-
521-
karatsuba_test:
522-
%%KARATSUBA_TEST%%
523-
524-
coverage_output:
525-
%%COVERAGE_OUTPUT%%
526-
527-
coverage:%%COVERAGE_PREREQS%%
528297

529298
manpages:
530299
$(MANPAGE) bc
@@ -561,37 +330,25 @@ clean_config: clean clean_benchmarks
561330
@$(RM) -f compile_commands.json
562331
@$(RM) -f $(BCL_PC)
563332

564-
clean_coverage:
565-
@printf 'Cleaning coverage files...\n'
566-
@$(RM) -f *.gcov
567-
@$(RM) -f *.html *.css
568-
@$(RM) -f *.gcda *.gcno
569-
@$(RM) -f *.profraw
570-
@$(RM) -f $(GCDA) $(GCNO)
571-
@$(RM) -f $(BC_GCDA) $(BC_GCNO)
572-
@$(RM) -f $(DC_GCDA) $(DC_GCNO)
573-
@$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
574-
@$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
575-
@$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
576-
@$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
577-
@$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
578-
@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
579-
580-
clean_tests: clean clean_config clean_coverage
333+
test:
334+
@if [ $(BC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n bc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(BC_EXEC); fi
335+
@if [ $(DC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n dc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(DC_EXEC); fi
336+
337+
clean_tests: clean clean_config
581338
@printf 'Cleaning test files...\n'
582339
@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
583340
@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
584-
@$(RM) -f $(TESTSDIR)/bc/parse.txt $(TESTSDIR)/bc/parse_results.txt
585-
@$(RM) -f $(TESTSDIR)/bc/print.txt $(TESTSDIR)/bc/print_results.txt
341+
@$(RM) -f $(TESTSDIR)/bc/parse_*.txt $(TESTSDIR)/bc/parse_*_results.txt
342+
@$(RM) -f $(TESTSDIR)/bc/print_*.txt $(TESTSDIR)/bc/print_*_results.txt
586343
@$(RM) -f $(TESTSDIR)/bc/bessel.txt $(TESTSDIR)/bc/bessel_results.txt
587344
@$(RM) -f $(TESTSDIR)/bc/strings2.txt $(TESTSDIR)/bc/strings2_results.txt
588345
@$(RM) -f $(TESTSDIR)/bc/scripts/bessel.txt
589346
@$(RM) -f $(TESTSDIR)/bc/scripts/parse.txt
590347
@$(RM) -f $(TESTSDIR)/bc/scripts/print.txt
591-
@$(RM) -f $(TESTSDIR)/bc/scripts/add.txt
592-
@$(RM) -f $(TESTSDIR)/bc/scripts/divide.txt
593-
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply.txt
594-
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract.txt
348+
@$(RM) -f $(TESTSDIR)/bc/scripts/add_*.txt
349+
@$(RM) -f $(TESTSDIR)/bc/scripts/divide_*.txt
350+
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply_*.txt
351+
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract_*.txt
595352
@$(RM) -f $(TESTSDIR)/bc/scripts/strings2.txt
596353
@$(RM) -f $(TESTSDIR)/dc/scripts/prime.txt
597354
@$(RM) -f .log_*.txt

build.gaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ presets: {
7575
dc_default_sigint_reset: true
7676
bc_default_tty_mode: true
7777
dc_default_tty_mode: false
78-
bc_default_prompt: ""
79-
dc_default_prompt: ""
78+
bc_default_prompt: @off
79+
dc_default_prompt: @off
8080
bc_default_expr_exit: true
8181
dc_default_expr_exit: true
8282
bc_default_digit_clamp: false
@@ -94,8 +94,8 @@ presets: {
9494
dc_default_sigint_reset: false
9595
bc_default_tty_mode: true
9696
dc_default_tty_mode: false
97-
bc_default_prompt: ""
98-
dc_default_prompt: ""
97+
bc_default_prompt: @tty_mode
98+
dc_default_prompt: @tty_mode
9999
bc_default_expr_exit: true
100100
dc_default_expr_exit: true
101101
bc_default_digit_clamp: false
@@ -111,8 +111,8 @@ presets: {
111111
dc/default_sigint_reset: true
112112
bc/default_tty_mode: true
113113
dc/default_tty_mode: true
114-
bc/default_prompt: ""
115-
dc/default_prompt: ""
114+
bc/default_prompt: @tty_mode
115+
dc/default_prompt: @tty_mode
116116
bc/default_expr_exit: false
117117
dc/default_expr_exit: false
118118
bc/default_digit_clamp: true
@@ -130,8 +130,8 @@ presets: {
130130
dc/default_sigint_reset: true
131131
bc/default_tty_mode: true
132132
dc/default_tty_mode: true
133-
bc/default_prompt: ""
134-
dc/default_prompt: ""
133+
bc/default_prompt: @tty_mode
134+
dc/default_prompt: @tty_mode
135135
bc/default_expr_exit: false
136136
dc/default_expr_exit: false
137137
bc/default_digit_clamp: true

0 commit comments

Comments
 (0)