[v2] Fix stray comma in leaf-changes-only mode.

Message ID 20200205111713.199559-1-gprocida@google.com
State Committed
Headers
Series [v2] Fix stray comma in leaf-changes-only mode. |

Commit Message

Aleksei Vetrov via Libabigail Jan. 1, 2020, midnight UTC
  This change replaces the "\n," sometimes seen in output (such as for
the PR25128 test cases) with a correctly indented "and".

	* src/abg-reporter-priv.cc (represent): Don't try to follow
        output of indented pretty representation with a comma, just
        emit "and" unconditionally; remove unnecessary intermediate
        ostringstream.
	* tests/data/Makefile.am: Add new test case files.
	* tests/data/test-abidiff-exit/test-no-stray-comma-*: New test
        cases.
        * tests/data/test-diff-suppr/test46-PR25128-report-?.txt:
        Replace unindented comma with indented "and".
	* tests/test-abidiff-exit.cc: Add no-stray-comma test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Matthias Maennich <maennich@google.com>
---
 src/abg-reporter-priv.cc                       |  17 ++++++-----------
 tests/data/Makefile.am                         |   3 +++
 .../test-no-stray-comma-report.txt             |  14 ++++++++++++++
 .../test-abidiff-exit/test-no-stray-comma-v0.o | Bin 0 -> 2784 bytes
 .../test-abidiff-exit/test-no-stray-comma-v1.o | Bin 0 -> 2784 bytes
 .../test46-PR25128-report-1.txt                |   2 +-
 .../test46-PR25128-report-2.txt                |   2 +-
 tests/test-abidiff-exit.cc                     |   9 +++++++++
 8 files changed, 34 insertions(+), 13 deletions(-)
 create mode 100644 tests/data/test-abidiff-exit/test-no-stray-comma-report.txt
 create mode 100644 tests/data/test-abidiff-exit/test-no-stray-comma-v0.o
 create mode 100644 tests/data/test-abidiff-exit/test-no-stray-comma-v1.o
  

Comments

Dodji Seketeli Jan. 1, 2020, midnight UTC | #1
Giuliano Procida <gprocida@google.com> a ?crit:

> This change replaces the "\n," sometimes seen in output (such as for
> the PR25128 test cases) with a correctly indented "and".
>
> 	* src/abg-reporter-priv.cc (represent): Don't try to follow
>         output of indented pretty representation with a comma, just
>         emit "and" unconditionally; remove unnecessary intermediate
>         ostringstream.
> 	* tests/data/Makefile.am: Add new test case files.
> 	* tests/data/test-abidiff-exit/test-no-stray-comma-*: New test
>         cases.
>         * tests/data/test-diff-suppr/test46-PR25128-report-?.txt:
>         Replace unindented comma with indented "and".
> 	* tests/test-abidiff-exit.cc: Add no-stray-comma test case.

I have applied this to master.

Thanks a lot!

Cheers,
  

Patch

diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc
index f9e08c91..fff7b55b 100644
--- a/src/abg-reporter-priv.cc
+++ b/src/abg-reporter-priv.cc
@@ -486,30 +486,25 @@  represent(const var_diff_sptr	&diff,
     {
       if (local_only && d->has_local_changes())
 	{
-	  std::ostringstream out_buffer;
-	    out_buffer
-	      << indent << "type '" << get_pretty_representation(o->get_type())
+	  out << indent << "type '" << get_pretty_representation(o->get_type())
 	      << "' of '" << o->get_qualified_name()
 	      << "' changed";
 
 	  if (d->currently_reporting())
 	    {
-	      out_buffer << " as being reported\n";
-	      begin_with_and = true;
+	      out << " as being reported\n";
 	    }
 	  else if (d->reported_once())
 	    {
-	      out_buffer << " as reported earlier\n";
-	      begin_with_and = true;
+	      out << " as reported earlier\n";
 	    }
 	  else
 	    {
-	      out_buffer << ":\n";
-	      d->report(out_buffer, indent + "  ");
-	      begin_with_and = false;
+	      out << ":\n";
+	      d->report(out, indent + "  ");
 	    }
 
-	  out << out_buffer.str();
+	  begin_with_and = true;
 	  emitted = true;
 	}
       else
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 1f574d2e..a38fadfd 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -107,6 +107,9 @@  test-abidiff-exit/test-loc-v0.bi \
 test-abidiff-exit/test-loc-v1.bi \
 test-abidiff-exit/test-loc-with-locs-report.txt \
 test-abidiff-exit/test-loc-without-locs-report.txt \
+test-abidiff-exit/test-no-stray-comma-report.txt \
+test-abidiff-exit/test-no-stray-comma-v0.o \
+test-abidiff-exit/test-no-stray-comma-v1.o \
 \
 test-diff-dwarf/test0-v0.cc		\
 test-diff-dwarf/test0-v0.o			\
diff --git a/tests/data/test-abidiff-exit/test-no-stray-comma-report.txt b/tests/data/test-abidiff-exit/test-no-stray-comma-report.txt
new file mode 100644
index 00000000..a66500d5
--- /dev/null
+++ b/tests/data/test-abidiff-exit/test-no-stray-comma-report.txt
@@ -0,0 +1,14 @@ 
+Leaf changes summary: 1 artifact changed
+Changed leaf types summary: 1 leaf type changed
+Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
+Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
+
+'struct foo at test-b146198490-v0.cc:1:1' changed:
+  type size changed from 32 to 64 (in bits)
+  there are data member changes:
+   type 'int[1]' of 'foo::bar' changed:
+     type name changed from 'int[1]' to 'int[2]'
+     array type size changed from 32 to 64
+     array type subrange 1 changed length from 1 to 2
+   and size changed from 32 to 64 (in bits) (by +32 bits)
+
diff --git a/tests/data/test-abidiff-exit/test-no-stray-comma-v0.o b/tests/data/test-abidiff-exit/test-no-stray-comma-v0.o
new file mode 100644
index 0000000000000000000000000000000000000000..1d40e893d4727497e66062e2b2f66b9c291742e3
GIT binary patch
literal 2784
zcmbtV&1(}u6n~RVnzY-7w6U5}g%$j$Xx5gNk}B0`{b;d@2n7+O?k3wb+H54*YE{I8
zB8ry^f{5Zl{|WD2{1f~KJbLgZc+mG|-=v#yMbLqr_ulV)&di&g2d5X$B!mDp1RR4c
zNudB%&lX>nY#H(}1WWTzzsx_q|9$i7$F~S4r79yMguDd8$&B!cm1Yx?LS*I<G+d_z
zBGG?d8YGKIQdOL;;@3kHKsu8ql1ZlOegM6$a~DJ^QWJoRF5bLG!#>gv6PI|t3Z_g0
zVo>bO=1n6znjI8F>D&&~=7o_l%_HVfbH)^TtYrX<OeikoOBgh{4;Bzl39*nTgPz?e
zA4Wxb518gLjD}?~n*r#x#qkjp!Iyc;g_kEs$h9vOiJd55%{dG~(cutPiXX<3vzpYZ
zl&mOiTS9sX@gq9`0tZ6)2?)G)P;@7zrYB}fQ#0emTjO@6A{|o&=nb==xIHBvCJgjk
zYx*^7-EY@xzE`zqf8!&Zy|84>9XvQOWtHqnd)z8Ef_2}Ut$DuJs#j2ST9wt=jnZ^+
zdde!+;Be5m3CmX|@vttPo1_DWvvYGttg%y`TX+00N^$x?$jAa=TS!3My#!(-Cr10z
znN3{PPQ>Y>A@}4&HupF&H_&qi4MI3}rcFu0x1VuJTzec02A_nkG*A;a3~qZ}XFykj
zcGL#QUhc?>F`!qmUDW9Gb{CA*40Ho58GtPrGYshe4aF;fw|HwGI{g;k0^O&HzG{Vi
z5uTE$OoY>_#t6hQ7!pwU5X-|FewpPFrc`04bCEy5IK_#c|FsAn-OaX!hkq4-+l=e+
zqw7ks4Uya*?2rBdw-~3|qxFN`zS9UC7irK6>8j!aZzBM^>I4qhZo3V3%Ug5os^_lP
zmh1jX6LpezT({-j>QXx`$FF(aE^Bq)Q!bbS>`JrI@bH$~elzfFyw$~a;8bpKAa8Yf
zrR6j{F8n{qDEiahs{K^q%FJ~7jpeOQ41wK92-9!gIkwk{?!O-ms6YPIe*%5=n3PlH
ze@8-O=(hA<r-!f{u_3n1uj6ONsjmo9y^N289J4s<F-h@NY60kliw@oPA}V!^?4K|=
z9(9hfrFF*DU*Joj{HcEWtLgPuV`3r%A2|Oa36Y`Kx{SKG{PUb&?Gxpv`>yA|i5SIH
zbs{TAk}u<R1u#|l6}^XeoWIZhyZ++;i2XG)c*g!ZuJS7U75nSvn+%kcAyc(}1;0Qh
zZvU>u>>s@v%3tj()uZR8*q<1@$OY4Xon9l|pUy<Tdk8^+io&rcB%N7bKgEsn-{AV+
KcRWKz_x}YqTCbV_

