llvm.org GIT mirror llvm / d4b0ab0
[llvm-cov] Add an option for "export" command to emit only file summary data. Summary: That allows to get the same data as produced by "llvm-cov report", but in JSON format, which is better for further processing by end users. Reviewers: vsk Reviewed By: vsk Differential Revision: https://reviews.llvm.org/D41085 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320435 91177308-0d34-0410-b5e6-96231b3b80d8 Max Moroz 1 year, 9 months ago
5 changed file(s) with 70 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
381381 It is an error to specify an architecture that is not included in the
382382 universal binary or to use an architecture that does not match a
383383 non-universal binary.
384
385 .. option:: -summary-only
386
387 Export only summary information for each file in the coverage data. This mode
388 will not export coverage information for smaller units such as individual
389 functions or regions. The result will be the same as produced by :program:
390 `llvm-cov report` command, but presented in JSON format rather than text.
3838 // RUN: FileCheck -input-file %t.export.json %S/Inputs/lineExecutionCounts.json
3939 // RUN: cat %t.export.json | %python -c "import json, sys; json.loads(sys.stdin.read())"
4040 //
41 // RUN: llvm-cov export %S/Inputs/lineExecutionCounts.covmapping -instr-profile %t.profdata 2>/dev/null -summary-only > %t.export-summary.json
42 // RUN: not grep '"name":"main"' %t.export-summary.json
43 //
4144 // Test html output.
4245 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S %s
4346 // RUN: llvm-cov show %S/Inputs/lineExecutionCounts.covmapping -format html -o %t.html.filtered.dir -instr-profile %t.profdata -path-equivalence=/tmp,%S -name=main %s
4447 // RUN: FileCheck -check-prefixes=HTML,HTML-WHOLE-FILE -input-file %t.html.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4548 // RUN: FileCheck -check-prefixes=HTML,HTML-FILTER -input-file %t.html.filtered.dir/coverage/tmp/showLineExecutionCounts.cpp.html %s
4649 //
47 // HTML-WHOLE-FILE:
[[@LINE-44]]
// before

                  
                
48 // HTML-FILTER-NOT:
[[@LINE-45]]
// before

                  
                
49 // HTML:
[[@LINE-44]]
161
int main() {

                  
                
50 // HTML:
[[@LINE-44]]
161
  int x = 0

                  
                
51 // HTML:
[[@LINE-44]]
161

                  
                
52 // HTML:
[[@LINE-44]]
161
  if (x)

                  
                
53 // HTML:
[[@LINE-44]]
0

                  
                
54 // HTML:
[[@LINE-44]]
161
  }

                  
                
55 // HTML:
[[@LINE-44]]
161
    x = 1;

                  
                
56 // HTML:
[[@LINE-44]]
161
  }

                  
                
57 // HTML:
[[@LINE-44]]
161

                  
                
58 // HTML:
[[@LINE-44]]
16.2k
  for (int i = 0; i < 100; ++i)

                  
                
59 // HTML:
[[@LINE-44]]
16.1k
    x = 1;

                  
                
60 // HTML:
[[@LINE-44]]
16.1k
  }

                  
                
61 // HTML:
[[@LINE-44]]
161

                  
                
62 // HTML:
[[@LINE-44]]
161
  x = x < 10

                  
                
63 // HTML:
[[@LINE-44]]
161
  x = x > 10

                  
                
64 // HTML:
[[@LINE-44]]
0
 x - 1:

                  
                
65 // HTML:
[[@LINE-44]]
161
        x + 1;

                  
                
66 // HTML:
[[@LINE-44]]
161

                  
                
67 // HTML:
[[@LINE-44]]
161
  return 0;

                  
                
68 // HTML:
[[@LINE-44]]
161
}

                  
                
69 // HTML-WHOLE-FILE:
[[@LINE-44]]
// after

                  
                
70 // HTML-FILTER-NOT:
[[@LINE-45]]
// after
                  
                
50 // HTML-WHOLE-FILE:
[[@LINE-47]]
// before
                  
                
51 // HTML-FILTER-NOT:
[[@LINE-48]]
// before

                  
                
52 // HTML:
[[@LINE-47]]
161
int main() {

                  
                
53 // HTML:
[[@LINE-47]]
161
  int x = 0

                  
                
54 // HTML:
[[@LINE-47]]
161

                  
                
55 // HTML:
[[@LINE-47]]
161
  if (x)

                  
                
56 // HTML:
[[@LINE-47]]
0

                  
                
57 // HTML:
[[@LINE-47]]
161
  }

                  
                
