Skip to content

Commit

Permalink
Add integration test for renumber-tests tool
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Jan 22, 2024
1 parent f1f7f22 commit fdc8ed1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 80 deletions.
33 changes: 30 additions & 3 deletions Tools/Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -14,10 +14,37 @@ function(add_tool_test tool)
-DTOOL_NAME:STRING=${tool}
-DTOOL_COMMAND:PATH=$<TARGET_FILE:${tool}>
"-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
)
10 changes: 4 additions & 6 deletions Tools/Tests/TestTool.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(DEBUG ON)
set(DEBUG OFF)
if(DEBUG)
function(dump_var var)
message(STATUS "${var}=${${var}}")
Expand All @@ -12,6 +12,7 @@ if(DEBUG)
TOOL_NAME
TOOL_COMMAND
TOOL_ARGS
COMPARE_FILES
)
dump_var(${var})
endforeach()
Expand Down Expand Up @@ -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()
13 changes: 2 additions & 11 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
6 changes: 3 additions & 3 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_)

Expand Down
6 changes: 3 additions & 3 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_)

Expand Down
15 changes: 3 additions & 12 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 2 additions & 20 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 2 additions & 20 deletions Tools/Tests/renumber-tests/Expected/Results/diffs/R8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Tools/Tests/renumber-tests/Inputs/Results/diffs/R1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

0 comments on commit fdc8ed1

Please sign in to comment.