Skip to content

Commit

Permalink
ready for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
alecksandr26 committed Jan 28, 2024
1 parent 7a3e132 commit cb85193
Show file tree
Hide file tree
Showing 63 changed files with 1,631 additions and 1,787 deletions.
61 changes: 35 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ endef

PKGNAME = unittest-c
C = cc
C_DEBUG_FLAGS = -ggdb -pedantic -Wall
C_COMPILE_FLAGS = -O2 -DNDEBUG -fno-stack-protector -z execstack -no-pie
C_DEBUG_FLAGS = -ggdb -pedantic -Wall -fPIC
C_COMPILE_FLAGS = -O2 -DNDEBUG -fno-stack-protector -z execstack -no-pie -fPIC
C_FLAGS = $(C_DEBUG_FLAGS)
C_FLAGS_LIBS = -ltc
C_FLAGS_TRY_CATCH_LIB = -ltc
C_FLAGS_WHOLE_ARCHIVE = -Wl,--whole-archive
C_FLAGS_NO_WHOLE_ARCHIVE = -Wl,--no-whole-archive
SHARED_LIB_FLAGS = -lunittest

AR = ar cr
CF = clang-format -i
Expand All @@ -42,27 +45,27 @@ UPLOAD_DIR = upload
TEST_SRC_DIR = $(addprefix $(TEST_DIR)/, src)
TEST_BIN_DIR = $(addprefix $(TEST_DIR)/, bin)

OBJS = $(addprefix $(OBJ_DIR)/, debug.o infofail.o tcase.o suit.o valgrind.o command.o compile.o tfile.o dir.o \
OBJS = $(addprefix $(OBJ_DIR)/, debug.o info.o tcase.o suit.o valgrind.o command.o compile.o tfile.o dir.o \
hashdates.o rerun.o unittest.o)

LIBS = $(addprefix $(LIB_DIR)/, libunittest.a)
EXAMPLES = $(addprefix $(EXAMPLE_DIR)/, test.out \
testc.out \
valgrind_test.out)
STATIC_LIBS = $(addprefix $(LIB_DIR)/, libunittest.a)
SHARED_LIBS = $(addprefix $(LIB_DIR)/, libunittest.so)

EXAMPLES = $(addprefix $(EXAMPLE_DIR)/, simple_example.out)

TESTS = $(addprefix $(TEST_BIN_DIR)/, test_running_testcase.out\
test_create_suit.out\
test_multiple_suits.out\
test_assert.out\
test_expect.out)
# test_compile.out\
# test_compile_fails.out\
# test_log.out\
# test_crashed_test.out
# )
test_expect.out\
test_compile.out\
test_compile_fails.out\
test_log.out\
test_crashed_test.out\
test_info.out)

.PHONY: all compile pkg upload-aur examples
all: $(OBJS) $(LIBS) $(TESTS) $(EXAMPLES)
all: $(OBJS) $(STATIC_LIBS) $(SHARED_LIBS) $(TESTS) $(EXAMPLES)

$(OBJ_DIR):
@echo Creating: $@
Expand All @@ -86,34 +89,40 @@ $(EXAMPLE_DIR):

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
@echo Compiling: $@
@$(C) $(C_FLAGS) -c $< -o $@ $(C_FLAGS_LIBS)
@$(C) $(C_FLAGS) -c $< -o $@

# Creates the library
$(LIB_DIR)/%.a: $(OBJS) | $(LIB_DIR)
@echo Archiving: $@ $^
@echo Archiving: $^ -o $@
@$(AR) $@ $^
@ranlib $@

$(LIB_DIR)/%.so: $(STATIC_LIBS) | $(LIB_DIR)
@echo Archiving: $^ -o $@
@$(C) -shared -o $@ $(C_FLAGS_WHOLE_ARCHIVE) $^ $(C_FLAGS_TRY_CATCH_LIB) $(C_FLAGS_NO_WHOLE_ARCHIVE)

