[PATCH] D62951: [analyzer][tests] Use normalize_plist in place of diff_plist (`tail` cases)

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 07:16:40 PDT 2019


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty.
Herald added subscribers: jsji, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.
hubert.reinterpretcast added parent revisions: D62949: [analyzer][tests] Add normalize_plist to replace diff_plist, D62950: [analyzer][tests] Use normalize_plist in place of diff_plist (`cat` cases).

The `%diff_plist` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests.

This patch applies the change described in http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html mechanically to the cases where the output file is piped to `%diff_plist` via `tail`. `%diff_plist` is then, being unused, removed.

The changes were applied via a script.

Note that `grep` expects text files (ending with a newline) as input. The `echo` command is used to generate a newline for the test output files, which do not have such newlines.


Repository:
  rC Clang

https://reviews.llvm.org/D62951

Files:
  test/Analysis/MismatchedDeallocator-path-notes.cpp
  test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
  test/Analysis/diagnostics/plist-multi-file.c
  test/Analysis/lambda-notes.cpp
  test/Analysis/lit.local.cfg
  test/Analysis/malloc-plist.c


Index: test/Analysis/malloc-plist.c
===================================================================
--- test/Analysis/malloc-plist.c
+++ test/Analysis/malloc-plist.c
@@ -1,6 +1,6 @@
 // RUN: rm -f %t
 // RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,unix.Malloc -analyzer-output=plist -verify -o %t -analyzer-config eagerly-assume=false %s
-// RUN: tail -n +11 %t | %diff_plist %S/Inputs/expected-plists/malloc-plist.c.plist -
+// RUN: %normalize_plist <%S/Inputs/expected-plists/malloc-plist.c.plist >%t.expected.sed && echo >>%t && tail -n +11 %t | %normalize_plist | diff -u %t.expected.sed -
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
Index: test/Analysis/lit.local.cfg
===================================================================
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -9,11 +9,6 @@
 config.test_format = analyzer_test.AnalyzerTest(
         config.test_format.execute_external, config.use_z3_solver)
 
-# Diff command used by Clang Analyzer tests (when comparing .plist files
-# with reference output)
-config.substitutions.append(('%diff_plist',
-    'diff -u -w -I "<string>/" -I "<string>.:" -I "version"'))
-
 # Diff command for testing SARIF output to reference output.
 config.substitutions.append(('%diff_sarif',
     '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I "2\.0\.0\-csd\.[0-9]*\.beta\."'''))
Index: test/Analysis/lambda-notes.cpp
===================================================================
--- test/Analysis/lambda-notes.cpp
+++ test/Analysis/lambda-notes.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core.DivideZero -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t
-// RUN: tail -n +11 %t | %diff_plist %S/Inputs/expected-plists/lambda-notes.cpp.plist -
+// RUN: %normalize_plist <%S/Inputs/expected-plists/lambda-notes.cpp.plist >%t.expected.sed && echo >>%t && tail -n +11 %t | %normalize_plist | diff -u %t.expected.sed -
 
 
 // Diagnostic inside a lambda
Index: test/Analysis/diagnostics/plist-multi-file.c
===================================================================
--- test/Analysis/diagnostics/plist-multi-file.c
+++ test/Analysis/diagnostics/plist-multi-file.c
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -o %t.plist -verify %s
-// RUN: tail -n +11 %t.plist | %diff_plist %S/Inputs/expected-plists/plist-multi-file.c.plist -
+// RUN: %normalize_plist <%S/Inputs/expected-plists/plist-multi-file.c.plist >%t.expected.sed.plist && echo >>%t.plist && tail -n +11 %t.plist | %normalize_plist | diff -u %t.expected.sed.plist -
 
 #include "plist-multi-file.h"
 
Index: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
===================================================================
--- test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
+++ test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file %s -o %t.plist
-// RUN: tail -n +11 %t.plist | %diff_plist %S/Inputs/expected-plists/plist-diagnostics-include-check.cpp.plist -
+// RUN: %normalize_plist <%S/Inputs/expected-plists/plist-diagnostics-include-check.cpp.plist >%t.expected.sed.plist && echo >>%t.plist && tail -n +11 %t.plist | %normalize_plist | diff -u %t.expected.sed.plist -
 
 #include "Inputs/include/plist-diagnostics-include-check-macro.h"
 
Index: test/Analysis/MismatchedDeallocator-path-notes.cpp
===================================================================
--- test/Analysis/MismatchedDeallocator-path-notes.cpp
+++ test/Analysis/MismatchedDeallocator-path-notes.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist %s -o %t.plist
-// RUN: tail -n +11 %t.plist | %diff_plist %S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist -
+// RUN: %normalize_plist <%S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist >%t.expected.sed.plist && echo >>%t.plist && tail -n +11 %t.plist | %normalize_plist | diff -u %t.expected.sed.plist -
 
 void changePointee(int *p);
 int *allocIntArray(unsigned c) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62951.203349.patch
Type: text/x-patch
Size: 4399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190606/3a931852/attachment.bin>


More information about the cfe-commits mailing list