From 434ac778bf4679138cfdcc1622372c95d7aeb603 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Wed, 14 Oct 2026 23:21:20 +0300 Subject: [PATCH] build the unit tests and sextest from the root Each subdirectory's Makefile repeated the compiler's module list just to link one program, and its result was copied back to the root anyway. --- .gitignore | 1 - Makefile | 21 +++++++++++---------- tests/Makefile | 21 --------------------- tools/sextest/Makefile | 16 ---------------- 4 files changed, 11 insertions(+), 48 deletions(-) delete mode 100644 tests/Makefile delete mode 100644 tools/sextest/Makefile diff --git a/.gitignore b/.gitignore index db46251..24fcac1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ sexc sex-tests sextest -tools/sextest/sextest # Scrapped design docs, kept for reference /attic diff --git a/Makefile b/Makefile index 9886b6d..45cbf7d 100644 --- a/Makefile +++ b/Makefile @@ -67,14 +67,17 @@ sexc.o: fmt-c-writer.o infer.o reader.o semen.o sex-macros.o sex-modules.o types sex-fmt-c.o: sex-fmt-c.scm $(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) $< -o $@ -unit sex-fmt-c -# Unit testing. Both link the modules built here -sex-tests: $(OBJ) - $(MAKE) -C ./tests sex-tests - cp ./tests/sex-tests ./ +# Both link the modules built here, whose import libraries they find +# with the root on the repository path. The tests are built in their +# own directory, where their includes would otherwise find the modules' +# namesakes +WITH_ROOT_REPO = CHICKEN_REPOSITORY_PATH=$(CURDIR):$(CHICKEN_REPOSITORY_PATH) -sextest: reader.o utils.o - $(MAKE) -C ./tools/sextest sextest - cp ./tools/sextest/sextest . +sex-tests: $(wildcard tests/*.scm) $(OBJ) + cd tests && $(WITH_ROOT_REPO) $(CHICKEN_C) $(CSC_FLAGS) run.scm -o ../$@ -link sexc + +sextest: tools/sextest/sextest.scm reader.o utils.o + $(CHICKEN_C) $(CSC_FLAGS) $< -o $@ -link reader,utils SEX_TEST_PROGRAMS = c11 \ closure-signatures \ @@ -133,10 +136,8 @@ clean: rm -f *.import.scm rm -f *.link rm -f sexc sex-tests sextest - $(MAKE) -C ./tests clean $(MAKE) -C ./tests/modules clean - $(MAKE) -C ./tools/sextest clean .PHONY: all check run-tests check-modules check-exit-code \ install install-strip installdirs uninstall \ - clean sex-tests sextest + clean diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 1e9ac31..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -CHICKEN_C = csc - -CSC_FLAGS += -K prefix -static - -# The compiler's modules are built once, in the root; their import -# libraries and objects are found there through the repository path -ROOT = .. -export CHICKEN_REPOSITORY_PATH := $(abspath $(ROOT)):$(or $(CHICKEN_REPOSITORY_PATH),$(shell chicken-install -repository)) - -MODULES = utils types infer sex-macros reader sex-modules semen sex-fmt-c fmt-c-writer sexc - -TESTS = basic semen reader fmt-c-writer utils line-directives codegen encapsulation args module-path types infer -TEST_SRCS = $(TESTS:%=%.scm) - -sex-tests: run.scm $(TEST_SRCS) $(MODULES:%=$(ROOT)/%.o) - $(CHICKEN_C) $(CSC_FLAGS) run.scm -o sex-tests -link sexc - -clean: - rm -f sex-tests - -.PHONY: clean diff --git a/tools/sextest/Makefile b/tools/sextest/Makefile deleted file mode 100644 index d589d13..0000000 --- a/tools/sextest/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CHICKEN_C = csc -CSC_FLAGS += -K prefix -static - -# sextest reuses sexc's reader (and its utils dependency) instead of -# duplicating the S-expression reader: both are linked from the root, -# found there through the repository path -ROOT = ../.. -export CHICKEN_REPOSITORY_PATH := $(abspath $(ROOT)):$(or $(CHICKEN_REPOSITORY_PATH),$(shell chicken-install -repository)) - -sextest: sextest.scm $(ROOT)/reader.o $(ROOT)/utils.o - $(CHICKEN_C) $(CSC_FLAGS) sextest.scm -o sextest -link reader,utils - -clean: - rm -f sextest - -.PHONY: clean