From: Vedant Kumar Date: Tue, 28 Feb 2017 16:57:28 +0000 (+0000) Subject: [llvm-cov] Error-out when an unsupported format is used (PR32087) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09f10e7e60533898a421db7594e5766c0d7f7bef;p=llvm [llvm-cov] Error-out when an unsupported format is used (PR32087) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296487 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-cov/warnings.h b/test/tools/llvm-cov/warnings.h index 0517b6a7c87..a06e02f92d5 100644 --- a/test/tools/llvm-cov/warnings.h +++ b/test/tools/llvm-cov/warnings.h @@ -1,5 +1,7 @@ // RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence /dev/null | FileCheck %s -allow-empty -check-prefix=FAKE-FILE-STDOUT // RUN: llvm-cov show %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -filename-equivalence /dev/null 2>&1 | FileCheck %s -check-prefix=FAKE-FILE-STDERR +// RUN: not llvm-cov report %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html +// RUN: not llvm-cov export %S/Inputs/prevent_false_instantiations.covmapping -instr-profile %S/Inputs/elf_binary_comdat.profdata -format=html // FAKE-FILE-STDOUT-NOT: warning: The file '{{.*}}' isn't covered. // FAKE-FILE-STDERR: warning: The file '{{.*}}' isn't covered. diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp index 781d1948ccd..6179c760d5b 100644 --- a/tools/llvm-cov/CodeCoverage.cpp +++ b/tools/llvm-cov/CodeCoverage.cpp @@ -818,8 +818,10 @@ int CodeCoverageTool::report(int argc, const char **argv, if (Err) return Err; - if (ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML) + if (ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML) { error("HTML output for summary reports is not yet supported."); + return 1; + } auto Coverage = load(); if (!Coverage) @@ -840,6 +842,11 @@ int CodeCoverageTool::export_(int argc, const char **argv, if (Err) return Err; + if (ViewOpts.Format != CoverageViewOptions::OutputFormat::Text) { + error("Coverage data can only be exported as textual JSON."); + return 1; + } + auto Coverage = load(); if (!Coverage) { error("Could not load coverage information");