diff options
author | bloodstalker <thabogre@gmail.com> | 2020-07-14 15:30:12 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2020-07-14 15:30:12 +0000 |
commit | 835b5ba3d6594a60963af89b0487f89afe6e19f1 (patch) | |
tree | 733fbda827f60ae4d35128605fbef3679f33b05e | |
parent | added a new switch:recorddecl. the test script is still WIP. (diff) | |
download | cgrep-835b5ba3d6594a60963af89b0487f89afe6e19f1.tar.gz cgrep-835b5ba3d6594a60963af89b0487f89afe6e19f1.zip |
wip-tests
-rw-r--r-- | test/declrefexpr.cpp | 8 | ||||
-rw-r--r-- | test/fielddecl.cpp | 6 | ||||
-rw-r--r-- | test/function.cpp | 6 | ||||
-rw-r--r-- | test/test_list.md | 32 | ||||
-rw-r--r-- | test/vardecl.cpp | 8 | ||||
-rwxr-xr-x | testscript/main.py | 43 |
6 files changed, 58 insertions, 45 deletions
diff --git a/test/declrefexpr.cpp b/test/declrefexpr.cpp index c184577..b2a617d 100644 --- a/test/declrefexpr.cpp +++ b/test/declrefexpr.cpp @@ -4,7 +4,7 @@ namespace declrefexpr_ns{ class testClass { public: testClass() = default; - int a; + int testa; private: }; @@ -12,9 +12,9 @@ private: int __attribute__((weak)) main(int argc, char *argv[]) { int a; - int b; + int testb; declrefexpr_ns::testClass tc; - tc.a = 10; + tc.testa = 10; - return a + b; + return a + testb; } diff --git a/test/fielddecl.cpp b/test/fielddecl.cpp index 6646afd..82f5d1f 100644 --- a/test/fielddecl.cpp +++ b/test/fielddecl.cpp @@ -4,12 +4,12 @@ namespace fielddecl_ns{ struct testStruct { int fieldone; - float fieldtwo; + float testfieldtwo; int fieldmacro; }; union testUnion { - int fieldone; + int testfieldone; bool fieldtwo; }; @@ -18,7 +18,7 @@ public: testClass(void); virtual ~testClass(); - void myMethod(void); + void testMethod(void); private: int an_arg; diff --git a/test/function.cpp b/test/function.cpp index 83878e7..bb0f228 100644 --- a/test/function.cpp +++ b/test/function.cpp @@ -1,6 +1,6 @@ namespace function_ns{ -void MyFunc(void) { return; } +void testMyFunc(void) { return; } class yolo { public: @@ -8,7 +8,7 @@ public: yolo(int a) : a(a) {} virtual ~yolo(); - void yolofunc(void) { return; } + void testyolofunc(void) { return; } private: int a; @@ -16,5 +16,5 @@ private: #define MFunc macroedFunc -void MFunc(void) { return; } +void testFunc(void) { return; } } // namespace diff --git a/test/test_list.md b/test/test_list.md index e39ea5e..39b2f02 100644 --- a/test/test_list.md +++ b/test/test_list.md @@ -1,22 +1,22 @@ ## Test List -- [x] function declaration -- [x] field declratation -- [x] cxx method declaration -- [x] variable declaration -- [x] class declaration -- [x] struct declaration -- [x] union declaration/definition -- [x] named declaration/definition -- [x] declaration reference expression -- [x] call expression -- [x] cxx member call expression -- [x] cxx record declaration -- [] macro definition -- [] header inclusion directive +- [x] function declaration +- [x] field declratation +- [x] cxx method declaration +- [x] variable declaration +- [x] class declaration +- [x] struct declaration +- [x] union declaration/definition +- [x] named declaration/definition +- [x] declaration reference expression +- [x] call expression +- [x] cxx member call expression +- [x] cxx record declaration +- [] macro definition +- [] header inclusion directive ## Cross Test List -* macro expansion behaviour -* overload +- macro expansion behaviour +- overload diff --git a/test/vardecl.cpp b/test/vardecl.cpp index 3f17a21..8bce877 100644 --- a/test/vardecl.cpp +++ b/test/vardecl.cpp @@ -1,21 +1,21 @@ namespace vardecl_ns{ -int a; +int gtesta; int testFunction(int a, int b); int testFunction(int a, int b) { return a + b; } class testClass { public: - testClass(int a) : a(a) {} + testClass(int a) : testa(a) {} virtual ~testClass(); void cxxMethod(double a) {} private: - int a; + int testa; }; #define vardeclmacro varDeclMacroExpanded -int vardeclmacro; +int testvardeclmacro; }; // namespace diff --git a/testscript/main.py b/testscript/main.py index 285f993..90b7737 100755 --- a/testscript/main.py +++ b/testscript/main.py @@ -9,6 +9,20 @@ import re test_files = ["/home/bloodstalker/extra/cgrep/cgrep.cpp"] +test_files_2 = [ + "./test/function.cpp", + "./test/fielddecl.cpp", + "./test/cxxmethoddecl.cpp", + "./test/vardecl.cpp", + "./test/classdecl.cpp", + "./test/structdecl.cpp", + "./test/uniondecdef.cpp", + "./test/nameddecldef.cpp", + "./test/declrefexpr.cpp", + "./test/callexpr.cpp", + "./test/cxxmembercallexpr.cpp", + ] + cgrep_test_args = [ "-A 1 -B 1 --func --var --regex n[aA]m", "-A 1 -B 1 --func --var --awk --regex n[aA]m", @@ -25,18 +39,17 @@ cgrep_test_args = [ "--dir ./ --regex run --func",] cgrep_test_args_2 = [ - "--regex test --func", - "--regex test --fielddecl", - "--regex test --memfunc", - "--regex test --var", - "--regex test --class", - "--regex test --struct", - "--regex test --union", - "--regex test --nameddecl", - "--regex test --declrefexpr", - "--regex test --call", - "--regex test --cxxcall", - "--regex test --", + "--func --regex test", + "--cxxfield --regex test", + "--memfunc --regex test", + "--var --regex test", + "--class --regex test", + "--struct --regex test", + "--union --regex test", + "--nameddecl --regex test", + "--declrefexpr --regex test", + "--call --regex test", + "--cxxcall --regex test", ] class Argparser(object): @@ -81,11 +94,11 @@ def main(): llvm_version = re.findall("[0-9]*\.[0-9]*\.[0-9]*", call_from_shell_list(["llvm-config", "--version"]).stdout.decode("utf-8")) # buld the magic sause. we dont wanna get stddef.h not found. clang_builtin_headers = "--extra-arg=-I" + llvm_libdir.stdout.decode("utf-8")[:-1] + "/clang/" + llvm_version[0] + "/include" - for cgrep_test_arg in cgrep_test_args: + for cgrep_test_arg, cgrep_test_files in zip(cgrep_test_args_2, test_files_2): arg_list = cgrep_test_arg.split() arg_list.insert(0, cgrep_exe) - arg_list.append(clang_builtin_headers) - arg_list.append(test_files[0]) + arg_list.insert(1, clang_builtin_headers) + arg_list.append(cgrep_test_files) print(arg_list) ret = call_from_shell_list(arg_list) print("ret:", ret.stdout.decode("utf-8"), end="") |