Skip to content

Commit

Permalink
Port sbroot test to automated pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
casch-at committed Jan 18, 2020
1 parent 5f1eaf4 commit 151815b
Show file tree
Hide file tree
Showing 40 changed files with 745 additions and 1,286 deletions.
18 changes: 7 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
*.o
*.a
Makefile
/Makefile
core
CMakeFiles/
cmake_install.cmake
CMakeCache.txt
rc
rdm
/cmake_install.cmake
/CMakeCache.txt
js
clangtest
gr
.gdb_history
.ninja_log
build.ninja
rules.ninja
/build.ninja
/rules.ninja
/.gdb_brestore
/.gdb_brestore.txt
/src/include/rct/rct-config.h
/src/librtags.dylib
/src/librtags.so
.ninja_deps
compile_commands.json
/.ninja_deps
/compile_commands.json
/tests/dtlcpptest/dtlcpptest
/bin/.gdb_brestore
/bin/.gdb_brestore.txt
Expand Down
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ if (RTAGS_ENABLE_DEV_OPTIONS)

include(CPack)
else ()
set(BUILD_TESTING 0 CACHE BOOL "Build testing files; requires cppunit.")
set(WITH_TESTS 0 CACHE BOOL "Build testing files; requires cppunit.")

set(RCT_WITH_TESTS ${BUILD_TESTING})
set(RCT_WITH_TESTS ${WITH_TESTS})

set(CMAKE_LEGACY_CYGWIN_WIN32 0)
if (CMAKE_COMPILER_IS_GNUCXX)
Expand Down Expand Up @@ -94,15 +94,7 @@ else ()

include(CTest)

if (BUILD_TESTING)
find_package(Perl QUIET)
if(PERL_FOUND)
add_test(NAME SBRootTest COMMAND perl "${CMAKE_SOURCE_DIR}/tests/sbroot/sbroot_test.pl")
set_property(TEST SBRootTest PROPERTY ENVIRONMENT "RTAGS_BINARY_DIR=${CMAKE_BINARY_DIR}/bin")
else()
message(WARNING "Perl not found! Excluding sbroot test from tests.")
endif()

if (WITH_TESTS)
find_program(PYTEST NAMES pytest py.test)
if (PYTEST)
add_test(NAME automated_tests COMMAND ${PYTEST} -svvv ${CMAKE_SOURCE_DIR}/tests/automated WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/automated)
Expand Down
9 changes: 5 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function usage ()
echo " --debug Compile RTags in debug mode"
echo " --release Compile RTags in release mode (default)"
echo " --system-clang Don't build llvm/clang as part of RTags' build process (default)"
echo " --build-tests Build tests"
echo " --with-tests Enable testing and build test files"
echo " --without-tests Disable testing and don't build test files"
echo " --build-clang Download and build llvm/clang as part of RTags' build process"
echo " --no-install Generate a build that isn't going to be installed"
echo " --prefix [arg] Set install prefix to arg"
Expand Down Expand Up @@ -62,11 +63,11 @@ while [ -n "$1" ]; do
--build-clang)
BUILD=1
;;
--build-tests)
CMAKE_ARGS="${CMAKE_ARGS} -DBUILD_TESTING=1"
--with-tests)
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_TESTS=1"
;;
--without-tests)
CMAKE_ARGS="${CMAKE_ARGS} -DBUILD_TESTING=0"
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_TESTS=0"
;;
--no-install)
CMAKE_ARGS="${CMAKE_ARGS} -DRTAGS_NO_INSTALL=1"
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen-man-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#
# Description: rc, rdm and help2man need to be in the PATH environment variable.
# Description: rc, rdm, help2man and sed need to be in the PATH environment variable.
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

if [ $# -lt 1 ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# - ASAN (default value is "1")
declare -a CMAKE_PARAMS=("-DCMAKE_CXX_COMPILER=$CXX$COMPILER_VERSION"
"-DCMAKE_C_COMPILER=$CC$COMPILER_VERSION"
"-DBUILD_TESTING=1")
"-DWITH_TESTS=1")

