Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable BUILDCC_TESTING for MSVC#195

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coder137 merged 11 commits intomainfrommsvc_tests
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion.github/workflows/linux_gcc_cmake_build.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -191,7 +191,7 @@ jobs:
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_DEV_SINGLE}}
run: cmake --build . --target cppcheck_static_analysis

- name: Build Debugfor test
- name: Build Debugand test
# Linux has 2 cores
run: |
cmake --build --list-presets
Expand Down
8 changes: 7 additions & 1 deletion.github/workflows/win_cmake_build.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,13 @@ jobs:
cmake --list-presets
cmake --preset=${{env.BUILD_MSVC_PRESET}}

- name: Build
- name: Build Debug and test
working-directory: ${{github.workspace}}/${{env.BUILD_FOLDER_MSVC_DEV_ALL}}
run: |
cmake --build . --parallel 2 --config Debug
ctest . --parallel 2 -C Debug

- name: Build Release
# Linux has 2 cores
run: |
cmake --build --list-presets
Expand Down
4 changes: 2 additions & 2 deletionsCMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ endif()

# Testing
set(BUILD_TESTING OFF CACHE BOOL "Third Party modules use these options")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND ${BUILDCC_TESTING})
if (${BUILDCC_TESTING})
set(TESTING ON)
message("Enabling unit-testing")
message("Compiler identification: ${CMAKE_CXX_COMPILER_ID}")
Expand DownExpand Up@@ -85,7 +85,7 @@ endif()

# Coverage

if (${TESTING})
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND ${TESTING})
include(cmake/coverage/lcov.cmake)
include(cmake/coverage/gcovr.cmake)
endif()
Expand Down
2 changes: 1 addition & 1 deletionCMakePresets.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,7 +121,7 @@
"BUILDCC_BOOTSTRAP_THROUGH_CMAKE": true,
"BUILDCC_PRECOMPILE_HEADERS": true,
"BUILDCC_EXAMPLES": true,
"BUILDCC_TESTING":false,
"BUILDCC_TESTING":true,
"BUILDCC_CLANGTIDY": false,
"BUILDCC_CPPCHECK": false,
"BUILDCC_DOCUMENTATION": false,
Expand Down
2 changes: 1 addition & 1 deletionbuildcc/lib/args/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ target_link_libraries(mock_args PUBLIC

CppUTest
CppUTestExt
gcov
${TEST_LINK_LIBS}
)

# Tests
Expand Down
1 change: 1 addition & 0 deletionsbuildcc/lib/args/test/test_args.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -258,5 +258,6 @@ TEST(ArgsTestGroup, Args_MultipleCustomTarget) {
}

int main(int ac, char **av) {
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
return CommandLineTestRunner::RunAllTests(ac, av);
}
2 changes: 1 addition & 1 deletionbuildcc/lib/env/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ if (${TESTING})

CppUTest
CppUTestExt
gcov
${TEST_LINK_LIBS}
)
target_compile_options(mock_env PUBLIC ${TEST_COMPILE_FLAGS} ${BUILD_COMPILE_FLAGS})
target_link_options(mock_env PUBLIC ${TEST_LINK_FLAGS} ${BUILD_LINK_FLAGS})
Expand Down
2 changes: 1 addition & 1 deletionbuildcc/lib/env/include/env/util.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,7 +49,7 @@ namespace buildcc::env {
*/
inline bool save_file(const char *name, const char *buf, size_t len,
bool binary) {
if (buf == nullptr) {
if (name == nullptr ||buf == nullptr) {
return false;
}
std::ofstream ofs(name, binary ? std::ofstream::binary : std::ofstream::out);
Expand Down
64 changes: 34 additions & 30 deletionsbuildcc/lib/env/test/test_env_util.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,27 +33,13 @@ TEST(EnvUtilTestGroup, Util_SaveFile_NullptrName) {
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_BadWrite) {
constexpr const char *const FILENAME = "BadWrite.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", -1, false);
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_GoodWrite) {
constexpr const char *const FILENAME = "GoodWrite.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", false);
CHECK_TRUE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_BadWrite_Binary) {
constexpr const char *const FILENAME = "BadWrite_Binary.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", -1, true);
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_GoodWrite_Binary) {
constexpr const char *const FILENAME = "GoodWrite_Binary.txt";
fs::remove(FILENAME);
Expand All@@ -69,22 +55,6 @@ TEST(EnvUtilTestGroup, Util_SaveFile_CheckDirectory) {
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_CannotWrite) {
constexpr const char *const FILENAME = "CannotWrite.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", false);
CHECK_TRUE(save);

std::error_code err;
fs::permissions(FILENAME, fs::perms::none, err);
if (err) {
FAIL("Cannot disable file permissions");
}

save = buildcc::env::save_file(FILENAME, "Hello", false);
CHECK_FALSE(save);
}

// Load File
TEST(EnvUtilTestGroup, Util_LoadFile_CheckDirectory) {
// NOTE, This is a directory
Expand DownExpand Up@@ -143,6 +113,8 @@ TEST(EnvUtilTestGroup, Util_LoadFile_ReadTxt) {
CHECK_TRUE(load);
}

#if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__)

TEST(EnvUtilTestGroup, Util_LoadFile_CannotOpen) {
constexpr const char *const FILENAME = "CannotOpen.txt";
buildcc::env::save_file(FILENAME, "Random Data", false);
Expand All@@ -159,6 +131,38 @@ TEST(EnvUtilTestGroup, Util_LoadFile_CannotOpen) {
CHECK_FALSE(load);
}

TEST(EnvUtilTestGroup, Util_SaveFile_BadWrite_Binary) {
constexpr const char *const FILENAME = "BadWrite_Binary.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", -1, true);
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_BadWrite) {
constexpr const char *const FILENAME = "BadWrite.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", -1, false);
CHECK_FALSE(save);
}

TEST(EnvUtilTestGroup, Util_SaveFile_CannotWrite) {
constexpr const char *const FILENAME = "CannotWrite.txt";
fs::remove(FILENAME);
bool save = buildcc::env::save_file(FILENAME, "Hello", false);
CHECK_TRUE(save);

std::error_code err;
fs::permissions(FILENAME, fs::perms::none, err);
if (err) {
FAIL("Cannot disable file permissions");
}

save = buildcc::env::save_file(FILENAME, "Hello", false);
CHECK_FALSE(save);
}

#endif

