From 3b09cf706bd2e47dd29cc0f5295a708c1266493a Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 21 Jan 2024 00:19:18 -0700 Subject: [PATCH] Add integration test for add-tests tool Some things are still hard-coded for add-tests, but this can be generalized for other tools later. Fixes #71 --- Tools/CMakeLists.txt | 4 ++ Tools/Tests/CMakeLists.txt | 13 +++++ Tools/Tests/Expected/Results/CLionResults.md | 24 ++++++++ .../Expected/Results/ReSharperCppResults.md | 24 ++++++++ Tools/Tests/Expected/Results/diffs/R1.txt | 22 ++++++++ Tools/Tests/Expected/Results/diffs/R2.txt | 13 +++++ Tools/Tests/Expected/Results/diffs/R3.txt | 13 +++++ Tools/Tests/Expected/Results/diffs/R4.txt | 22 ++++++++ Tools/Tests/Expected/Results/diffs/R5.txt | 45 +++++++++++++++ Tools/Tests/Expected/Results/diffs/R6.txt | 45 +++++++++++++++ Tools/Tests/Expected/Results/diffs/R7.txt | 1 + Tools/Tests/Expected/Results/diffs/R8.txt | 1 + Tools/Tests/Expected/Sources/TestRename.cpp | 55 +++++++++++++++++++ Tools/Tests/Inputs/Results/CLionResults.md | 22 ++++++++ .../Inputs/Results/ReSharperCppResults.md | 22 ++++++++ Tools/Tests/Inputs/Results/diffs/R1.txt | 22 ++++++++ Tools/Tests/Inputs/Results/diffs/R2.txt | 13 +++++ Tools/Tests/Inputs/Results/diffs/R3.txt | 13 +++++ Tools/Tests/Inputs/Results/diffs/R4.txt | 22 ++++++++ Tools/Tests/Inputs/Results/diffs/R5.txt | 45 +++++++++++++++ Tools/Tests/Inputs/Results/diffs/R6.txt | 45 +++++++++++++++ Tools/Tests/Inputs/Sources/TestRename.cpp | 55 +++++++++++++++++++ Tools/Tests/TestAddTests.cmake | 37 +++++++++++++ 23 files changed, 578 insertions(+) create mode 100644 Tools/Tests/CMakeLists.txt create mode 100644 Tools/Tests/Expected/Results/CLionResults.md create mode 100644 Tools/Tests/Expected/Results/ReSharperCppResults.md create mode 100644 Tools/Tests/Expected/Results/diffs/R1.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R2.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R3.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R4.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R5.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R6.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R7.txt create mode 100644 Tools/Tests/Expected/Results/diffs/R8.txt create mode 100644 Tools/Tests/Expected/Sources/TestRename.cpp create mode 100644 Tools/Tests/Inputs/Results/CLionResults.md create mode 100644 Tools/Tests/Inputs/Results/ReSharperCppResults.md create mode 100644 Tools/Tests/Inputs/Results/diffs/R1.txt create mode 100644 Tools/Tests/Inputs/Results/diffs/R2.txt create mode 100644 Tools/Tests/Inputs/Results/diffs/R3.txt create mode 100644 Tools/Tests/Inputs/Results/diffs/R4.txt create mode 100644 Tools/Tests/Inputs/Results/diffs/R5.txt create mode 100644 Tools/Tests/Inputs/Results/diffs/R6.txt create mode 100644 Tools/Tests/Inputs/Sources/TestRename.cpp create mode 100644 Tools/Tests/TestAddTests.cmake diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt index 801eb27..34edbe2 100644 --- a/Tools/CMakeLists.txt +++ b/Tools/CMakeLists.txt @@ -7,3 +7,7 @@ add_subdirectory(TestDiffs) add_subdirectory(TestNames) add_subdirectory(TestResults) add_subdirectory(ToolSummary) + +if(BUILD_TESTING) + add_subdirectory(Tests) +endif() diff --git a/Tools/Tests/CMakeLists.txt b/Tools/Tests/CMakeLists.txt new file mode 100644 index 0000000..8c8534c --- /dev/null +++ b/Tools/Tests/CMakeLists.txt @@ -0,0 +1,13 @@ +set(INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Inputs) +set(EXPECTED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Expected) +add_test(NAME test-add-tests-tool + COMMAND ${CMAKE_COMMAND} + -DCMAKE_COMMAND:STRING=${CMAKE_COMMAND} + -DTEST_NAME:STRING=add-tests + -DTEST_DIR:STRING=${CMAKE_BINARY_DIR}/ToolTests + -DINPUT_DIR:STRING=${INPUT_DIR} + -DEXPECTED_DIR:STRING=${EXPECTED_DIR} + -DTOOL=$ + -P ${CMAKE_CURRENT_SOURCE_DIR}/TestAddTests.cmake +) +set_tests_properties(test-add-tests-tool PROPERTIES LABELS add-tests) diff --git a/Tools/Tests/Expected/Results/CLionResults.md b/Tools/Tests/Expected/Results/CLionResults.md new file mode 100644 index 0000000..160fbae --- /dev/null +++ b/Tools/Tests/Expected/Results/CLionResults.md @@ -0,0 +1,24 @@ +# CLion + +## Add Block Delimiter +Case | Result +---- | ------ +ABD1 | Pass +ABD2 | Pass +ABD3 | Pass +ABD4 | Pass +ABD5 | Pass +ABD6 | Pass +ABD7 | Pass + +## Rename +Case | Result +---- | ------ +R1 | Pass +R2 | Pass +R3 | Pass +R4 | Pass +R5 | Failure (selects unrelated names) [1938](https://youtrack.jetbrains.com/issue/CPP-1938) +R6 | Failure (selects unrelated names) [1938](https://youtrack.jetbrains.com/issue/CPP-1938) +R7 | +R8 | diff --git a/Tools/Tests/Expected/Results/ReSharperCppResults.md b/Tools/Tests/Expected/Results/ReSharperCppResults.md new file mode 100644 index 0000000..2583b0e --- /dev/null +++ b/Tools/Tests/Expected/Results/ReSharperCppResults.md @@ -0,0 +1,24 @@ +# ReSharper for C++ + +## Add Block Delimiter +Case | Result +---- | ------ +ABD1 | Pass +ABD2 | Pass +ABD3 | Pass +ABD4 | Pass +ABD5 | Pass +ABD6 | Pass +ABD7 | Pass + +## Rename +Case | Result +---- | ------ +R1 | Pass +R2 | Failure (unavailable) [RSCPP-15796](https://youtrack.jetbrains.com/issue/RSCPP-15796) +R3 | Failure (unavailable) [RSCPP-15796](https://youtrack.jetbrains.com/issue/RSCPP-15796) +R4 | Pass +R5 | Pass +R6 | Pass +R7 | +R8 | diff --git a/Tools/Tests/Expected/Results/diffs/R1.txt b/Tools/Tests/Expected/Results/diffs/R1.txt new file mode 100644 index 0000000..c5468c4 --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R1.txt @@ -0,0 +1,22 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..dd356e8 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -10,7 +10,7 @@ + // updates all references to the modified element. + + // #TEST#: R1 Rename this macro +-#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); + + { diff --git a/Tools/Tests/Expected/Results/diffs/R2.txt b/Tools/Tests/Expected/Results/diffs/R2.txt new file mode 100644 index 0000000..540a7ba --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R2.txt @@ -0,0 +1,13 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#define MACRO_ONE_ARG(x_) (2.0f * x_) ++#define MACRO_ONE_ARG(goink_) (2.0f * goink_) + + class Operations + { diff --git a/Tools/Tests/Expected/Results/diffs/R3.txt b/Tools/Tests/Expected/Results/diffs/R3.txt new file mode 100644 index 0000000..540a7ba --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R3.txt @@ -0,0 +1,13 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#define MACRO_ONE_ARG(x_) (2.0f * x_) ++#define MACRO_ONE_ARG(goink_) (2.0f * goink_) + + class Operations + { diff --git a/Tools/Tests/Expected/Results/diffs/R4.txt b/Tools/Tests/Expected/Results/diffs/R4.txt new file mode 100644 index 0000000..0033be3 --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R4.txt @@ -0,0 +1,22 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#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/Expected/Results/diffs/R5.txt b/Tools/Tests/Expected/Results/diffs/R5.txt new file mode 100644 index 0000000..cce691b --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R5.txt @@ -0,0 +1,45 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..a756ebe 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -31,22 +31,22 @@ public: + }; + + // #TEST#: R5 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 +- 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/Expected/Results/diffs/R6.txt b/Tools/Tests/Expected/Results/diffs/R6.txt new file mode 100644 index 0000000..cce691b --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R6.txt @@ -0,0 +1,45 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..a756ebe 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -31,22 +31,22 @@ public: + }; + + // #TEST#: R5 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 +- 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/Expected/Results/diffs/R7.txt b/Tools/Tests/Expected/Results/diffs/R7.txt new file mode 100644 index 0000000..cb496d4 --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R7.txt @@ -0,0 +1 @@ +AWAITING TEST RESULTS diff --git a/Tools/Tests/Expected/Results/diffs/R8.txt b/Tools/Tests/Expected/Results/diffs/R8.txt new file mode 100644 index 0000000..cb496d4 --- /dev/null +++ b/Tools/Tests/Expected/Results/diffs/R8.txt @@ -0,0 +1 @@ +AWAITING TEST RESULTS diff --git a/Tools/Tests/Expected/Sources/TestRename.cpp b/Tools/Tests/Expected/Sources/TestRename.cpp new file mode 100644 index 0000000..7eef8be --- /dev/null +++ b/Tools/Tests/Expected/Sources/TestRename.cpp @@ -0,0 +1,55 @@ +#include "Rename.h" + +#include "Require.h" + +#include +#include + +// Renames a local variable, function, method, field, property, parameter, +// type, namespace, active CSS style, C++ global variable or C++ macro and +// updates all references to the modified element. + +// #TEST#: R1 Rename this macro +#define MACRO_NO_ARGS 3.14159f + +// #TEST#: R2 Rename the macro argument x_ from declaration +// #TEST#: R3 =R2 Rename the macro argument x_ from usage +// #TEST#: R4 Rename this macro +#define MACRO_ONE_ARG(x_) (2.0f * x_) + +class Operations +{ +public: + // #TEST#: R7 Rename method + int Operation1() + { + return 1; + } + // #TEST#: R8 Rename method + int Operation2() + { + return 2; + } +}; + +// #TEST#: R5 Rename this class, but class in Rename2.cpp shouldn't be renamed +class Rename1 +{ +public: + // #TEST#: R6 =R5 Rename this class via its c'tor + Rename1() : x() + { + } + + ~Rename1() + { + } + + typedef Rename1 MyClass; + + void Operation() + { + } + + int x; +}; diff --git a/Tools/Tests/Inputs/Results/CLionResults.md b/Tools/Tests/Inputs/Results/CLionResults.md new file mode 100644 index 0000000..a09d879 --- /dev/null +++ b/Tools/Tests/Inputs/Results/CLionResults.md @@ -0,0 +1,22 @@ +# CLion + +## Add Block Delimiter +Case | Result +---- | ------ +ABD1 | Pass +ABD2 | Pass +ABD3 | Pass +ABD4 | Pass +ABD5 | Pass +ABD6 | Pass +ABD7 | Pass + +## Rename +Case | Result +---- | ------ +R1 | Pass +R2 | Pass +R3 | Pass +R4 | Pass +R5 | Failure (selects unrelated names) [1938](https://youtrack.jetbrains.com/issue/CPP-1938) +R6 | Failure (selects unrelated names) [1938](https://youtrack.jetbrains.com/issue/CPP-1938) diff --git a/Tools/Tests/Inputs/Results/ReSharperCppResults.md b/Tools/Tests/Inputs/Results/ReSharperCppResults.md new file mode 100644 index 0000000..d7e8310 --- /dev/null +++ b/Tools/Tests/Inputs/Results/ReSharperCppResults.md @@ -0,0 +1,22 @@ +# ReSharper for C++ + +## Add Block Delimiter +Case | Result +---- | ------ +ABD1 | Pass +ABD2 | Pass +ABD3 | Pass +ABD4 | Pass +ABD5 | Pass +ABD6 | Pass +ABD7 | Pass + +## Rename +Case | Result +---- | ------ +R1 | Pass +R2 | Failure (unavailable) [RSCPP-15796](https://youtrack.jetbrains.com/issue/RSCPP-15796) +R3 | Failure (unavailable) [RSCPP-15796](https://youtrack.jetbrains.com/issue/RSCPP-15796) +R4 | Pass +R5 | Pass +R6 | Pass diff --git a/Tools/Tests/Inputs/Results/diffs/R1.txt b/Tools/Tests/Inputs/Results/diffs/R1.txt new file mode 100644 index 0000000..c5468c4 --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R1.txt @@ -0,0 +1,22 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..dd356e8 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -10,7 +10,7 @@ + // updates all references to the modified element. + + // #TEST#: R1 Rename this macro +-#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); + + { diff --git a/Tools/Tests/Inputs/Results/diffs/R2.txt b/Tools/Tests/Inputs/Results/diffs/R2.txt new file mode 100644 index 0000000..540a7ba --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R2.txt @@ -0,0 +1,13 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#define MACRO_ONE_ARG(x_) (2.0f * x_) ++#define MACRO_ONE_ARG(goink_) (2.0f * goink_) + + class Operations + { diff --git a/Tools/Tests/Inputs/Results/diffs/R3.txt b/Tools/Tests/Inputs/Results/diffs/R3.txt new file mode 100644 index 0000000..540a7ba --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R3.txt @@ -0,0 +1,13 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#define MACRO_ONE_ARG(x_) (2.0f * x_) ++#define MACRO_ONE_ARG(goink_) (2.0f * goink_) + + class Operations + { diff --git a/Tools/Tests/Inputs/Results/diffs/R4.txt b/Tools/Tests/Inputs/Results/diffs/R4.txt new file mode 100644 index 0000000..0033be3 --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R4.txt @@ -0,0 +1,22 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +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 +-#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/Inputs/Results/diffs/R5.txt b/Tools/Tests/Inputs/Results/diffs/R5.txt new file mode 100644 index 0000000..cce691b --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R5.txt @@ -0,0 +1,45 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..a756ebe 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -31,22 +31,22 @@ public: + }; + + // #TEST#: R5 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 +- 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/Inputs/Results/diffs/R6.txt b/Tools/Tests/Inputs/Results/diffs/R6.txt new file mode 100644 index 0000000..cce691b --- /dev/null +++ b/Tools/Tests/Inputs/Results/diffs/R6.txt @@ -0,0 +1,45 @@ +diff --git a/Sources/TestRename.cpp b/Sources/TestRename.cpp +index d1c1283..a756ebe 100644 +--- a/Sources/TestRename.cpp ++++ b/Sources/TestRename.cpp +@@ -31,22 +31,22 @@ public: + }; + + // #TEST#: R5 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 +- 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/Inputs/Sources/TestRename.cpp b/Tools/Tests/Inputs/Sources/TestRename.cpp new file mode 100644 index 0000000..e222152 --- /dev/null +++ b/Tools/Tests/Inputs/Sources/TestRename.cpp @@ -0,0 +1,55 @@ +#include "Rename.h" + +#include "Require.h" + +#include +#include + +// Renames a local variable, function, method, field, property, parameter, +// type, namespace, active CSS style, C++ global variable or C++ macro and +// updates all references to the modified element. + +// #TEST#: R1 Rename this macro +#define MACRO_NO_ARGS 3.14159f + +// #TEST#: R2 Rename the macro argument x_ from declaration +// #TEST#: R3 =R2 Rename the macro argument x_ from usage +// #TEST#: R4 Rename this macro +#define MACRO_ONE_ARG(x_) (2.0f * x_) + +class Operations +{ +public: + // #GOINK#: Rxx Rename method + int Operation1() + { + return 1; + } + // #GOINK#: Rxx Rename method + int Operation2() + { + return 2; + } +}; + +// #TEST#: R5 Rename this class, but class in Rename2.cpp shouldn't be renamed +class Rename1 +{ +public: + // #TEST#: R6 =R5 Rename this class via its c'tor + Rename1() : x() + { + } + + ~Rename1() + { + } + + typedef Rename1 MyClass; + + void Operation() + { + } + + int x; +}; diff --git a/Tools/Tests/TestAddTests.cmake b/Tools/Tests/TestAddTests.cmake new file mode 100644 index 0000000..977c20c --- /dev/null +++ b/Tools/Tests/TestAddTests.cmake @@ -0,0 +1,37 @@ +set(TEST_DIR "${TEST_DIR}/${TEST_NAME}") + +# copy INPUT_DIR contents to TEST_DIR +file(COPY ${INPUT_DIR}/Sources DESTINATION ${TEST_DIR}) +file(COPY ${INPUT_DIR}/Results DESTINATION ${TEST_DIR}) + +# run tool +execute_process( + COMMAND ${TOOL} ${TEST_DIR}/Sources R ${TEST_DIR}/Sources/TestRename.cpp ${TEST_DIR}/Results +) + +# compare TEST_DIR contents to EXPECTED_DIR +function(compare_file relativePath) + execute_process( + COMMAND ${CMAKE_COMMAND} -E compare_files + ${TEST_DIR}/${relativePath} ${EXPECTED_DIR}/${relativePath} + RESULT_VARIABLE difference + ) + if(difference EQUAL 0) + message(STATUS "${TEST_DIR}/${relativePath} ${EXPECTED_DIR}/${relativePath} are equal") + elseif(difference EQUAL 1) + message(STATUS "${TEST_DIR}/${relativePath}:") + execute_process(COMMAND ${CMAKE_COMMAND} -E cat "${TEST_DIR}/${relativePath}") + message(STATUS "${EXPECTED_DIR}/${relativePath}:") + execute_process(COMMAND ${CMAKE_COMMAND} -E cat "${EXPECTED_DIR}/${relativePath}") + message(FATAL_ERROR "${TEST_DIR}/${relativePath} ${EXPECTED_DIR}/${relativePath} are different") + else() + message(FATAL_ERROR "Error while comparing ${TEST_DIR}/${relativePath} ${EXPECTED_DIR}/${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) +endforeach()