58 // HTML:
[[@LINE-47]]
161
    x = 1;

                  
                
59 // HTML:
[[@LINE-47]]
161
  }

                  
                
60 // HTML:
[[@LINE-47]]
161

                  
                
61 // HTML:
[[@LINE-47]]
16.2k
  for (int i = 0; i < 100; ++i)

                  
                
62 // HTML:
[[@LINE-47]]
16.1k
    x = 1;

                  
                
63 // HTML:
[[@LINE-47]]
16.1k
  }

                  
                
64 // HTML:
[[@LINE-47]]
161

                  
                
65 // HTML:
[[@LINE-47]]
161
  x = x < 10

                  
                
66 // HTML:
[[@LINE-47]]
161
  x = x > 10

                  
                
67 // HTML:
[[@LINE-47]]
0
 x - 1:

                  
                
68 // HTML:
[[@LINE-47]]
161
        x + 1;

                  
                
69 // HTML:
[[@LINE-47]]
161

                  
                
70 // HTML:
[[@LINE-47]]
161
  return 0;

                  
                
71 // HTML:
[[@LINE-47]]
161
}

                  
                
72 // HTML-WHOLE-FILE:
[[@LINE-47]]
// after

                  
                
73 // HTML-FILTER-NOT:
[[@LINE-48]]
// after

                  
                
7174 //
7275 // Test index creation.
7376 // RUN: FileCheck -check-prefix=TEXT-INDEX -input-file %t.dir/index.txt %s
630630 "show-instantiation-summary", cl::Optional,
631631 cl::desc("Show instantiation statistics in summary table"));
632632
633 cl::opt SummaryOnly(
634 "summary-only", cl::Optional,
635 cl::desc("Export only summary information for each source file"));
636
633637 auto commandLineParser = [&, this](int argc, const char **argv) -> int {
634638 cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n");
635639 ViewOpts.Debug = DebugDump;
742746
743747 ViewOpts.ShowRegionSummary = RegionSummary;
744748 ViewOpts.ShowInstantiationSummary = InstantiationSummary;
749 ViewOpts.ExportSummaryOnly = SummaryOnly;
745750
746751 return 0;
747752 };
176176 SourceFiles, Options);
177177 renderFiles(SourceFiles, FileReports);
178178
179 emitDictKey("functions");
180 renderFunctions(Coverage.getCoveredFunctions());
179 // Skip functions-level information for summary-only export mode.
180 if (!Options.ExportSummaryOnly) {
181 emitDictKey("functions");
182 renderFunctions(Coverage.getCoveredFunctions());
183 }
181184
182185 emitDictKey("totals");
183186 renderSummary(Totals);
253256 emitDictStart();
254257
255258 emitDictElement("filename", FileCoverage.getFilename());
256 emitDictKey("segments");
257
258 // Start List of Segments.
259 emitArrayStart();
260
261 for (const auto &Segment : FileCoverage)
262 renderSegment(Segment);
263
264 // End List of Segments.
265 emitArrayEnd();
266
267 emitDictKey("expansions");
268
269 // Start List of Expansions.
270 emitArrayStart();
271
272 for (const auto &Expansion : FileCoverage.getExpansions())
273 renderExpansion(Expansion);
274
275 // End List of Expansions.
276 emitArrayEnd();
259
260 // Skip segments and expansions for summary-only export mode.
261 if (!Options.ExportSummaryOnly) {
262 emitDictKey("segments");
263
264 // Start List of Segments.
265 emitArrayStart();
266
267 for (const auto &Segment : FileCoverage)
268 renderSegment(Segment);
269
270 // End List of Segments.
271 emitArrayEnd();
272
273 emitDictKey("expansions");
274
275 // Start List of Expansions.
276 emitArrayStart();
277
278 for (const auto &Expansion : FileCoverage.getExpansions())
279 renderExpansion(Expansion);
280
281 // End List of Expansions.
282 emitArrayEnd();
283 }
277284
278285 emitDictKey("summary");
279286 renderSummary(FileReport);
3131 bool ShowFullFilenames;
3232 bool ShowRegionSummary;
3333 bool ShowInstantiationSummary;
34 bool ExportSummaryOnly;
3435 OutputFormat Format;
3536 std::string ShowOutputDirectory;
3637 std::vector DemanglerOpts;