Skip to content

Commit 86cb91f

Browse files
authored
Merge pull request #1194 from asarium/unittests/appveyor
Execute unit tests on appveyor
2 parents 4321fd3 + cdc6f7d commit 86cb91f

File tree

9 files changed

+52
-33
lines changed

9 files changed

+52
-33
lines changed

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ before_build:
1515
- git submodule update --init --recursive
1616
build_script:
1717
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/build.ps1
18-
18+
test_script:
19+
- ps: . $Env:APPVEYOR_BUILD_FOLDER/ci/appveyor/test.ps1
1920

2021
deploy:
2122
- provider: GitHub

ci/appveyor/build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ if ($DeployBuild) {
111111
7z a "$($PackageName)-builds-$($buildConfig.PackageType).zip" "$env:APPVEYOR_BUILD_FOLDER/../install/*"
112112
Push-AppveyorArtifact "$($PackageName)-builds-$($buildConfig.PackageType).zip"
113113
} else {
114-
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
114+
cmake -DFSO_USE_SPEECH="ON" -DFSO_FATAL_WARNINGS="ON" -DFSO_USE_VOICEREC="ON" -DFSO_BUILD_TESTS="ON" -DMSVC_SIMD_INSTRUCTIONS=SSE2 `
115115
-G "$Env:CMAKE_GENERATOR" -T "$Env:PlatformToolset" ..
116116

117117
cmake --build . --config "$Env:CONFIGURATION" -- /verbosity:minimal

ci/appveyor/test.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
if ([System.Convert]::ToBoolean($env:DeployBuild)) {
3+
# Skip tests for deployment
4+
exit 0
5+
} else {
6+
# Appveyor doesn't have OpenAL so copy our DLLs to the output FOLDER
7+
$arch=""
8+
if ($Env:CMAKE_GENERATOR -Match "Win64") {
9+
$arch="win64"
10+
} else {
11+
$arch="win32"
12+
}
13+
$dllPath = "$Env:APPVEYOR_BUILD_FOLDER\lib\openal\libs\$arch\OpenAL32.dll"
14+
$copyDestination = "$pwd\bin\$Env:CONFIGURATION\"
15+
16+
write "Copying OpenAL DLL..."
17+
Copy-Item "$dllPath" "$copyDestination"
18+
19+
write "Running unit tests..."
20+
# Run unit tests
21+
&"$pwd\bin\$Env:CONFIGURATION\unittests.exe" --gtest_shuffle 2>&1
22+
23+
if (! ($?)) {
24+
exit 1
25+
}
26+
}

cmake/util.cmake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ ENDIF(EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${FILE}\")
6666
SET(${OUTVAR} "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${NAME} PARENT_SCOPE)
6767
ENDFUNCTION(EP_CHECK_FILE_EXISTS)
6868

69+
MACRO(COPY_FILE_TO_TARGET _target _file)
70+
if(UNIX)
71+
ADD_CUSTOM_COMMAND(
72+
TARGET ${_target} POST_BUILD
73+
COMMAND cp -a "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
74+
COMMENT "copying '${_file}'..."
75+
)
76+
else()
77+
ADD_CUSTOM_COMMAND(
78+
TARGET ${_target} POST_BUILD
79+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
80+
COMMENT "copying '${_file}'..."
81+
)
82+
endif()
83+
endmacro(COPY_FILE_TO_TARGET)
84+
6985
MACRO(COPY_FILES_TO_TARGET _target)
7086
if(UNIX)
7187
ADD_CUSTOM_COMMAND(
@@ -76,19 +92,7 @@ MACRO(COPY_FILES_TO_TARGET _target)
7692
endif()
7793

7894
FOREACH(file IN LISTS TARGET_COPY_FILES)
79-
if(UNIX)
80-
ADD_CUSTOM_COMMAND(
81-
TARGET ${_target} POST_BUILD
82-
COMMAND cp -a "${file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
83-
COMMENT "copying '${file}'..."
84-
)
85-
else()
86-
ADD_CUSTOM_COMMAND(
87-
TARGET ${_target} POST_BUILD
88-
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file}" "$<TARGET_FILE_DIR:${_target}>/${LIBRAY_DESTINATION}/"
89-
COMMENT "copying '${file}'..."
90-
)
91-
endif()
95+
COPY_FILE_TO_TARGET("${_target}" "${file}")
9296
ENDFOREACH(file)
9397
ENDMACRO(COPY_FILES_TO_TARGET)
9498

lib/openal/libs/win32/OpenAL32.dll

825 KB
Binary file not shown.

lib/openal/libs/win64/OpenAL32.dll

958 KB
Binary file not shown.

test/src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ set_target_properties(unittests PROPERTIES FOLDER "tests")
1212
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../test_data" TEST_DATA_PATH)
1313
string(REPLACE "\\" "\\\\" TEST_DATA_PATH "${TEST_DATA_PATH}")
1414
target_compile_definitions(unittests PRIVATE "TEST_DATA_PATH=\"${TEST_DATA_PATH}\"")
15+
16+
INCLUDE(util)
17+
COPY_FILES_TO_TARGET(unittests)

test/src/scripting/lua/Args.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,3 @@ using namespace luacpp::args;
99
class LuaArgumentTest: public LuaStateTest {
1010
};
1111

12-
TEST_F(LuaArgumentTest, GetArgs) {
13-
ScopedLuaStackTest stackTest(L);
14-
15-
lua_pushliteral(L, "Abcdefg");
16-
17-
std::string arg1;
18-
int arg2;
19-
20-
int n = getArgs(L, arg1, optional, arg2);
21-
22-
ASSERT_EQ(1, n);
23-
ASSERT_STREQ("Abcdefg", arg1.c_str());
24-
25-
ASSERT_EQ(1, lua_gettop(L));
26-
27-
lua_pop(L, 1);
28-
}

test/src/util/FSTestFixture.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <gtest/gtest.h>
44
#include <globalincs/vmallocator.h>
55

6+
#include <cstdint>
7+
68
namespace test {
79

810
enum InitFlags {
@@ -14,7 +16,7 @@ enum InitFlags {
1416

1517
class FSTestFixture: public ::testing::Test {
1618
private:
17-
uint64_t _initFlags;
19+
std::uint64_t _initFlags;
1820

1921
SCP_vector<SCP_string> _cmdlineArgs;
2022
SCP_string _currentModDir;

0 commit comments

Comments
 (0)