diff --git a/Tools/Tests/CMakeLists.txt b/Tools/Tests/CMakeLists.txt index f312958..d254146 100644 --- a/Tools/Tests/CMakeLists.txt +++ b/Tools/Tests/CMakeLists.txt @@ -1,5 +1,5 @@ function(add_tool_test tool) - cmake_parse_arguments(args "" "" "COMMAND" ${ARGN}) + cmake_parse_arguments(args "" "" "COMMAND;COMPARE_FILES" ${ARGN}) set(INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${tool}/Inputs) set(EXPECTED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${tool}/Expected) set(TEST_DIR ${CMAKE_BINARY_DIR}/ToolTests/${tool}) @@ -14,10 +14,37 @@ function(add_tool_test tool) -DTOOL_NAME:STRING=${tool} -DTOOL_COMMAND:PATH=$ "-DTOOL_ARGS:STRING=${args_COMMAND}" + "-DCOMPARE_FILES:STRING=${args_COMPARE_FILES}" -P ${CMAKE_CURRENT_SOURCE_DIR}/TestTool.cmake ) set_property(TEST test-${tool}-tool PROPERTY LABELS ${tool} tool) endfunction() -add_tool_test(add-tests COMMAND Sources R Sources/TestRename.cpp Results) -add_tool_test(renumber-tests COMMAND Sources R Results) +add_tool_test(add-tests + COMMAND Sources R Sources/TestRename.cpp Results + COMPARE_FILES + Sources/TestRename.cpp + Results/CLionResults.md + Results/ReSharperCppResults.md + Results/diffs/R1.txt + Results/diffs/R2.txt + Results/diffs/R3.txt + Results/diffs/R4.txt + Results/diffs/R5.txt + Results/diffs/R6.txt + Results/diffs/R7.txt + Results/diffs/R8.txt +) +add_tool_test(renumber-tests + COMMAND Sources R Results + COMPARE_FILES + Sources/TestRename.cpp + Results/CLionResults.md + Results/ReSharperCppResults.md + Results/diffs/R1.txt + Results/diffs/R4.txt + Results/diffs/R5.txt + Results/diffs/R6.txt + Results/diffs/R7.txt + Results/diffs/R8.txt +) diff --git a/Tools/Tests/TestTool.cmake b/Tools/Tests/TestTool.cmake index f448753..39243b0 100644 --- a/Tools/Tests/TestTool.cmake +++ b/Tools/Tests/TestTool.cmake @@ -1,4 +1,4 @@ -set(DEBUG ON) +set(DEBUG OFF) if(DEBUG) function(dump_var var) message(STATUS "${var}=${${var}}") @@ -12,6 +12,7 @@ if(DEBUG) TOOL_NAME TOOL_COMMAND TOOL_ARGS + COMPARE_FILES ) dump_var(${var}) endforeach() @@ -61,9 +62,6 @@ function(compare_file relativePath) endif() endfunction() -compare_file(Sources/TestRename.cpp) -compare_file(Results/CLionResults.md) -compare_file(Results/ReSharperCppResults.md) -foreach(case RANGE 1 8) - compare_file(Results/diffs/R${case}.txt) +foreach(file ${COMPARE_FILES}) + compare_file(${file}) endforeach() diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R1.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R1.txt index c5468c4..f754fb1 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R1.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R1.txt @@ -9,14 +9,5 @@ index d1c1283..dd356e8 100644 -#define MACRO_NO_ARGS 3.14159f +#define GOINK 3.14159f - // #TEST#: R2 Rename the macro argument x_ from declaration - // #TEST#: R3 =R2 Rename the macro argument x_ from usage -@@ -645,7 +645,7 @@ void TestRename() - // #TEST#: R205 rename the variable Y::x - int y = test2.Operation() + X::x + X::y + Y::x; - -- float x = MACRO_NO_ARGS; -+ float x = GOINK; - x = MACRO_ONE_ARG(2.0f); - - { +class Operations +{ diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R4.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R4.txt index 540a7ba..3500645 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R4.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R4.txt @@ -3,9 +3,9 @@ index d1c1283..3e43246 100644 --- a/Sources/TestRename.cpp +++ b/Sources/TestRename.cpp @@ -15,7 +15,7 @@ - // #TEST#: R2 Rename the macro argument x_ from declaration - // #TEST#: R3 =R2 Rename the macro argument x_ from usage - // #TEST#: R4 Rename this macro + // #TEST#: R4 Rename the macro argument x_ from declaration + // #TEST#: R5 =R4 Rename the macro argument x_ from usage + // #TEST#: R6 Rename this macro -#define MACRO_ONE_ARG(x_) (2.0f * x_) +#define MACRO_ONE_ARG(goink_) (2.0f * goink_) diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R5.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R5.txt index 540a7ba..3500645 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R5.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R5.txt @@ -3,9 +3,9 @@ index d1c1283..3e43246 100644 --- a/Sources/TestRename.cpp +++ b/Sources/TestRename.cpp @@ -15,7 +15,7 @@ - // #TEST#: R2 Rename the macro argument x_ from declaration - // #TEST#: R3 =R2 Rename the macro argument x_ from usage - // #TEST#: R4 Rename this macro + // #TEST#: R4 Rename the macro argument x_ from declaration + // #TEST#: R5 =R4 Rename the macro argument x_ from usage + // #TEST#: R6 Rename this macro -#define MACRO_ONE_ARG(x_) (2.0f * x_) +#define MACRO_ONE_ARG(goink_) (2.0f * goink_) diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R6.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R6.txt index 0033be3..ef749e0 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R6.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R6.txt @@ -3,20 +3,11 @@ index d1c1283..8628cb4 100644 --- a/Sources/TestRename.cpp +++ b/Sources/TestRename.cpp @@ -15,7 +15,7 @@ - // #TEST#: R2 Rename the macro argument x_ from declaration - // #TEST#: R3 =R2 Rename the macro argument x_ from usage - // #TEST#: R4 Rename this macro + // #TEST#: R4 Rename the macro argument x_ from declaration + // #TEST#: R5 =R4 Rename the macro argument x_ from usage + // #TEST#: R6 Rename this macro -#define MACRO_ONE_ARG(x_) (2.0f * x_) +#define GOINK(x_) (2.0f * x_) class Operations { -@@ -646,7 +646,7 @@ void TestRename() - int y = test2.Operation() + X::x + X::y + Y::x; - - float x = MACRO_NO_ARGS; -- x = MACRO_ONE_ARG(2.0f); -+ x = GOINK(2.0f); - - { - // #TEST#: R206 Rename the namespace X diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R7.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R7.txt index cce691b..4590283 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R7.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R7.txt @@ -5,41 +5,23 @@ index d1c1283..a756ebe 100644 @@ -31,22 +31,22 @@ public: }; - // #TEST#: R5 Rename this class, but class in Rename2.cpp shouldn't be renamed + // #TEST#: R7 Rename this class, but class in Rename2.cpp shouldn't be renamed -class Rename1 +class Goink { public: - // #TEST#: R6 =R5 Rename this class via its c'tor + // #TEST#: R8 =R7 Rename this class via its c'tor - Rename1() : x() + Goink() : x() { } - // #TEST#: R7 =R5 Rename this class via its d'tor - ~Rename1() + ~Goink() { } - // #TEST#: R8 =R5 Rename this class via typedef - // #TEST#: R9 Rename typedef MyClass - typedef Rename1 MyClass; + typedef Goink MyClass; - // #TEST#: R10 Rename this method void Operation() -@@ -616,11 +616,11 @@ void TestRename() - - // #TEST#: R191 Rename MyClass - // #TEST#: R192 =R5 Rename Rename1 from scope qualifier -- Rename1::MyClass myClass; -+ Goink::MyClass myClass; - myClass.Operation(); - - // #TEST#: R193 Rename this variable -- Rename1 test; -+ Goink test; - // #TEST#: R194 Rename this method - test.Operation(); - // #TEST#: R195 Rename this function diff --git a/Tools/Tests/renumber-tests/Expected/Results/diffs/R8.txt b/Tools/Tests/renumber-tests/Expected/Results/diffs/R8.txt index cce691b..4590283 100644 --- a/Tools/Tests/renumber-tests/Expected/Results/diffs/R8.txt +++ b/Tools/Tests/renumber-tests/Expected/Results/diffs/R8.txt @@ -5,41 +5,23 @@ index d1c1283..a756ebe 100644 @@ -31,22 +31,22 @@ public: }; - // #TEST#: R5 Rename this class, but class in Rename2.cpp shouldn't be renamed + // #TEST#: R7 Rename this class, but class in Rename2.cpp shouldn't be renamed -class Rename1 +class Goink { public: - // #TEST#: R6 =R5 Rename this class via its c'tor + // #TEST#: R8 =R7 Rename this class via its c'tor - Rename1() : x() + Goink() : x() { } - // #TEST#: R7 =R5 Rename this class via its d'tor - ~Rename1() + ~Goink() { } - // #TEST#: R8 =R5 Rename this class via typedef - // #TEST#: R9 Rename typedef MyClass - typedef Rename1 MyClass; + typedef Goink MyClass; - // #TEST#: R10 Rename this method void Operation() -@@ -616,11 +616,11 @@ void TestRename() - - // #TEST#: R191 Rename MyClass - // #TEST#: R192 =R5 Rename Rename1 from scope qualifier -- Rename1::MyClass myClass; -+ Goink::MyClass myClass; - myClass.Operation(); - - // #TEST#: R193 Rename this variable -- Rename1 test; -+ Goink test; - // #TEST#: R194 Rename this method - test.Operation(); - // #TEST#: R195 Rename this function diff --git a/Tools/Tests/renumber-tests/Inputs/Results/diffs/R1.txt b/Tools/Tests/renumber-tests/Inputs/Results/diffs/R1.txt index fa31d30..f754fb1 100644 --- a/Tools/Tests/renumber-tests/Inputs/Results/diffs/R1.txt +++ b/Tools/Tests/renumber-tests/Inputs/Results/diffs/R1.txt @@ -9,5 +9,5 @@ index d1c1283..dd356e8 100644 -#define MACRO_NO_ARGS 3.14159f +#define GOINK 3.14159f - // #TEST#: R2 Rename the macro argument x_ from declaration - // #TEST#: R3 =R2 Rename the macro argument x_ from usage +class Operations +{