if [ "$ASAN" ]; then
CMAKE_PARAMS+=("-DASAN=address,undefined")
Expand Down
15 changes: 10 additions & 5 deletions tests/automated/AnonymousUnion/expectation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[
{
"name": "follow_location",
"rc-command": [ "--follow-location", "{0}/main.cpp:9:7:"],
"expectation": ["{0}/main.cpp:5:17:"]
}
{
"name": "follow_location",
"rc-command": [
"--follow-location",
"{0}/main.cpp:9:7:"
],
"expectation": [
"{0}/main.cpp:5:17:"
]
}
]
34 changes: 26 additions & 8 deletions tests/automated/ClassTemplates/expectation.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
[
{ "name": "find_references",
"rc-command": [ "--references", "{0}/main.cpp:9:8"],
"expectation": ["{0}/main.cpp:16:17","{0}/main.cpp:17:17","{0}/main.cpp:20:5"] },

{ "name": "multiple_template_parameters",
"rc-command": [ "--references", "{0}/main.cpp:25:8"],
"expectation": ["{0}/main.cpp:27:17","{0}/main.cpp:28:17","{0}/main.cpp:29:17",
"{0}/main.cpp:30:17", "{0}/main.cpp:31:17"] }
{
"name": "find_references",
"rc-command": [
"--references",
"{0}/main.cpp:9:8"
],
"expectation": [
"{0}/main.cpp:16:17",
"{0}/main.cpp:17:17",
"{0}/main.cpp:20:5"
]
},
{
"name": "multiple_template_parameters",
"rc-command": [
"--references",
"{0}/main.cpp:25:8"
],
"expectation": [
"{0}/main.cpp:27:17",
"{0}/main.cpp:28:17",
"{0}/main.cpp:29:17",
"{0}/main.cpp:30:17",
"{0}/main.cpp:31:17"
]
}
]
14 changes: 11 additions & 3 deletions tests/automated/ClassTemplates/expectation_disabled.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[
{ "name": "disabled_member_expression",
"rc-command": [ "--references", "{0}/main.cpp:12:11"],
"expectation": ["{0}/main.cpp:2:10","{0}/main.cpp:5:9"] }
{
"name": "disabled_member_expression",
"rc-command": [
"--references",
"{0}/main.cpp:12:11"
],
"expectation": [
"{0}/main.cpp:2:10",
"{0}/main.cpp:5:9"
]
}
]
18 changes: 14 additions & 4 deletions tests/automated/ClassTemplatesMultipleTU/expectation.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[
{ "name": "multiple_template_parameters",
"rc-command": [ "--references", "{0}/a.hpp:4:8"],
"expectation": ["{0}/main.cpp:3:17","{0}/main.cpp:4:17","{0}/main.cpp:5:17",
"{0}/a.cpp:3:17", "{0}/a.cpp:4:17"] }
{
"name": "multiple_template_parameters",
"rc-command": [
"--references",
"{0}/a.hpp:4:8"
],
"expectation": [
"{0}/main.cpp:3:17",
"{0}/main.cpp:4:17",
"{0}/main.cpp:5:17",
"{0}/a.cpp:3:17",
"{0}/a.cpp:4:17"
]
}
]
57 changes: 33 additions & 24 deletions tests/automated/Completion/expectation.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
[
{ "name": "completion should show accessible items",

"rc-command": [ "--code-complete-at", "{0}/main.cpp:12:15",
"--synchronous-completions"],

"expectation": [ " get int get() CXXMethod Foo ",
" validate void validate(int) CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""] },

{ "name": "completion should not show not accessible/private items",

"rc-command": [ "--code-complete-at", "{0}/main.cpp:20:7",
"--synchronous-completions"],

"expectation": [ " get int get() CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""] }
{
"name": "completion should show accessible items",
"rc-command": [
"--code-complete-at",
"{0}/main.cpp:12:15",
"--synchronous-completions"
],
"expectation": [
" get int get() CXXMethod Foo ",
" validate void validate(int) CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""
]
},
{
"name": "completion should not show not accessible/private items",
"rc-command": [
"--code-complete-at",
"{0}/main.cpp:20:7",
"--synchronous-completions"
],
"expectation": [
" get int get() CXXMethod Foo ",
" Foo Foo:: ClassDecl Foo ",
" operator= Foo & operator=(const Foo &) CXXMethod Foo ",
" operator= Foo & operator=(Foo &&) CXXMethod Foo ",
" ~Foo void ~Foo() CXXDestructor Foo ",
""
]
}
]
41 changes: 32 additions & 9 deletions tests/automated/ForwardDeclaration/expectation.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
[
{ "name": "forward_declared_object_points_to_real_declaration",
"rc-command": [ "--follow-location", "{0}/contains_forward_declaration.hpp:3:16"],
"expectation": ["{0}/include.hpp:2:8"] },
{ "name": "forward_declared_object_points_to_real_declaration_through_macro",
"rc-command": [ "--follow-location", "{0}/main.cpp:10:15", "--all-targets"],
"expectation": ["{0}/include.hpp:2:8", "{0}/main.cpp:5:1"] },
{ "name": "reference_to_opaque_forward_declaration",
"rc-command": [ "--references", "{0}/main.cpp:13:8"],
"expectation": ["{0}/main.cpp:17:5"] }
{
"name": "forward_declared_object_points_to_real_declaration",
"rc-command": [
"--follow-location",
"{0}/contains_forward_declaration.hpp:3:16"
],
"expectation": [
"{0}/include.hpp:2:8"
]
},
{
"name": "forward_declared_object_points_to_real_declaration_through_macro",
"rc-command": [
"--follow-location",
"{0}/main.cpp:10:15",
"--all-targets"
],
"expectation": [
"{0}/include.hpp:2:8",
"{0}/main.cpp:5:1"
]
},
{
"name": "reference_to_opaque_forward_declaration",
"rc-command": [
"--references",
"{0}/main.cpp:13:8"
],
"expectation": [
"{0}/main.cpp:17:5"
]
}
]
13 changes: 10 additions & 3 deletions tests/automated/FunctionPointerField/expectation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[
{ "name": "classes/structs instance containing a pointer pointer field should not be a reference to the function pointer",
"rc-command": [ "--references", "{0}/main.cpp:3:12" ],
"expectation": [ "{0}/main.cpp:10:7" ] }
{
"name": "classes/structs instance containing a pointer pointer field should not be a reference to the function pointer",
"rc-command": [
"--references",
"{0}/main.cpp:3:12"
],
"expectation": [
"{0}/main.cpp:10:7"
]
}
]
13 changes: 10 additions & 3 deletions tests/automated/FunctionTemplates/expectation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[
{ "name": "find_references",
"rc-command": [ "--references", "{0}/main.cpp:2:6"],
"expectation": ["{0}/main.cpp:10:5"] }
{
"name": "find_references",
"rc-command": [
"--references",
"{0}/main.cpp:2:6"
],
"expectation": [
"{0}/main.cpp:10:5"
]
}
]
11 changes: 8 additions & 3 deletions tests/automated/InlineConstructorWrongTarget/expectation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[
{ "name": "inline constructor should not point to struct/class definition",
"rc-command": [ "--follow-location", "{0}/main.cpp:7:5" ],
"expectation": [] }
{
"name": "inline constructor should not point to struct/class definition",
"rc-command": [
"--follow-location",
"{0}/main.cpp:7:5"
],
"expectation": []
}
]
15 changes: 12 additions & 3 deletions tests/automated/MetaPrograms/expectation.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
[
{ "name": "find_references",
"rc-command": [ "--references", "{0}/main.cpp:2:8"],
"expectation": ["{0}/main.cpp:3:24","{0}/main.cpp:7:8","{0}/main.cpp:11:9"] }
{
"name": "find_references",
"rc-command": [
"--references",
"{0}/main.cpp:2:8"
],
"expectation": [
"{0}/main.cpp:3:24",
"{0}/main.cpp:7:8",
"{0}/main.cpp:11:9"
]
}
]
29 changes: 22 additions & 7 deletions tests/automated/MultipleTU/expectation.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
[
{ "name": "follow_location",
"rc-command": [ "--follow-location", "{0}/a.hpp:3:6"],
"expectation": ["{0}/a.cpp:3:6"] },
{ "name": "find_references",
"rc-command": [ "--references", "{0}/a.hpp:3:6"],
"expectation": ["{0}/a.cpp:6:5","{0}/main.cpp:4:5","{0}/main.cpp:5:5"] }

{
"name": "follow_location",
"rc-command": [
"--follow-location",
"{0}/a.hpp:3:6"
],
"expectation": [
"{0}/a.cpp:3:6"
]
},
{
"name": "find_references",
"rc-command": [
"--references",
"{0}/a.hpp:3:6"
],
"expectation": [
"{0}/a.cpp:6:5",
"{0}/main.cpp:4:5",
"{0}/main.cpp:5:5"
]
}
]
Loading

0 comments on commit 151815b

Please sign in to comment.