literal 0
HcmV?d00001

diff --git a/tests/data/test-abidiff-exit/test-no-stray-comma-v1.o b/tests/data/test-abidiff-exit/test-no-stray-comma-v1.o
new file mode 100644
index 0000000000000000000000000000000000000000..a2550b4a08d8b08ce56c300a3cb2ef2a64edb4b4
GIT binary patch
literal 2784
zcmbtVPiqrF6n~RVnr*iYX=62|3M=>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>Z+eK8W7}-A)
z;BeSE!j{$<Rex4o3h7Vv(_c-kzZ?-0A^0frFVG}JYOO1%i^@MI^2>dq{B+;d{2Pc-
zOj#$2oZ{j#-j;yiGQZ>x5RdZrg#VGh_&*W;iWxi?{wgl>O8m9(SIu_?P>_a#%k@k6
zB??jdcPnE5=+%(^a$l()H8;inEWkxkF#Xr*HB$ZQOw_xF5M-$+q+<bVjq3U-Zj}GF
MsQ*LDGZ0k&-!dn!yZ`_I

literal 0
HcmV?d00001

diff --git a/tests/data/test-diff-suppr/test46-PR25128-report-1.txt b/tests/data/test-diff-suppr/test46-PR25128-report-1.txt
index b08460d4..9a974032 100644
--- a/tests/data/test-diff-suppr/test46-PR25128-report-1.txt
+++ b/tests/data/test-diff-suppr/test46-PR25128-report-1.txt
@@ -13,6 +13,6 @@  Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
    type 'unsigned long int' of 'root_domain::max_cpu_capacity' changed:
      entity changed from 'unsigned long int' to 'struct max_cpu_capacity' at sched.h:722:1
      type size changed from 64 to 192 (in bits)
-, size changed from 64 to 192 (in bits) (by +128 bits)
+   and size changed from 64 to 192 (in bits) (by +128 bits)
    'perf_domain* root_domain::pd' offset changed from 14528 to 14656 (in bits) (by +128 bits)
 
diff --git a/tests/data/test-diff-suppr/test46-PR25128-report-2.txt b/tests/data/test-diff-suppr/test46-PR25128-report-2.txt
index 558530e1..d6873cb0 100644
--- a/tests/data/test-diff-suppr/test46-PR25128-report-2.txt
+++ b/tests/data/test-diff-suppr/test46-PR25128-report-2.txt
@@ -9,6 +9,6 @@  Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
    type 'unsigned long int' of 'root_domain::max_cpu_capacity' changed:
      entity changed from 'unsigned long int' to 'struct max_cpu_capacity' at sched.h:722:1
      type size changed from 64 to 192 (in bits)
-, size changed from 64 to 192 (in bits) (by +128 bits)
+   and size changed from 64 to 192 (in bits) (by +128 bits)
    'perf_domain* root_domain::pd' offset changed from 14528 to 14656 (in bits) (by +128 bits)
 
diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc
index 4cef727e..88875b34 100644
--- a/tests/test-abidiff-exit.cc
+++ b/tests/test-abidiff-exit.cc
@@ -111,6 +111,15 @@  InOutSpec in_out_specs[] =
     "data/test-abidiff-exit/test-loc-without-locs-report.txt",
     "output/test-abidiff-exit/test-loc-without-locs-report.txt"
   },
+  {
+    "data/test-abidiff-exit/test-no-stray-comma-v0.o",
+    "data/test-abidiff-exit/test-no-stray-comma-v1.o",
+    "",
+    "--leaf-changes-only",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/test-no-stray-comma-report.txt",
+    "output/test-abidiff-exit/test-no-stray-comma-report.txt"
+  },
   {0, 0, 0 ,0,  abigail::tools_utils::ABIDIFF_OK, 0, 0}
 };