mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[llvm-cov] Use relative paths to file reports in -output-dir mode
This makes it possible to e.g copy a report to another filesystem. llvm-svn: 274173
This commit is contained in:
parent
873731b063
commit
c8e68bf5bb
@ -9,3 +9,9 @@
|
||||
// CHECK-NOT: coverage{{.*}}dots{{.*}}..{{.*}}dots
|
||||
|
||||
int main() {}
|
||||
|
||||
// Re-purpose this file to test that we use relative paths when creating
|
||||
// report indices:
|
||||
|
||||
// RUN: FileCheck -check-prefix=REL-INDEX -input-file %t.dir/index.txt %s
|
||||
// REL-INDEX-NOT: %t.dir
|
||||
|
@ -28,10 +28,14 @@ void CoveragePrinter::StreamDestructor::operator()(raw_ostream *OS) const {
|
||||
}
|
||||
|
||||
std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension,
|
||||
bool InToplevel) {
|
||||
bool InToplevel, bool Relative) {
|
||||
assert(Extension.size() && "The file extension may not be empty");
|
||||
|
||||
SmallString<256> FullPath(Opts.ShowOutputDirectory);
|
||||
SmallString<256> FullPath;
|
||||
|
||||
if (!Relative)
|
||||
FullPath.append(Opts.ShowOutputDirectory);
|
||||
|
||||
if (!InToplevel)
|
||||
sys::path::append(FullPath, getCoverageDir());
|
||||
|
||||
@ -51,7 +55,7 @@ CoveragePrinter::createOutputStream(StringRef Path, StringRef Extension,
|
||||
if (!Opts.hasOutputDirectory())
|
||||
return OwnedStream(&outs());
|
||||
|
||||
std::string FullPath = getOutputPath(Path, Extension, InToplevel);
|
||||
std::string FullPath = getOutputPath(Path, Extension, InToplevel, false);
|
||||
|
||||
auto ParentDir = sys::path::parent_path(FullPath);
|
||||
if (auto E = sys::fs::create_directories(ParentDir))
|
||||
|
@ -111,9 +111,11 @@ public:
|
||||
protected:
|
||||
CoveragePrinter(const CoverageViewOptions &Opts) : Opts(Opts) {}
|
||||
|
||||
/// \brief Return `OutputDir/ToplevelDir/Path.Extension`.
|
||||
/// \brief Return `OutputDir/ToplevelDir/Path.Extension`. If \p InToplevel is
|
||||
/// false, skip the ToplevelDir component. If \p Relative is false, skip the
|
||||
/// OutputDir component.
|
||||
std::string getOutputPath(StringRef Path, StringRef Extension,
|
||||
bool InToplevel);
|
||||
bool InToplevel, bool Relative = true);
|
||||
|
||||
/// \brief If directory output is enabled, create a file in that directory
|
||||
/// at the path given by getOutputPath(). Otherwise, return stdout.
|
||||
|
Loading…
x
Reference in New Issue
Block a user