# Trying to fetch the compiled directory
$(EXAMPLE_DIR)/%.out: $(EXAMPLE_DIR)/%.c $(LIBS) | $(EXAMPLE_DIR)
@echo Compiling: $(filter-out $(EXAMPLE_DIR), $^) -o $@
@$(C) $(C_FLAGS) $(filter-out $(EXAMPLE_DIR), $^) -o $@ $(C_FLAGS_LIBS)
$(EXAMPLE_DIR)/%.out: $(EXAMPLE_DIR)/%.c $(SHARED_LIBS) | $(EXAMPLE_DIR)
@echo Compiling: $< -o $@
@$(C) $(C_FLAGS) -L./$(LIB_DIR) $< -o $@ $(SHARED_LIB_FLAGS)

example_%.out: $(EXAMPLE_DIR)/%.out
@echo Running
@./$<
@export LD_LIBRARY_PATH=$(LIB_DIR):$$LD_LIBRARY_PATH && \
./$<

examples: $(addprefix example_, $(notdir $(EXAMPLES)))

# Compile the tests
$(TEST_BIN_DIR)/test_%.out: $(TEST_SRC_DIR)/test_%.c $(LIBS) | $(TEST_BIN_DIR)
@echo Compiling: $(filter-out $(TEST_BIN_DIR), $^) -o $@
@$(C) $(C_FLAGS) $(filter-out $(TEST_BIN_DIR), $^) -o $@ $(C_FLAGS_LIBS)
$(TEST_BIN_DIR)/test_%.out: $(TEST_SRC_DIR)/test_%.c $(SHARED_LIBS) | $(TEST_BIN_DIR)
@echo Compiling: $< -o $@
@$(C) $(C_FLAGS) -L./$(LIB_DIR) $< -o $@ $(SHARED_LIB_FLAGS)

# To run some tests
test_%.out: $(TEST_BIN_DIR)/test_%.out
@echo Running: $<
@$(V) $(V_FLAGS) ./$<
@export LD_LIBRARY_PATH=$(LIB_DIR):$$LD_LIBRARY_PATH && \
$(V) $(V_FLAGS) ./$<
@echo Passed

test: $(notdir $(TESTS))
Expand Down Expand Up @@ -163,7 +172,7 @@ format:

# Clean objects and libs and recompile with optimizations
compile: C_FLAGS = $(C_COMPILE_FLAGS)
compile: clean $(LIBS)
compile: clean $(SHARED_LIBS)

pkg:
@$(M) $(M_FLAGS)
Expand Down
4 changes: 2 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

# Move to the build directory
pkgname=unittest-c
pkgver=1.2.0
pkgrel=6
pkgver=1.3.0
pkgrel=7
epoch=
pkgdesc="unittest c is a fast and simple macro-based unit testing framework for C.
It's inspired by the Python unittest module and designed to reduce boilerplate code.
Expand Down
10 changes: 7 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
---- 2023/05/13 ----
- Think where to put these implementations executing_from_basedir, get_basedir [X]
- Update the documentation being clear about how to do the recompilation process [X]
- Start adding more asserts, also add some new features for debuggin [ ]
- Start adding more asserts, also add some new features for debuggin [X]

---- 2023/05/22 ----
- Add several tests for the new features implemented [X]
Expand All @@ -36,7 +36,6 @@

---- 2023/05/23 ----
- Create an execption if someone trys to use valgrind without using the recompileation mode [ ]
- Develop a way to use Absolute paths or things like that [ ]
- Change the sections of the documentation [X]
- Solve another bug with the hashed date files [X]

Expand All @@ -47,7 +46,7 @@
- Solve the bug of the measured time [X]

---- 2024/01/17 ----
- Make the library shared dynamically linked [ ]
- Make the library shared dynamically linked [X]

---- 2024/01/18 ----
- Try to compile and run the other testfiles, you will require edit
Expand All @@ -56,4 +55,9 @@

---- 2024/01/23 ----
- Copy the test case through other way and not via pipes [X]

---- 2024/01/27 ----
- Develop a way to run isolated each test, not just each testcase [ ]
- Do a refactor of the info.c file, and also the whole comments [ ]
- Document the whole asserts and expects [ ]

34 changes: 0 additions & 34 deletions example/dir/anothertest.c

This file was deleted.

91 changes: 0 additions & 91 deletions example/dir/simpletest.c

This file was deleted.

31 changes: 0 additions & 31 deletions example/dir/simpletest2.c

This file was deleted.

34 changes: 0 additions & 34 deletions example/dir2/anothertest.c

This file was deleted.

Loading

0 comments on commit cb85193

Please sign in to comment.