Created
September 6, 2017 01:16
-
-
Save clwyatt/56081227413c762b23f39ab70cb7c894 to your computer and use it in GitHub Desktop.
CMake fixes for Milestone 0 ECE 3574 Fall 2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.5) | |
project(SYNTH CXX) | |
# require a C++11 compiler for all targets | |
set(CMAKE_CXX_STANDARD 11) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
if(UNIX) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") | |
endif() | |
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}) | |
add_executable(synth synth.cpp) | |
INSTALL(TARGETS synth DESTINATION bin) | |
enable_testing() | |
add_test(00_Install ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install) | |
add_subdirectory(tests) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_executable(compare compare.cpp) | |
INSTALL(TARGETS compare DESTINATION bin) | |
if(WIN32) | |
set(EXE_NAME synth.exe) | |
set(COMPARE_EXE_NAME compare.exe) | |
else() | |
set(EXE_NAME synth) | |
set(COMPARE_EXE_NAME compare) | |
endif() | |
# these tests should pass | |
foreach(ID RANGE 9) | |
add_test(NAME test${ID} | |
COMMAND ${CMAKE_COMMAND} | |
-DCOMPARE_EXE_FILE=${CMAKE_BINARY_DIR}/bin/${COMPARE_EXE_NAME} | |
-DEXE_FILE=${CMAKE_BINARY_DIR}/bin/${EXE_NAME} | |
-DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/test${ID}.csv | |
-DOUTPUT_FILE=test${ID}.wav | |
-DERR_FILE=test${ID}.stderr | |
-DOUT_FILE=test${ID}.stdout | |
-DTEST_FILE=${CMAKE_SOURCE_DIR}/tests/test${ID}.wav | |
-P ${CMAKE_CURRENT_SOURCE_DIR}/Test.cmake | |
) | |
endforeach(ID) | |
# these tests should not succeeed | |
add_test(test10 ${CMAKE_BINARY_DIR}/bin/${EXE_NAME} ${CMAKE_SOURCE_DIR}/tests/test10.csv test10.wav) | |
add_test(test11 ${CMAKE_BINARY_DIR}/bin/${EXE_NAME} ${CMAKE_SOURCE_DIR}/tests/test11.csv test11.wav) | |
add_test(test12 ${CMAKE_BINARY_DIR}/bin/${EXE_NAME} ${CMAKE_SOURCE_DIR}/tests/test12.csv test12.wav) | |
set_tests_properties(test10 PROPERTIES WILL_FAIL ON) | |
set_tests_properties(test11 PROPERTIES WILL_FAIL ON) | |
set_tests_properties(test12 PROPERTIES WILL_FAIL ON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the program and capture output | |
execute_process( | |
COMMAND ${EXE_FILE} ${INPUT_FILE} ${OUTPUT_FILE} | |
ERROR_FILE ${ERR_FILE} | |
OUTPUT_FILE ${OUT_FILE} | |
) | |
# Compare the output to the expected | |
execute_process( | |
COMMAND ${COMPARE_EXE_FILE} ${OUTPUT_FILE} ${TEST_FILE} | |
RESULT_VARIABLE DIFFERENT | |
) | |
if(DIFFERENT) | |
message(FATAL_ERROR "Test failed - synth output incorrect") | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment