Skip to content

Commit 69a11d6

Browse files
authored
testrunner: aligned multiline template with new default (danmar#7534)
1 parent ff44a9e commit 69a11d6

File tree

7 files changed

+227
-227
lines changed

7 files changed

+227
-227
lines changed

test/fixture.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ void TestFixture::reportErr(const ErrorMessage &msg)
466466
void TestFixture::setTemplateFormat(const std::string &templateFormat)
467467
{
468468
if (templateFormat == "multiline") {
469-
mTemplateFormat = "{file}:{line}:{severity}:{message}";
470-
mTemplateLocation = "{file}:{line}:note:{info}";
469+
mTemplateFormat = "[{file}:{line}:{column}]: {severity}:{inconclusive:inconclusive:} {message} [{id}]";
470+
mTemplateLocation = "[{file}:{line}:{column}]: note: {info}";
471471
}
472472
else if (templateFormat == "simple") { // TODO: use the existing one in CmdLineParser
473473
mTemplateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]";

test/testbufferoverrun.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,9 +3505,9 @@ class TestBufferOverrun : public TestFixture {
35053505
" char *p = malloc(10);\n"
35063506
" memset(p, 0, 20);\n"
35073507
"}");
3508-
ASSERT_EQUALS("test.cpp:3:error:Buffer is accessed out of bounds: p\n"
3509-
"test.cpp:2:note:Assign p, buffer with size 10\n"
3510-
"test.cpp:3:note:Buffer overrun\n", errout_str());
3508+
ASSERT_EQUALS("[test.cpp:3:12]: error: Buffer is accessed out of bounds: p [bufferAccessOutOfBounds]\n"
3509+
"[test.cpp:2:13]: note: Assign p, buffer with size 10\n"
3510+
"[test.cpp:3:12]: note: Buffer overrun\n", errout_str());
35113511

35123512
settings0 = settingsOld;
35133513
}
@@ -3557,33 +3557,33 @@ class TestBufferOverrun : public TestFixture {
35573557
" char a[2];\n"
35583558
" f(a);\n"
35593559
"}");
3560-
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
3561-
"test.cpp:4:note:Function 'f' is called\n"
3562-
"test.cpp:1:note:Declaration of 1st function argument.\n"
3563-
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
3564-
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
3560+
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
3561+
"[test.cpp:4:5]: note: Function 'f' is called\n"
3562+
"[test.cpp:1:13]: note: Declaration of 1st function argument.\n"
3563+
"[test.cpp:3:10]: note: Passing buffer 'a' to function that is declared here\n"
3564+
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
35653565

35663566
check("void f(float a[10][3]);\n"
35673567
"void g() {\n"
35683568
" float a[2][3];\n"
35693569
" f(a);\n"
35703570
"}");
3571-
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
3572-
"test.cpp:4:note:Function 'f' is called\n"
3573-
"test.cpp:1:note:Declaration of 1st function argument.\n"
3574-
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
3575-
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
3571+
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
3572+
"[test.cpp:4:5]: note: Function 'f' is called\n"
3573+
"[test.cpp:1:14]: note: Declaration of 1st function argument.\n"
3574+
"[test.cpp:3:11]: note: Passing buffer 'a' to function that is declared here\n"
3575+
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
35763576

35773577
check("void f(int a[20]);\n"
35783578
"void g() {\n"
35793579
" int a[2];\n"
35803580
" f(a);\n"
35813581
"}");
3582-
ASSERT_EQUALS("test.cpp:4:warning:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
3583-
"test.cpp:4:note:Function 'f' is called\n"
3584-
"test.cpp:1:note:Declaration of 1st function argument.\n"
3585-
"test.cpp:3:note:Passing buffer 'a' to function that is declared here\n"
3586-
"test.cpp:4:note:Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
3582+
ASSERT_EQUALS("[test.cpp:4:5]: warning: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
3583+
"[test.cpp:4:5]: note: Function 'f' is called\n"
3584+
"[test.cpp:1:12]: note: Declaration of 1st function argument.\n"
3585+
"[test.cpp:3:9]: note: Passing buffer 'a' to function that is declared here\n"
3586+
"[test.cpp:4:5]: note: Buffer 'a' is too small, the function 'f' expects a bigger buffer in 1st argument\n", errout_str());
35873587

35883588
check("void f(int a[]) {\n"
35893589
" switch (2) {\n"
@@ -3613,11 +3613,11 @@ class TestBufferOverrun : public TestFixture {
36133613
" f(b);\n"
36143614
" return 0;\n"
36153615
"}\n");
3616-
ASSERT_EQUALS("test.cpp:8:warning:Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n"
3617-
"test.cpp:8:note:Function 'f' is called\n"
3618-
"test.cpp:1:note:Declaration of 1st function argument.\n"
3619-
"test.cpp:7:note:Passing buffer 'b' to function that is declared here\n"
3620-
"test.cpp:8:note:Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n",
3616+
ASSERT_EQUALS("[test.cpp:8:5]: warning: Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument [argumentSize]\n"
3617+
"[test.cpp:8:5]: note: Function 'f' is called\n"
3618+
"[test.cpp:1:12]: note: Declaration of 1st function argument.\n"
3619+
"[test.cpp:7:9]: note: Passing buffer 'b' to function that is declared here\n"
3620+
"[test.cpp:8:5]: note: Buffer 'b' is too small, the function 'f' expects a bigger buffer in 1st argument\n",
36213621
errout_str());
36223622
}
36233623

test/testclass.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8929,10 +8929,10 @@ class TestClass : public TestFixture {
89298929
" static C *mInstance;\n"
89308930
" void hello() {}\n"
89318931
"};");
8932-
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
8933-
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
8934-
"test.cpp:3:note:Delete 'mInstance', invalidating 'this'\n"
8935-
"test.cpp:3:note:Call method when 'this' is invalid\n",
8932+
ASSERT_EQUALS("[test.cpp:3:38]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
8933+
"[test.cpp:5:13]: note: Assuming 'mInstance' is used as 'this'\n"
8934+
"[test.cpp:3:20]: note: Delete 'mInstance', invalidating 'this'\n"
8935+
"[test.cpp:3:38]: note: Call method when 'this' is invalid\n",
89368936
errout_str());
89378937

89388938
checkThisUseAfterFree("class C {\n"
@@ -8942,10 +8942,10 @@ class TestClass : public TestFixture {
89428942
" static std::shared_ptr<C> mInstance;\n"
89438943
" void hello() {}\n"
89448944
"};");
8945-
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
8946-
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
8947-
"test.cpp:3:note:Delete 'mInstance', invalidating 'this'\n"
8948-
"test.cpp:3:note:Call method when 'this' is invalid\n",
8945+
ASSERT_EQUALS("[test.cpp:3:39]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
8946+
"[test.cpp:5:29]: note: Assuming 'mInstance' is used as 'this'\n"
8947+
"[test.cpp:3:20]: note: Delete 'mInstance', invalidating 'this'\n"
8948+
"[test.cpp:3:39]: note: Call method when 'this' is invalid\n",
89498949
errout_str());
89508950

89518951
checkThisUseAfterFree("class C {\n"
@@ -8956,10 +8956,10 @@ class TestClass : public TestFixture {
89568956
" void hello();\n"
89578957
" void reset() { mInstance.reset(); }\n"
89588958
"};");
8959-
ASSERT_EQUALS("test.cpp:3:warning:Calling method 'hello()' when 'this' might be invalid\n"
8960-
"test.cpp:5:note:Assuming 'mInstance' is used as 'this'\n"
8961-
"test.cpp:7:note:Delete 'mInstance', invalidating 'this'\n"
8962-
"test.cpp:3:note:Call method when 'this' is invalid\n",
8959+
ASSERT_EQUALS("[test.cpp:3:29]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
8960+
"[test.cpp:5:29]: note: Assuming 'mInstance' is used as 'this'\n"
8961+
"[test.cpp:7:18]: note: Delete 'mInstance', invalidating 'this'\n"
8962+
"[test.cpp:3:29]: note: Call method when 'this' is invalid\n",
89638963
errout_str());
89648964

89658965
// Use member..
@@ -8970,10 +8970,10 @@ class TestClass : public TestFixture {
89708970
" static C *self;\n"
89718971
" int x;\n"
89728972
"};");
8973-
ASSERT_EQUALS("test.cpp:3:warning:Using member 'x' when 'this' might be invalid\n"
8974-
"test.cpp:5:note:Assuming 'self' is used as 'this'\n"
8975-
"test.cpp:3:note:Delete 'self', invalidating 'this'\n"
8976-
"test.cpp:3:note:Call method when 'this' is invalid\n",
8973+
ASSERT_EQUALS("[test.cpp:3:33]: warning: Using member 'x' when 'this' might be invalid [thisUseAfterFree]\n"
8974+
"[test.cpp:5:13]: note: Assuming 'self' is used as 'this'\n"
8975+
"[test.cpp:3:20]: note: Delete 'self', invalidating 'this'\n"
8976+
"[test.cpp:3:33]: note: Call method when 'this' is invalid\n",
89778977
errout_str());
89788978

89798979
checkThisUseAfterFree("class C {\n"
@@ -8983,10 +8983,10 @@ class TestClass : public TestFixture {
89838983
" static C *self;\n"
89848984
" std::map<int,int> x;\n"
89858985
"};");
8986-
ASSERT_EQUALS("test.cpp:3:warning:Using member 'x' when 'this' might be invalid\n"
8987-
"test.cpp:5:note:Assuming 'self' is used as 'this'\n"
8988-
"test.cpp:3:note:Delete 'self', invalidating 'this'\n"
8989-
"test.cpp:3:note:Call method when 'this' is invalid\n",
8986+
ASSERT_EQUALS("[test.cpp:3:33]: warning: Using member 'x' when 'this' might be invalid [thisUseAfterFree]\n"
8987+
"[test.cpp:5:13]: note: Assuming 'self' is used as 'this'\n"
8988+
"[test.cpp:3:20]: note: Delete 'self', invalidating 'this'\n"
8989+
"[test.cpp:3:33]: note: Call method when 'this' is invalid\n",
89908990
errout_str());
89918991

89928992
// Assign 'shared_from_this()' to non-static smart pointer
@@ -8998,10 +8998,10 @@ class TestClass : public TestFixture {
89988998
" std::shared_ptr<C> mInstance;\n"
89998999
" void hello() {}\n"
90009000
"};");
9001-
ASSERT_EQUALS("test.cpp:4:warning:Calling method 'hello()' when 'this' might be invalid\n"
9002-
"test.cpp:6:note:Assuming 'mInstance' is used as 'this'\n"
9003-
"test.cpp:4:note:Delete 'mInstance', invalidating 'this'\n"
9004-
"test.cpp:4:note:Call method when 'this' is invalid\n",
9001+
ASSERT_EQUALS("[test.cpp:4:39]: warning: Calling method 'hello()' when 'this' might be invalid [thisUseAfterFree]\n"
9002+
"[test.cpp:6:22]: note: Assuming 'mInstance' is used as 'this'\n"
9003+
"[test.cpp:4:20]: note: Delete 'mInstance', invalidating 'this'\n"
9004+
"[test.cpp:4:39]: note: Call method when 'this' is invalid\n",
90059005
errout_str());
90069006

90079007
// Avoid FP..

test/testcondition.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -789,19 +789,19 @@ class TestCondition : public TestFixture {
789789
" if (x) {}\n"
790790
" else if (!x) {}\n"
791791
"}");
792-
ASSERT_EQUALS("test.cpp:3:style:Expression is always true because 'else if' condition is opposite to previous condition at line 2.\n"
793-
"test.cpp:2:note:first condition\n"
794-
"test.cpp:3:note:else if condition is opposite to first condition\n", errout_str());
792+
ASSERT_EQUALS("[test.cpp:3:14]: style: Expression is always true because 'else if' condition is opposite to previous condition at line 2. [multiCondition]\n"
793+
"[test.cpp:2:9]: note: first condition\n"
794+
"[test.cpp:3:14]: note: else if condition is opposite to first condition\n", errout_str());
795795

796796
check("void f(int x) {\n"
797797
" int y = x;\n"
798798
" if (x) {}\n"
799799
" else if (!y) {}\n"
800800
"}");
801-
ASSERT_EQUALS("test.cpp:4:style:Expression is always true because 'else if' condition is opposite to previous condition at line 3.\n"
802-
"test.cpp:2:note:'y' is assigned value 'x' here.\n"
803-
"test.cpp:3:note:first condition\n"
804-
"test.cpp:4:note:else if condition is opposite to first condition\n", errout_str());
801+
ASSERT_EQUALS("[test.cpp:4:14]: style: Expression is always true because 'else if' condition is opposite to previous condition at line 3. [multiCondition]\n"
802+
"[test.cpp:2:13]: note: 'y' is assigned value 'x' here.\n"
803+
"[test.cpp:3:9]: note: first condition\n"
804+
"[test.cpp:4:14]: note: else if condition is opposite to first condition\n", errout_str());
805805
}
806806

807807
void checkBadBitmaskCheck() {
@@ -6021,27 +6021,27 @@ class TestCondition : public TestFixture {
60216021
" if (x == y)\n"
60226022
" x = y;\n"
60236023
"}");
6024-
ASSERT_EQUALS("test.cpp:3:style:Assignment 'x=y' is redundant with condition 'x==y'.\n"
6025-
"test.cpp:2:note:Condition 'x==y'\n"
6026-
"test.cpp:3:note:Assignment 'x=y' is redundant\n", errout_str());
6024+
ASSERT_EQUALS("[test.cpp:3:11]: style: Assignment 'x=y' is redundant with condition 'x==y'. [duplicateConditionalAssign]\n"
6025+
"[test.cpp:2:11]: note: Condition 'x==y'\n"
6026+
"[test.cpp:3:11]: note: Assignment 'x=y' is redundant\n", errout_str());
60276027

60286028
check("void f(int& x, int y) {\n"
60296029
" if (x != y)\n"
60306030
" x = y;\n"
60316031
"}");
6032-
ASSERT_EQUALS("test.cpp:2:style:The statement 'if (x!=y) x=y' is logically equivalent to 'x=y'.\n"
6033-
"test.cpp:3:note:Assignment 'x=y'\n"
6034-
"test.cpp:2:note:Condition 'x!=y' is redundant\n", errout_str());
6032+
ASSERT_EQUALS("[test.cpp:2:11]: style: The statement 'if (x!=y) x=y' is logically equivalent to 'x=y'. [duplicateConditionalAssign]\n"
6033+
"[test.cpp:3:11]: note: Assignment 'x=y'\n"
6034+
"[test.cpp:2:11]: note: Condition 'x!=y' is redundant\n", errout_str());
60356035

60366036
check("void f(int& x, int y) {\n"
60376037
" if (x == y)\n"
60386038
" x = y;\n"
60396039
" else\n"
60406040
" x = 1;\n"
60416041
"}");
6042-
ASSERT_EQUALS("test.cpp:3:style:Assignment 'x=y' is redundant with condition 'x==y'.\n"
6043-
"test.cpp:2:note:Condition 'x==y'\n"
6044-
"test.cpp:3:note:Assignment 'x=y' is redundant\n", errout_str());
6042+
ASSERT_EQUALS("[test.cpp:3:11]: style: Assignment 'x=y' is redundant with condition 'x==y'. [duplicateConditionalAssign]\n"
6043+
"[test.cpp:2:11]: note: Condition 'x==y'\n"
6044+
"[test.cpp:3:11]: note: Assignment 'x=y' is redundant\n", errout_str());
60456045

60466046
check("void f(int& x, int y) {\n"
60476047
" if (x != y)\n"
@@ -6091,18 +6091,18 @@ class TestCondition : public TestFixture {
60916091
" }\n"
60926092
" bool b;\n"
60936093
"};\n");
6094-
ASSERT_EQUALS("test.cpp:4:style:The statement 'if (b) b=true' is redundant.\n"
6095-
"test.cpp:4:note:Assignment 'b=true'\n"
6096-
"test.cpp:4:note:Condition 'b' is redundant\n"
6097-
"test.cpp:5:style:The statement 'if (b) b=false' is logically equivalent to 'b=false'.\n"
6098-
"test.cpp:5:note:Assignment 'b=false'\n"
6099-
"test.cpp:5:note:Condition 'b' is redundant\n"
6100-
"test.cpp:6:style:The statement 'if (!b) b=true' is logically equivalent to 'b=true'.\n"
6101-
"test.cpp:6:note:Assignment 'b=true'\n"
6102-
"test.cpp:6:note:Condition '!b' is redundant\n"
6103-
"test.cpp:7:style:The statement 'if (!b) b=false' is redundant.\n"
6104-
"test.cpp:7:note:Assignment 'b=false'\n"
6105-
"test.cpp:7:note:Condition '!b' is redundant\n",
6094+
ASSERT_EQUALS("[test.cpp:4:13]: style: The statement 'if (b) b=true' is redundant. [duplicateConditionalAssign]\n"
6095+
"[test.cpp:4:18]: note: Assignment 'b=true'\n"
6096+
"[test.cpp:4:13]: note: Condition 'b' is redundant\n"
6097+
"[test.cpp:5:13]: style: The statement 'if (b) b=false' is logically equivalent to 'b=false'. [duplicateConditionalAssign]\n"
6098+
"[test.cpp:5:18]: note: Assignment 'b=false'\n"
6099+
"[test.cpp:5:13]: note: Condition 'b' is redundant\n"
6100+
"[test.cpp:6:13]: style: The statement 'if (!b) b=true' is logically equivalent to 'b=true'. [duplicateConditionalAssign]\n"
6101+
"[test.cpp:6:19]: note: Assignment 'b=true'\n"
6102+
"[test.cpp:6:13]: note: Condition '!b' is redundant\n"
6103+
"[test.cpp:7:13]: style: The statement 'if (!b) b=false' is redundant. [duplicateConditionalAssign]\n"
6104+
"[test.cpp:7:19]: note: Assignment 'b=false'\n"
6105+
"[test.cpp:7:13]: note: Condition '!b' is redundant\n",
61066106
errout_str());
61076107
}
61086108

0 commit comments

Comments
 (0)