Skip to content

Commit

Permalink
Add integration test for add-tests tool
Browse files Browse the repository at this point in the history
Some things are still hard-coded for add-tests, but this can be
generalized for other tools later.

Fixes #71
  • Loading branch information
LegalizeAdulthood committed Jan 21, 2024
1 parent d1f70cb commit 3b09cf7
Show file tree
Hide file tree
Showing 23 changed files with 578 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ add_subdirectory(TestDiffs)
add_subdirectory(TestNames)
add_subdirectory(TestResults)
add_subdirectory(ToolSummary)

if(BUILD_TESTING)
add_subdirectory(Tests)
endif()
13 changes: 13 additions & 0 deletions Tools/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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=$<TARGET_FILE:add-tests>
-P ${CMAKE_CURRENT_SOURCE_DIR}/TestAddTests.cmake
)
set_tests_properties(test-add-tests-tool PROPERTIES LABELS add-tests)
24 changes: 24 additions & 0 deletions Tools/Tests/Expected/Results/CLionResults.md
Original file line number Diff line number Diff line change
@@ -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 |
24 changes: 24 additions & 0 deletions Tools/Tests/Expected/Results/ReSharperCppResults.md
Original file line number Diff line number Diff line change
@@ -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 |
22 changes: 22 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R1.txt
Original file line number Diff line number Diff line change
@@ -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);

{
13 changes: 13 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R2.txt
Original file line number Diff line number Diff line change
@@ -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
{
13 changes: 13 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R3.txt
Original file line number Diff line number Diff line change
@@ -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
{
22 changes: 22 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R4.txt
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R5.txt
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions Tools/Tests/Expected/Results/diffs/R6.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Tools/Tests/Expected/Results/diffs/R7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AWAITING TEST RESULTS
1 change: 1 addition & 0 deletions Tools/Tests/Expected/Results/diffs/R8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AWAITING TEST RESULTS
55 changes: 55 additions & 0 deletions Tools/Tests/Expected/Sources/TestRename.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "Rename.h"

#include "Require.h"

#include <stdexcept>
#include <string>

// 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;
};
22 changes: 22 additions & 0 deletions Tools/Tests/Inputs/Results/CLionResults.md
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 22 additions & 0 deletions Tools/Tests/Inputs/Results/ReSharperCppResults.md
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions Tools/Tests/Inputs/Results/diffs/R1.txt
Original file line number Diff line number Diff line change
@@ -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);

{
13 changes: 13 additions & 0 deletions Tools/Tests/Inputs/Results/diffs/R2.txt
Original file line number Diff line number Diff line change
@@ -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
{
13 changes: 13 additions & 0 deletions Tools/Tests/Inputs/Results/diffs/R3.txt
Original file line number Diff line number Diff line change
@@ -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
{
Loading

0 comments on commit 3b09cf7

Please sign in to comment.