TEST(EnvUtilTestGroup, Util_Split) {
{
std::vector<std::string> paths = buildcc::env::split("", ':');
Expand Down
2 changes: 1 addition & 1 deletionbuildcc/lib/target/cmake/mock_target.cmake
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ target_link_libraries(mock_target PUBLIC

CppUTest
CppUTestExt
gcov
${TEST_LINK_LIBS}
)

# https://github.com/msys2/MINGW-packages/issues/2303
Expand Down
22 changes: 22 additions & 0 deletionsbuildcc/lib/target/mock/test_target_util.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
#ifndef TARGET_MOCK_TEST_TARGET_UTIL_H_
#define TARGET_MOCK_TEST_TARGET_UTIL_H_

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

namespace buildcc::m {

inline void blocking_sleep(int seconds) {
#ifdef _WIN32
Sleep(seconds * 1000);
#else
sleep(seconds);
#endif
}

} // namespace buildcc::m

#endif
2 changes: 1 addition & 1 deletionbuildcc/lib/target/test/path/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ target_link_libraries(${TEST_NAME} PRIVATE

CppUTest
CppUTestExt
gcov
${TEST_LINK_LIBS}
)
target_compile_options(${TEST_NAME} PRIVATE ${TEST_COMPILE_FLAGS})
target_link_options(${TEST_NAME} PRIVATE ${TEST_LINK_FLAGS})
Expand Down
5 changes: 2 additions & 3 deletionsbuildcc/lib/target/test/target/test_generator.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
#include "target/generator.h"

#include <unistd.h>

#include "expect_command.h"
#include "expect_generator.h"
#include "test_target_util.h"

#include "taskflow/taskflow.hpp"

Expand DownExpand Up@@ -162,7 +161,7 @@ TEST(GeneratorTestGroup, Generator_Rebuild_Inputs) {
buildcc::m::GeneratorRunner(generator);
}

sleep(1);
buildcc::m::blocking_sleep(1);
bool saved = buildcc::env::save_file(
(buildcc::env::get_project_root_dir() / "new_source.cpp")
.string()
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,6 @@
#include "schema/target_serialization.h"

#include <iostream>
#include <unistd.h>

// NOTE, Make sure all these includes are AFTER the system and header includes
#include "CppUTest/CommandLineTestRunner.h"
Expand Down
4 changes: 2 additions & 2 deletionsbuildcc/lib/target/test/target/test_target_lib_dep.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,14 +5,14 @@

#include "expect_command.h"
#include "expect_target.h"
#include "test_target_util.h"

#include "target/target.h"

//
#include "schema/target_serialization.h"

#include <iostream>
#include <unistd.h>

// NOTE, Make sure all these includes are AFTER the system and header includes
#include "CppUTest/CommandLineTestRunner.h"
Expand DownExpand Up@@ -234,7 +234,7 @@ TEST(TargetTestLibDep, TargetDep_UpdateExistingLibraryTest) {
buildcc::m::TargetRunner(foolib);

// * To make sure that save_file is newer
sleep(1);
buildcc::m::blocking_sleep(1);
bool saved = buildcc::env::save_file(
foolib.GetTargetPath().string().c_str(), std::string{""}, false);
CHECK_TRUE(saved);
Expand Down
7 changes: 3 additions & 4 deletionsbuildcc/lib/target/test/target/test_target_pch.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
#include <filesystem>

#include <unistd.h>

#include "constants.h"

#include "expect_command.h"
#include "expect_target.h"
#include "test_target_util.h"

#include "target/target.h"

Expand DownExpand Up@@ -128,7 +127,7 @@ TEST(TargetPchTestGroup, Target_AddPch_Rebuild) {

// Rebuild: Updated
{
sleep(1);
buildcc::m::blocking_sleep(1);
fs::path filename =
fs::path(BUILD_SCRIPT_SOURCE) / "data" / "pch/pch_header_1.h";
bool save = buildcc::env::save_file(filename.string().c_str(), "", false);
Expand DownExpand Up@@ -221,7 +220,7 @@ TEST(TargetPchTestGroup, Target_AddPch_CppRebuild) {

// Rebuild: Updated
{
sleep(1);
buildcc::m::blocking_sleep(1);
fs::path filename =
fs::path(BUILD_SCRIPT_SOURCE) / "data" / "pch/pch_header_1.h";
bool save = buildcc::env::save_file(filename.string().c_str(), "", false);
Expand Down
5 changes: 2 additions & 3 deletionsbuildcc/lib/target/test/target/test_target_source.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
#include "constants.h"

#include <unistd.h>

#include "expect_command.h"
#include "expect_target.h"
#include "test_target_util.h"

#include "target/target.h"

Expand DownExpand Up@@ -193,7 +192,7 @@ TEST(TargetTestSourceGroup, Target_Build_SourceRecompile) {
CHECK_FALSE(loaded_sources.find(new_source_file) == loaded_sources.end());
}
{
sleep(1);
buildcc::m::blocking_sleep(1);

// * Force copy to trigger recompile for NEW_SOURCE
// *2 Current file is updated
Expand Down
7 changes: 3 additions & 4 deletionsbuildcc/lib/target/test/target/test_target_user_deps.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
#include <unistd.h>

#include "constants.h"

#include "expect_command.h"
#include "expect_target.h"
#include "test_target_util.h"

#include "target/target.h"

Expand DownExpand Up@@ -80,7 +79,7 @@ TEST(TargetTestUserDepsGroup, Target_Build_CompileDeps_Rebuild) {

{
// * To make sure that save_file is newer
sleep(1);
buildcc::m::blocking_sleep(1);
const fs::path new_source =
buildcc::env::get_project_root_dir() / "data" / "new_source.cpp";
std::string buf{""};
Expand DownExpand Up@@ -119,7 +118,7 @@ TEST(TargetTestUserDepsGroup, Target_Build_LinkDeps_Rebuild) {

{
// * To make sure that save_file is newer
sleep(1);
buildcc::m::blocking_sleep(1);
const fs::path new_source =
buildcc::env::get_project_root_dir() / "data" / "new_source.cpp";
std::string buf{""};
Expand Down
2 changes: 1 addition & 1 deletionbuildcc/lib/toolchain/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ if (${TESTING})

CppUTest
CppUTestExt
gcov
${TEST_LINK_LIBS}
)

add_executable(test_toolchain_verify
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp