Added the ability to test/build in Unix
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ cmake-build-debug/
|
||||
/test/output.txt
|
||||
/test/output2.txt
|
||||
/test/NameSort.exe
|
||||
/test/NameSort
|
||||
|
||||
# Ignore build directory on *nix systems
|
||||
/build
|
||||
|
||||
@@ -15,9 +15,18 @@ add_custom_command(TARGET NameSort POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $
|
||||
target_include_directories(NameSort PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
# After everything has been built, we want to automatically run tests as part of the build
|
||||
add_custom_command(
|
||||
TARGET NameSort
|
||||
POST_BUILD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test
|
||||
COMMAND cmd /c Test.cmd
|
||||
)
|
||||
IF(Win32)
|
||||
add_custom_command(
|
||||
TARGET NameSort
|
||||
POST_BUILD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test
|
||||
COMMAND cmd /c Test.cmd
|
||||
)
|
||||
ELSE()
|
||||
add_custom_command(
|
||||
TARGET NameSort
|
||||
POST_BUILD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test
|
||||
COMMAND bash -c ./Test.sh
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
24
test/Test.sh
Executable file
24
test/Test.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
OUTPUT="output.txt"
|
||||
OUTPUT2="output2.txt"
|
||||
|
||||
rm -f $OUTPUT
|
||||
rm -f $OUTPUT2
|
||||
|
||||
./NameSort "Sort Me.txt" > $OUTPUT
|
||||
./NameSort "Sort Me 2.txt" > $OUTPUT2
|
||||
|
||||
diff "Sorted.txt" $OUTPUT
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Test 1 Success"
|
||||
else
|
||||
echo "Test 1 Failure"
|
||||
fi
|
||||
|
||||
diff "Sorted 2.txt" $OUTPUT2
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Test 2 Success"
|
||||
else
|
||||
echo "Test 2 Failure"
|
||||
fi
|
||||
Reference in New Issue
Block a user