Skip to content

Commit 8e67c55

Browse files
authored
refactor: faster test compiles (#1055)
1 parent f618e34 commit 8e67c55

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

app/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ THIRDPARTYDIR := third_party
1010
TESTDIR := tests
1111
BUILDDIR := tmp
1212
INCDIR := src
13+
RANDOM_MOVER = $(TESTDIR)/mock/engine/random_mover$(SUFFIX)
14+
DUMMY_ENGINE = $(TESTDIR)/mock/engine/dummy_engine$(SUFFIX)
1315

1416
#Flags, Libraries and Includes
1517
CXXFLAGS := -O3 -std=c++17 -Wall -Wextra -DNDEBUG
16-
CXXFLAGS_TEST := -O2 -std=c++17 -Wall -Wextra -pedantic -Wuninitialized -fno-omit-frame-pointer
18+
CXXFLAGS_TEST := -O0 -std=c++17 -Wall -Wextra -pedantic -Wuninitialized -fno-omit-frame-pointer
1719
CXXFLAGS_COV := -O0 --coverage -g -std=c++17 -Wall -Wextra -pedantic -Wuninitialized -g3 -fno-omit-frame-pointer
1820
INC := -I$(INCDIR) -Ithird_party
1921

@@ -211,17 +213,19 @@ coverage: tests
211213
cd .. && ./fastchess-tests
212214
mkdir -p coverage && cd coverage && gcovr --html-details coverage.html --gcov-ignore-errors=no_working_dir_found --gcov-ignore-parse-errors -f "../src" -r ../. ..
213215

214-
tests: $(TARGET) compile-random-mover
215-
$(CXX) $(CXXFLAGS) ./tests/mock/engine/dummy_engine.cpp -o ./tests/mock/engine/dummy_engine$(SUFFIX) $(LDFLAGS) $(EXTRA_LDFLAGS)
216+
tests: $(TARGET) $(RANDOM_MOVER) $(DUMMY_ENGINE)
216217

217218
format: $(SRC_FILES) $(HEADERS)
218219
clang-format -i $^
219220

220221
tidy: $(SRC_FILES) $(HEADERS)
221222
clang-tidy $^
222223

223-
compile-random-mover: $(TARGET)
224-
$(CXX) -O3 -std=c++17 ./tests/mock/engine/random_mover.cpp -o ./tests/mock/engine/random_mover
224+
$(RANDOM_MOVER): $(TESTDIR)/mock/engine/random_mover.cpp
225+
$(CXX) -O3 -std=c++17 $< -o $@
226+
227+
$(DUMMY_ENGINE): $(TESTDIR)/mock/engine/dummy_engine.cpp
228+
$(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(EXTRA_LDFLAGS)
225229

226230
$(TARGET): $(OBJECTS)
227231
$(CXX) $(CXXFLAGS) $(NATIVE) $(INC) $(DEPFLAGS) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
@@ -233,6 +237,6 @@ build_directories:
233237
@$(shell mkdir -p $(dir $(OBJECTS)))
234238

235239
clean:
236-
rm -rf $(BUILDDIR) $(TARGET) $(TARGET)-tests $(TARGET)-tests.exe $(TARGET).exe ../random_mover ./tests/mock/engine/random_mover
240+
rm -rf $(BUILDDIR) $(TARGET) $(TARGET)-tests $(TARGET)-tests.exe $(TARGET).exe ../random_mover $(RANDOM_MOVER) $(DUMMY_ENGINE)
237241

238242
-include $(DEPENDS)

app/src/cli/cli.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ class OptionsParser {
9696
ss << " (compiled with cutechess output)";
9797
#endif
9898

99+
#ifndef NDEBUG
100+
ss << " (assertions)";
101+
#endif
102+
99103
return ss.str();
100104
}
101105

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fastchess alpha 1.8.2 <build>
1+
fastchess alpha 1.8.2 <build> (assertions)

0 commit comments

Comments
 (0)