* [PATCH olang 0/2] add unit tests config @ 2024-02-18 0:27 Carlos Maniero 2024-02-18 0:50 ` [PATCH olang 1/2] tests: move munit to a shared directory Carlos Maniero 2024-02-19 0:50 ` [PATCH olang 0/2] add unit tests config Johnny Richard 0 siblings, 2 replies; 5+ messages in thread From: Carlos Maniero @ 2024-02-18 0:27 UTC (permalink / raw) To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero Simple configurations to start supporting unit tests. Note that I moved the munit to a shared directory to avoid having it duplicated over te codebase. Although I kept the .o duplicated in each folder it is used so then It won't requires any extra configuration to clean the munit.o. The make clean of both integration and unit will handle the cleaning. Carlos Maniero (2): tests: move munit to a shared directory tests: add unit tests configuration Makefile | 6 +++++- tests/integration/Makefile | 16 +++++++++------ tests/{integration => shared}/munit.c | 0 tests/{integration => shared}/munit.h | 0 tests/unit/Makefile | 28 +++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 7 deletions(-) rename tests/{integration => shared}/munit.c (100%) rename tests/{integration => shared}/munit.h (100%) create mode 100644 tests/unit/Makefile -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH olang 1/2] tests: move munit to a shared directory 2024-02-18 0:27 [PATCH olang 0/2] add unit tests config Carlos Maniero @ 2024-02-18 0:50 ` Carlos Maniero 2024-02-18 0:50 ` [PATCH olang 2/2] tests: add unit tests configuration Carlos Maniero 2024-02-19 0:50 ` [PATCH olang 0/2] add unit tests config Johnny Richard 1 sibling, 1 reply; 5+ messages in thread From: Carlos Maniero @ 2024-02-18 0:50 UTC (permalink / raw) To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero Since unit tests also uses munit, there is no reason to keep it inside the integration directory. Instead I created a shared directory to keep stuff that are shared in between unit and integration tests. Signed-off-by: Carlos Maniero <carlos@maniero.me> --- tests/integration/Makefile | 16 ++++++++++------ tests/{integration => shared}/munit.c | 0 tests/{integration => shared}/munit.h | 0 3 files changed, 10 insertions(+), 6 deletions(-) rename tests/{integration => shared}/munit.c (100%) rename tests/{integration => shared}/munit.h (100%) diff --git a/tests/integration/Makefile b/tests/integration/Makefile index a42f787..eeebfdd 100644 --- a/tests/integration/Makefile +++ b/tests/integration/Makefile @@ -1,12 +1,13 @@ SRCS := $(wildcard *_test.c) -TO_LINT := $(filter-out munit.c munit.h,$(wildcard *.c *.h)) OBJS := $(patsubst %_test.c, %_test.o, $(SRCS)) -CFLAGS := -I../../src +CFLAGS := -I../../src -I../shared TESTS := $(patsubst %_test.c, %_test, $(SRCS)) EXEC_TESTS := $(patsubst %_test, ./%_test, $(TESTS)) +MUNIT_SRC := ../shared/munit.c +MUNIT := ./munit.o .PHONY: all -all: munit.o cli_runner.o $(TESTS) +all: $(MUNIT) cli_runner.o $(TESTS) @for file in $(EXEC_TESTS); do \ ./"$$file"; \ done @@ -16,12 +17,15 @@ clean: $(RM) *.o *_test .PHONY: linter -linter: $(TO_LINT) +linter: $(SRCS) clang-format --dry-run --Werror $? .PHONY: linter-fix -linter-fix: $(TO_LINT) +linter-fix: $(SRCS) clang-format -i $? -cli_test: munit.o cli_runner.o cli_test.o +cli_test: $(MUNIT) cli_runner.o cli_test.o $(CC) $? $(CFLAGS) -o $@ + +$(MUNIT): + $(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT) diff --git a/tests/integration/munit.c b/tests/shared/munit.c similarity index 100% rename from tests/integration/munit.c rename to tests/shared/munit.c diff --git a/tests/integration/munit.h b/tests/shared/munit.h similarity index 100% rename from tests/integration/munit.h rename to tests/shared/munit.h -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH olang 2/2] tests: add unit tests configuration 2024-02-18 0:50 ` [PATCH olang 1/2] tests: move munit to a shared directory Carlos Maniero @ 2024-02-18 0:50 ` Carlos Maniero 2024-02-18 0:55 ` [olang/patches/.build.yml] build success builds.sr.ht 0 siblings, 1 reply; 5+ messages in thread From: Carlos Maniero @ 2024-02-18 0:50 UTC (permalink / raw) To: ~johnnyrichard/olang-devel; +Cc: Carlos Maniero This commit introduces a basic configuration for unit tests. However, as there are currently no unit tests, the linter step has not been activated. This is because clang-format does not handle zero files gracefully. The linter step must be enabled once the first unit test is implemented. Signed-off-by: Carlos Maniero <carlos@maniero.me> --- Makefile | 6 +++++- tests/unit/Makefile | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/unit/Makefile diff --git a/Makefile b/Makefile index b13b41b..62297ad 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ linter: $(SRCS) $(HEADERS) clang-format --dry-run --Werror $? $(MAKE) -C tests/integration/ linter - .PHONY: linter-fix linter-fix: $(SRCS) $(HEADERS) clang-format -i $? @@ -32,9 +31,14 @@ integration-test: $(MAKE) $(MAKE) -C tests/integration/ +.PHONY: unit-test +unit-test: + $(MAKE) -C tests/unit/ + .PHONY: check check: $(MAKE) integration-test + $(MAKE) unit-test $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(CFLAGS) -c $< -o $@ diff --git a/tests/unit/Makefile b/tests/unit/Makefile new file mode 100644 index 0000000..ab250cf --- /dev/null +++ b/tests/unit/Makefile @@ -0,0 +1,28 @@ +SRCS := $(wildcard *_test.c) +OBJS := $(patsubst %_test.c, %_test.o, $(SRCS)) +CFLAGS := -I../../src -I../shared +TESTS := $(patsubst %_test.c, %_test, $(SRCS)) +EXEC_TESTS := $(patsubst %_test, ./%_test, $(TESTS)) +MUNIT_SRC := ../shared/munit.c +MUNIT := ./munit.o + +.PHONY: all +all: $(MUNIT) $(TESTS) + @for file in $(EXEC_TESTS); do \ + ./"$$file"; \ + done + +.PHONY: clean +clean: + $(RM) *.o *_test + +.PHONY: linter +linter: $(SRCS) + clang-format --dry-run --Werror $? + +.PHONY: linter-fix +linter-fix: $(SRCS) + clang-format -i $? + +$(MUNIT): + $(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT) -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [olang/patches/.build.yml] build success 2024-02-18 0:50 ` [PATCH olang 2/2] tests: add unit tests configuration Carlos Maniero @ 2024-02-18 0:55 ` builds.sr.ht 0 siblings, 0 replies; 5+ messages in thread From: builds.sr.ht @ 2024-02-18 0:55 UTC (permalink / raw) To: Carlos Maniero; +Cc: ~johnnyrichard/olang-devel olang/patches/.build.yml: SUCCESS in 33s [add unit tests config][0] from [Carlos Maniero][1] [0]: https://lists.sr.ht/~johnnyrichard/olang-devel/patches/49618 [1]: mailto:carlos@maniero.me ✓ #1152377 SUCCESS olang/patches/.build.yml https://builds.sr.ht/~johnnyrichard/job/1152377 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH olang 0/2] add unit tests config 2024-02-18 0:27 [PATCH olang 0/2] add unit tests config Carlos Maniero 2024-02-18 0:50 ` [PATCH olang 1/2] tests: move munit to a shared directory Carlos Maniero @ 2024-02-19 0:50 ` Johnny Richard 1 sibling, 0 replies; 5+ messages in thread From: Johnny Richard @ 2024-02-19 0:50 UTC (permalink / raw) To: Carlos Maniero; +Cc: ~johnnyrichard/olang-devel Great work my friend! applied. To git.sr.ht:~johnnyrichard/olang bdb6244..7e4d206 main -> main ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-18 23:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-18 0:27 [PATCH olang 0/2] add unit tests config Carlos Maniero 2024-02-18 0:50 ` [PATCH olang 1/2] tests: move munit to a shared directory Carlos Maniero 2024-02-18 0:50 ` [PATCH olang 2/2] tests: add unit tests configuration Carlos Maniero 2024-02-18 0:55 ` [olang/patches/.build.yml] build success builds.sr.ht 2024-02-19 0:50 ` [PATCH olang 0/2] add unit tests config Johnny Richard
Code repositories for project(s) associated with this public inbox https://git.johnnyrichard.com/olang.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox