<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/138350>138350</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[llvm-cov] Add support to llvm-cov show HTML ouptut to strip out the base absolute base source directory path
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bartlettroscoe
</td>
</tr>
</table>
<pre>
## Description
The current implementation of `llvm-cov show -format html [other options] -o <cov-output-dir>` produces HTML files and subdirectories that show the absolute path the source files. For example, for a coverage build for Trilinos, the base `index.html` file shows the absolute directory path `/scratch/rabartl/Trilinos.base/Trilinos/` like:

I realize that this allows reporting coverage from source files all over the directory tree, but this is not ideal in most cases because:
1. Most coverage reporting will be for defined projects under a single base source directory
2. We don't want to clutter the HTML output with the full absolute directory path
3. The full absolute directory path may actually be considered sensitive information in some contexts where the relative directory path would not be
4. The generated directory tree under `cov-output-dir>/coverage/` has a bunch of worthless empty directories starting from the root `/`.
## Proposed solution
One potential solution would be to add a new argument to `llvm-cov show` like `--base-project-path <base-project-path>` which would strip the base path off of the sources specified by `--sources <src1> <src2> ...`. For example, for Trilinos we could run something like:
```
llvm-cov show [other args] -o <cov-output-dir> --base-project-path /scratch/rabartl/Trilinos.base/Trilinos \
--sources /scratch/rabartl/Trilinos.base/Trilinos/packages/teuchos
```
This would produce HTML files that shows the base path as `Trilinos/packages/teuchos` and the subdirectory path under `<cov-output-dir>/coverage/` would be:
```
<cov-output-dir>/coverage/packages/teuchos/
```
and so on under that.
So the output HTML coverage file would look like:

NOTE: The justification to leave the last subdir path of `<base-project-path>` (which is `Trilinos` in this example) is that this subdir name is typically the project name, and therefore makes a meaningful name for the report and the page.
## Workaround
One can workaround this by post-processing the generated HTML files and directories to achieve the desired result.
ToDo: Post shell script that does the correct post-processing.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0Vl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