From a504fc14108e6b0c4a1d1b02822140a0f90f6532 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 | 7 +++---- Makefile | 21 +++++++++++---------- tests/Makefile | 21 --------------------- tools/sextest/Makefile | 16 ---------------- 4 files changed, 14 insertions(+), 51 deletions(-) delete mode 100644 tests/Makefile delete mode 100644 tools/sextest/Makefile diff --git a/.gitignore b/.gitignore index db462514..7469404f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,9 @@ *.o *.import.scm *.link -sexc -sex-tests -sextest -tools/sextest/sextest +/sexc +/sex-tests +/sextest # Scrapped design docs, kept for reference /attic diff --git a/Makefile b/Makefile index 9459d256..dfb57eac 100644 --- a/Makefile +++ b/Makefile @@ -63,14 +63,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 \ @@ -129,10 +132,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 1e9ac319..00000000 --- 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 d589d135..00000000 --- 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