Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RDY] Add Catch2 for unit testing #1550

Merged
merged 6 commits into from Jun 14, 2019

Conversation

Projects
None yet
2 participants
@DavidFair
Copy link
Contributor

commented Jun 11, 2019

Adds Catch2 and a simple sanity test to check the CI hooks correctly run

We use VCPKG to pull in Catch2 on MSVC, if your running *nix you will need to install it from your package manager to test.
User installation and package manager / VCPKG installations require different include paths in the cpp file.
To avoid all this hassle I've bundled catch2, in the far future when it's widely available from package managers (when Ubuntu 16.04 is dropped) we can just switch to using cmake's find package instead.

This PR also moves everything that isn't main into a separate lib so we don't have to mess with dependencies for unit testing too

@DavidFair DavidFair changed the title Add Catch2 for unit testing [WIP] Add Catch2 for unit testing Jun 11, 2019

@DavidFair DavidFair force-pushed the DavidFair:Add_catch2 branch from 4620149 to 032c841 Jun 11, 2019

DavidFair added some commits Jun 11, 2019

Add Catch2 to CMakeLists
Adds catch 2 to CMakeLists in a basic form which duplicates all files
across, with an example test to validate it runs correctly
Create static lib for CorsixTH to link to for testing
Moves the implementation of CorsixTH into a main executable and a
seperate static lib we can link against for unit testing. This means we
don't have to mess around with deps for unit testing.

@DavidFair DavidFair force-pushed the DavidFair:Add_catch2 branch from 2a20740 to 64621fe Jun 11, 2019

DavidFair added some commits Jun 11, 2019

AppVeyor and Travis Unit test integration
Appveyor and travis changes

Ensure cmake is available to sudo

Travis fixes
Ensure static libs are complied with C++14
Bundle catch within project
Show resolved Hide resolved CorsixTH/CppTest/CMakeLists.txt Outdated
@@ -34,6 +34,9 @@ include_directories(${CMAKE_BINARY_DIR}/CorsixTH/Src/)

# Generate source files list
# Note: Done after generating config.h

# XXX: We should manually specify the files to include in each directory rather

This comment has been minimized.

Copy link
@TheCycoONE

TheCycoONE Jun 11, 2019

Member

Yes, and we should be using the project specific dirs ${CMAKE_PROJECT_SOURCE_DIR}, and common should come from a Target instead of being included as files... stuff to do.

Show resolved Hide resolved CorsixTH/CMakeLists.txt Outdated
Show resolved Hide resolved CorsixTH/CppTest/CMakeLists.txt Outdated

@DavidFair DavidFair changed the title [WIP] Add Catch2 for unit testing [RFC] Add Catch2 for unit testing Jun 11, 2019

Show resolved Hide resolved .travis.yml Outdated
Show resolved Hide resolved .travis.yml Outdated

@DavidFair DavidFair force-pushed the DavidFair:Add_catch2 branch from f2649ca to 768a231 Jun 11, 2019

Show resolved Hide resolved CorsixTH/CMakeLists.txt Outdated

set_target_properties(CorsixTH PROPERTIES LINK_FLAGS_MINSIZEREL "-dead_strip")
set_target_properties(CorsixTH PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")

target_link_libraries(CorsixTH SDL2main)
target_link_libraries(CorsixTH Corsixth_lib)

This comment has been minimized.

Copy link
@TheCycoONE

TheCycoONE Jun 12, 2019

Member

Linking CorsixTH_lib can be done outside of the if block.

)

################
# Variables
################

$anim_view_libs = "wxwidgets"
$corsixth_libs = "ffmpeg", "freetype", "lua", "luafilesystem", "lpeg", "sdl2", "sdl2-mixer[libflac,mpg123,libmodplug,libvorbis]", "luasocket"
$corsixth_libs = "ffmpeg", "freetype", "lua", "luafilesystem", "lpeg", "sdl2", "sdl2-mixer[libflac,mpg123,libmodplug,libvorbis]", "luasocket", "Catch2"

This comment has been minimized.

Copy link
@TheCycoONE

TheCycoONE Jun 12, 2019

Member

port name is catch2 all lowercase. This might matter if we use vcpkg in other environments in the future.

@@ -71,15 +71,16 @@ function run_script {
run_command -command "git clone $vcpkg_git_url $dest_folder_name"
Set-Location -Path $dest_folder_path
run_command "git checkout $VcpkgCommitSha"
} else {
}
else {

This comment has been minimized.

Copy link
@TheCycoONE

TheCycoONE Jun 12, 2019

Member

Why did you change the formatting here (and at the catch)?

This comment has been minimized.

Copy link
@DavidFair

DavidFair Jun 12, 2019

Author Contributor

The auto formatting in VS Code is set to do this automatically, I'm going to be cheeky and leave it otherwise I will have to remember to undo this each time I open this file

@TheCycoONE

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

Need to drop catch.hpp from the patch still.

@TheCycoONE

This comment has been minimized.

Copy link
Member

commented Jun 12, 2019

I think that's it. The above mentioned things, and adding a trailing newline to every file and we should be good for this PR.

@DavidFair DavidFair changed the title [RFC] Add Catch2 for unit testing [RDY] Add Catch2 for unit testing Jun 13, 2019

@TheCycoONE TheCycoONE merged commit 1dd1672 into CorsixTH:master Jun 14, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.