Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ optional arguments:
(default: ['utf-8', 'latin-1'])
--dump [FILE] dump JSON payload to a file
--skip-ssl-verify skip ssl certificate verification when communicating with the coveralls server
-p DIR, --prefix DIR A prefix to prepend to generated filenames. This
option is useful when source files exist in the root
directory and you want to simulate a source tree in
coveralls.io. for example, if you pass --prefix foo,
filenames in coveralls.io will be shown as foo/bar.c.
```

## Example `.travis.yml`
Expand Down
14 changes: 14 additions & 0 deletions cpp_coveralls/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def create_args(params):
help='skip ssl certificate verification when '
'communicating with the coveralls server',
action='store_true', default=False)
parser.add_argument('-p', '--prefix', metavar="DIR",
help='A prefix to prepend to generated filenames. '
'This option is useful when source files exist '
'in the root directory and you want to simulate '
'a source tree in coveralls.io. for example, if '
'you pass --prefix foo, filenames in '
'coveralls.io will be shown as foo/bar.c.'
)

return parser.parse_args(params)

Expand Down Expand Up @@ -469,4 +477,10 @@ def collect(args):

# Use the root directory to get information on the Git repository
report['git'] = gitrepo.gitrepo(abs_root)

# Prepent the prefix to sourcefiles if given.
if args.prefix:
for sourcefile in report['source_files']:
sourcefile['name'] = os.path.join(args.prefix, sourcefile['name'])

return report