mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
CMakeLibTests: Use runTests
Also, improve it a little.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <cm/filesystem>
|
||||
|
||||
#include "testCommon.h"
|
||||
|
||||
namespace {
|
||||
|
||||
namespace fs = cm::filesystem;
|
||||
@@ -971,38 +973,9 @@ bool testNonMemberFunctions()
|
||||
|
||||
int testCMFilesystemPath(int /*unused*/, char* /*unused*/[])
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (!testConstructors()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testConcatenation()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testModifiers()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testObservers()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testCompare()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testGeneration()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testDecomposition()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testQueries()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testIterators()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testNonMemberFunctions()) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
return runTests({ testConstructors, testConcatenation, testModifiers,
|
||||
testObservers, testCompare, testGeneration,
|
||||
testDecomposition, testQueries, testIterators,
|
||||
testNonMemberFunctions },
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "cmCMakePath.h"
|
||||
|
||||
#include "testCommon.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void checkResult(bool success)
|
||||
@@ -422,20 +424,6 @@ bool testAppend()
|
||||
|
||||
int testCMakePath(int /*unused*/, char* /*unused*/[])
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (!testConstructors()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testAssign()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testConcat()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testAppend()) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
return runTests({ testConstructors, testAssign, testConcat, testAppend },
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -3,28 +3,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define ASSERT_TRUE(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
|
||||
std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << '\n'; \
|
||||
return false; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
inline int runTests(std::vector<std::function<bool()>> const& tests)
|
||||
#define BOOL_STRING(b) ((b) ? "TRUE" : "FALSE")
|
||||
|
||||
namespace {
|
||||
|
||||
inline int runTests(std::initializer_list<std::function<bool()>> const& tests,
|
||||
const bool fail_fast = true)
|
||||
{
|
||||
int result = 0;
|
||||
for (auto const& test : tests) {
|
||||
if (!test()) {
|
||||
return 1;
|
||||
result = 1;
|
||||
if (fail_fast) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::cout << ".";
|
||||
std::cout << '.';
|
||||
}
|
||||
|
||||
std::cout << " Passed" << std::endl;
|
||||
return 0;
|
||||
if (!result) {
|
||||
std::cout << " Passed\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#define BOOL_STRING(b) ((b) ? "TRUE" : "FALSE")
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm3p/cppdap/future.h>
|
||||
#include <cm3p/cppdap/io.h>
|
||||
@@ -194,8 +193,6 @@ bool testThreadsRequestAfterThreadExitedEvent()
|
||||
|
||||
int testDebuggerAdapter(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testBasicProtocol,
|
||||
testThreadsRequestAfterThreadExitedEvent,
|
||||
});
|
||||
return runTests(
|
||||
{ testBasicProtocol, testThreadsRequestAfterThreadExitedEvent });
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm3p/cppdap/future.h>
|
||||
#include <cm3p/cppdap/io.h>
|
||||
@@ -180,7 +178,5 @@ bool testProtocolWithPipes()
|
||||
|
||||
int testDebuggerAdapterPipe(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testProtocolWithPipes,
|
||||
});
|
||||
return runTests({ testProtocolWithPipes });
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -177,9 +176,7 @@ static bool testSourceFileLoadedAfterHandleBreakpointRequest()
|
||||
|
||||
int testDebuggerBreakpointManager(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testHandleBreakpointRequestBeforeFileIsLoaded,
|
||||
testHandleBreakpointRequestAfterFileIsLoaded,
|
||||
testSourceFileLoadedAfterHandleBreakpointRequest,
|
||||
});
|
||||
return runTests({ testHandleBreakpointRequestBeforeFileIsLoaded,
|
||||
testHandleBreakpointRequestAfterFileIsLoaded,
|
||||
testSourceFileLoadedAfterHandleBreakpointRequest });
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -27,7 +26,5 @@ static bool testStackFrameFunctionName()
|
||||
|
||||
int testDebuggerThread(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testStackFrameFunctionName,
|
||||
});
|
||||
return runTests({ testStackFrameFunctionName });
|
||||
}
|
||||
|
||||
@@ -204,11 +204,7 @@ static bool testNoSupportsVariableType()
|
||||
|
||||
int testDebuggerVariables(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testUniqueIds,
|
||||
testConstructors,
|
||||
testIgnoreEmptyStringEntries,
|
||||
testSortTheResult,
|
||||
testNoSupportsVariableType,
|
||||
});
|
||||
return runTests({ testUniqueIds, testConstructors,
|
||||
testIgnoreEmptyStringEntries, testSortTheResult,
|
||||
testNoSupportsVariableType });
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -571,18 +570,10 @@ static bool testCreateFromFileSets()
|
||||
|
||||
int testDebuggerVariablesHelper(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testCreateFromPolicyMap,
|
||||
testCreateFromPairVector,
|
||||
testCreateFromSet,
|
||||
testCreateFromStringVector,
|
||||
testCreateFromTarget,
|
||||
testCreateFromGlobalGenerator,
|
||||
testCreateFromMakefile,
|
||||
testCreateFromStackFrame,
|
||||
testCreateFromTests,
|
||||
testCreateFromBTStringVector,
|
||||
testCreateFromFileSet,
|
||||
testCreateFromFileSets,
|
||||
});
|
||||
return runTests({ testCreateFromPolicyMap, testCreateFromPairVector,
|
||||
testCreateFromSet, testCreateFromStringVector,
|
||||
testCreateFromTarget, testCreateFromGlobalGenerator,
|
||||
testCreateFromMakefile, testCreateFromStackFrame,
|
||||
testCreateFromTests, testCreateFromBTStringVector,
|
||||
testCreateFromFileSet, testCreateFromFileSets });
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -44,7 +43,5 @@ static bool testVariablesRegistration()
|
||||
|
||||
int testDebuggerVariablesManager(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
testVariablesRegistration,
|
||||
});
|
||||
return runTests({ testVariablesRegistration });
|
||||
}
|
||||
|
||||
@@ -465,47 +465,8 @@ bool testRequired()
|
||||
|
||||
int testJSONHelpers(int /*unused*/, char* /*unused*/[])
|
||||
{
|
||||
if (!testInt()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testUInt()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testBool()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testString()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testObject()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testObjectInherited()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testObjectNoExtra()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testObjectOptional()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testVector()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testVectorFilter()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMap()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMapFilter()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOptional()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testRequired()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return runTests({ testInt, testUInt, testBool, testString, testObject,
|
||||
testObjectInherited, testObjectNoExtra, testObjectOptional,
|
||||
testVector, testVectorFilter, testMap, testMapFilter,
|
||||
testOptional, testRequired });
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "cmList.h"
|
||||
|
||||
#include "testCommon.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void checkResult(bool success)
|
||||
@@ -951,44 +953,9 @@ bool testStaticModifiers()
|
||||
|
||||
int testList(int /*unused*/, char* /*unused*/[])
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (!testConstructors()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testAssign()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testConversions()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testAccess()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testModifiers()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testRemoveItems()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testRemoveDuplicates()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testFilter()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testReverse()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testSort()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testTransform()) {
|
||||
result = 1;
|
||||
}
|
||||
if (!testStaticModifiers()) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
return runTests({ testConstructors, testAssign, testConversions, testAccess,
|
||||
testModifiers, testRemoveItems, testRemoveDuplicates,
|
||||
testFilter, testReverse, testSort, testTransform,
|
||||
testStaticModifiers },
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -1157,188 +1157,65 @@ static bool testStability()
|
||||
|
||||
int testString(int /*unused*/, char* /*unused*/[])
|
||||
{
|
||||
if (!testConstructDefault()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromNullPtr()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromCStrNull()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromCharArray()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromCStr()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromStdString()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromView()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromChar()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromInitList()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromBuffer()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromInputIterator()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromN()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructFromStaticStringView()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructCopy()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testConstructMove()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignCopy()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignMove()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromChar()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromView()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromStdString()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromCStr()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromCharArray()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromCStrNull()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromNullPtr()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromInitList()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAssignFromStaticStringView()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorBool()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorIndex()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorPlusEqual()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorCompare()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorStream()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testOperatorStdStringPlusEqual()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_borrow()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_view()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_empty()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_length()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_at()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_front_back()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_clear()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_insert()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_erase()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_push_back()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_pop_back()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_replace()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_copy()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_resize()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_swap()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethodIterators()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_substr_AtEndBorrowed()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_substr_AtEndOwned()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_substr_AtStartBorrowed()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_substr_AtStartOwned()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_compare()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_find()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_rfind()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_find_first_of()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_find_first_not_of()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_find_last_of()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testMethod_find_last_not_of()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testAddition()) {
|
||||
return 1;
|
||||
}
|
||||
if (!testStability()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return runTests({ testConstructDefault,
|
||||
testConstructFromNullPtr,
|
||||
testConstructFromCStrNull,
|
||||
testConstructFromCharArray,
|
||||
testConstructFromCStr,
|
||||
testConstructFromStdString,
|
||||
testConstructFromView,
|
||||
testConstructFromChar,
|
||||
testConstructFromInitList,
|
||||
testConstructFromBuffer,
|
||||
testConstructFromInputIterator,
|
||||
testConstructFromN,
|
||||
testConstructFromStaticStringView,
|
||||
testConstructCopy,
|
||||
testConstructMove,
|
||||
testAssignCopy,
|
||||
testAssignMove,
|
||||
testAssignFromChar,
|
||||
testAssignFromView,
|
||||
testAssignFromStdString,
|
||||
testAssignFromCStr,
|
||||
testAssignFromCharArray,
|
||||
testAssignFromCStrNull,
|
||||
testAssignFromNullPtr,
|
||||
testAssignFromInitList,
|
||||
testAssignFromStaticStringView,
|
||||
testOperatorBool,
|
||||
testOperatorIndex,
|
||||
testOperatorPlusEqual,
|
||||
testOperatorCompare,
|
||||
testOperatorStream,
|
||||
testOperatorStdStringPlusEqual,
|
||||
testMethod_borrow,
|
||||
testMethod_view,
|
||||
testMethod_empty,
|
||||
testMethod_length,
|
||||
testMethod_at,
|
||||
testMethod_front_back,
|
||||
testMethod_clear,
|
||||
testMethod_insert,
|
||||
testMethod_erase,
|
||||
testMethod_push_back,
|
||||
testMethod_pop_back,
|
||||
testMethod_replace,
|
||||
testMethod_copy,
|
||||
testMethod_resize,
|
||||
testMethod_swap,
|
||||
testMethodIterators,
|
||||
testMethod_substr_AtEndBorrowed,
|
||||
testMethod_substr_AtEndOwned,
|
||||
testMethod_substr_AtStartBorrowed,
|
||||
testMethod_substr_AtStartOwned,
|
||||
testMethod_compare,
|
||||
testMethod_find,
|
||||
testMethod_rfind,
|
||||
testMethod_find_first_of,
|
||||
testMethod_find_first_not_of,
|
||||
testMethod_find_last_of,
|
||||
testMethod_find_last_not_of,
|
||||
testAddition,
|
||||
testStability });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user