Skip to content

Commit e411677

Browse files
committed
change example to sort, and move to test directory
1 parent 9b1049e commit e411677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+636
-549
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ build*
1111
config/compiler_cxx
1212
config/log.txt
1313
config/openmp
14-
example
1514
docs/doxygen/errors.txt
1615
docs/html/
1716
files.txt
@@ -23,5 +22,6 @@ lib/*.so
2322
lib/pkgconfig/*.pc
2423
make.inc
2524
test/tester
25+
test/out
2626
testsweeper-*
2727
wiki/

CMakeLists.txt

+1-32
Original file line numberDiff line numberDiff line change
@@ -134,38 +134,7 @@ endif()
134134

135135
#-------------------------------------------------------------------------------
136136
if (build_tests)
137-
# Compile example.
138-
set( example ${testsweeper_}example )
139-
add_executable( ${example} example.cc )
140-
target_link_libraries( ${example} testsweeper )
141-
set_target_properties( ${example} PROPERTIES CXX_EXTENSIONS false )
142-
143-
enable_testing()
144-
145-
add_test( NAME ${example} COMMAND ${example} )
146-
set_tests_properties(
147-
${example} PROPERTIES PASS_REGULAR_EXPRESSION "Usage:" )
148-
149-
add_test( NAME ${example}_foo COMMAND ${example} foo )
150-
set_tests_properties(
151-
${example}_foo PROPERTIES PASS_REGULAR_EXPRESSION "All tests passed" )
152-
153-
# Copy test script to build directory.
154-
add_custom_command(
155-
TARGET testsweeper POST_BUILD
156-
COMMAND
157-
cp -a ${CMAKE_CURRENT_SOURCE_DIR}/test
158-
${CMAKE_CURRENT_BINARY_DIR}/test
159-
)
160-
161-
if (testsweeper_is_project)
162-
add_custom_target(
163-
"check"
164-
COMMAND
165-
python run_tests.py
166-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test"
167-
)
168-
endif()
137+
add_subdirectory( test )
169138
endif()
170139

171140
#-------------------------------------------------------------------------------

GNUmakefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ lib_src = testsweeper.cc version.cc
6565
lib_obj = $(addsuffix .o, $(basename $(lib_src)))
6666
dep += $(addsuffix .d, $(basename $(lib_src)))
6767

68-
tester_src = example.cc
68+
tester_src = test/test.cc test/test_sort.cc
6969
tester_obj = $(addsuffix .o, $(basename $(tester_src)))
7070
dep += $(addsuffix .d, $(basename $(tester_src)))
7171

72-
tester = example
72+
tester = test/tester
7373

7474
#-------------------------------------------------------------------------------
7575
# Get Mercurial id, and make version.o depend on it via .id file.
@@ -93,9 +93,12 @@ version.o: .id
9393
# TestSweeper specific flags and libraries
9494

9595
# additional flags and libraries for testers
96+
TEST_CXXFLAGS += -I.
9697
TEST_LDFLAGS += -L. -Wl,-rpath,$(abspath .)
9798
TEST_LIBS += -ltestsweeper
9899

100+
$(tester_obj): CXXFLAGS += $(TEST_CXXFLAGS)
101+
99102
#-------------------------------------------------------------------------------
100103
# Rules
101104
.DELETE_ON_ERROR:
@@ -175,10 +178,10 @@ docs-todo:
175178
#-------------------------------------------------------------------------------
176179
# general rules
177180
clean:
178-
$(RM) *.o *.a *.so *.gch $(tester)
181+
$(RM) $(lib_a) $(lib_so) $(lib_obj) $(tester_obj) $(dep) $(headers_gch) $(tester)
179182

180183
distclean: clean
181-
$(RM) make.inc $(dep)
184+
$(RM) make.inc
182185

183186
%.o: %.cc
184187
$(CXX) $(CXXFLAGS) -c $< -o $@

INSTALL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Available targets:
4747
then compiles the library and tester
4848
make config - configures TestSweeper, creating a make.inc file
4949
make lib - compiles the library (lib/libtestsweeper.so)
50-
make tester - compiles the tester (example)
50+
make tester - compiles test/tester
5151
make docs - todo: generates documentation in docs/html/index.html
5252
make install - installs the library and headers to ${prefix}
5353
make uninstall - remove installed library and headers from ${prefix}

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ stages {
5050
make -j8
5151
5252
echo "========================================"
53-
ldd example
53+
ldd test/tester
5454
5555
echo "========================================"
5656
cd test

test/CMakeLists.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#-------------------------------------------------------------------------------
2+
set( tester "${testsweeper_}tester" )
3+
add_executable(
4+
${tester}
5+
test.cc
6+
test_sort.cc
7+
)
8+
9+
# C++11 is inherited from testsweeper, but disabling extensions is not.
10+
set_target_properties( ${tester} PROPERTIES CXX_EXTENSIONS false )
11+
12+
target_link_libraries(
13+
${tester}
14+
testsweeper
15+
)
16+
17+
# Copy run_tests script and reference output to build directory.
18+
add_custom_command(
19+
TARGET ${tester} POST_BUILD
20+
COMMAND
21+
cp -a ${CMAKE_CURRENT_SOURCE_DIR}/run_tests.py
22+
${CMAKE_CURRENT_SOURCE_DIR}/ref
23+
${CMAKE_CURRENT_BINARY_DIR}/
24+
)
25+
26+
if (testsweeper_is_project)
27+
add_custom_target(
28+
"check"
29+
COMMAND
30+
python run_tests.py
31+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
32+
)
33+
endif()

test/ref-005.txt

-10
This file was deleted.

test/ref-006.txt

-15
This file was deleted.

test/ref-100.txt

-16
This file was deleted.

test/ref-200.txt

-8
This file was deleted.

test/ref-201.txt

-8
This file was deleted.

test/ref-202.txt

-6
This file was deleted.

test/ref-203.txt

-9
This file was deleted.

test/ref-300.txt

-8
This file was deleted.

test/ref-301.txt

-8
This file was deleted.

test/ref-302.txt

-8
This file was deleted.

test/ref-303.txt

-8
This file was deleted.

test/ref-400.txt

-53
This file was deleted.

0 commit comments

Comments
 (0)