-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
icc code coverage support #247
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first pass review of the PR. It would be nice to test this on travis as well before merging. https://github.com/nemequ/icc-travis has an example of using icc on travis, I can look into it further.
DESCRIPTION
Outdated
@@ -57,7 +57,7 @@ Suggests: | |||
xml2 (>= 1.0.0), | |||
parallel, | |||
memoise | |||
License: MIT + file LICENSE | |||
License: MIT + file LICENSE + Oracle Contribution License |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be License: MIT + file LICENSE | GPL-3
Oracle Contribution under GPL-3
Outdated
@@ -0,0 +1,18 @@ | |||
This software (the "Software") is contributed under the terms of the GPL-3 with additional permission for MIT under GPL-3 Section 7 as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this license information should go in inst/COPYING
.
@@ -99,3 +99,152 @@ run_gcov <- function(path, quiet = TRUE, | |||
class = "coverage") | |||
}) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should go in R/icc.R
.
R/compiled.R
Outdated
# parse icc compiler code coverage output | ||
parse_icov <- function(lines, package_path = "") { | ||
|
||
source_file <- trimws(lines[1L]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trimws is only available in (R >= 3.3.0), covr supports (R >= 3.1.0), so an alternative would need to be provided for earlier versions.
R/compiled.R
Outdated
capture(name = "idcol", digits), "\t", any_spaces, | ||
capture(name = "coverage", digits)) | ||
|
||
showCfunctions <- getOption("covr.showCfunctions", FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should follow the conventions in the rest of the package and be snake_case
.
R/covr.R
Outdated
rex::rex(start, "CC = ", | ||
capture(name = "compiler", anything), | ||
" ", anything))$compiler | ||
compiler <- compiler[!is.na(compiler)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should error if no compiler is found.
R/covr.R
Outdated
" ", anything))$compiler | ||
compiler <- compiler[!is.na(compiler)] | ||
|
||
res <- try(system(paste(compiler, "--version"), intern=TRUE), silent=TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tryCatch(
system2(compiler, "--version"),
error = function(e) {
warning("cannot recognize a supported compiler")
})
R/covr.R
Outdated
return("gcc") | ||
else if (length(grep("icc ", res)) > 0L) | ||
return("icc") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about clang? Typically it is aliased as gcc, but it can also be explicitly specified.
R/compiled.R
Outdated
|
||
icov_inputs <- list.files(path, pattern = rex::rex(".dyn", end), | ||
recursive = TRUE, full.names = TRUE) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are no icov inputs we can probably return early here.
R/compiled.R
Outdated
icov_inputs <- list.files(path, pattern = rex::rex(".dyn", end), | ||
recursive = TRUE, full.names = TRUE) | ||
|
||
icov_profmerge <- getOption("covr.icov_prof", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return if this is not set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited the changes based upon the comments.
Will move parse_icov and run_icov to a new file icc.R in a separate pull afterwards.
Make changes according to the review comments and update DESCRIPTION and LICENSE files with new proposal. The new license proposal "License: MIT + file LICENSE + Portions GPLv3 with Additional Permission | GPLv3" in DESCRIPTION file seems to cause R CMD check a warning which is flagged by travis. |
made changes according to review comments and updated license with a new proposal. It seems that the new license proposal 'License: MIT + file LICENSE + Portions GPLv3 with Additional Permission | GPLv3' causes R CMD check a warning which is flagged by travis. |
I recently modified the covr license to be GPL-3 and you will need to sign the project CLA and remove the Oracle copyright clauses in order to contribute this code. |
Codecov Report
@@ Coverage Diff @@
## master #247 +/- ##
==========================================
- Coverage 80.65% 74.71% -5.95%
==========================================
Files 23 24 +1
Lines 1370 1499 +129
==========================================
+ Hits 1105 1120 +15
- Misses 265 379 +114
Continue to review full report at Codecov.
|
oracle license statement has been removed. Changes are sync'ed with master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for removing the comments, I have a few minor suggestions around detecting the compiler used.
Also could you add a note to NEWS.md with the change and mentioning yourself and add your name as a contributor to the DESCRIPTION file (if it is not already there).
R/covr.R
Outdated
relative = relative_path) | ||
} else { | ||
# use icc compiler | ||
coverage <- structure(c(coverage, run_icov(pkg$path, quiet = quiet)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't duplicate all of the code, just the object that differs.
res <- if (uses_icc()) {
run_icov(pkg$path, quiet = quiet)
} else {
run_gcov(pkg$path, quiet = quiet)
}
coverage <- structure(c(coverage, res), class = "coverage", package = pkg, relative = relative_path)
R/covr.R
Outdated
@@ -429,3 +455,23 @@ add_hooks <- function(pkg_name, lib, fix_mcexit = FALSE) { | |||
|
|||
writeLines(text = lines, con = load_script) | |||
} | |||
|
|||
# check if gcc or icc is used | |||
get_compiler <- function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function should just check if icc
is used and fallback to the current behavior otherwise. Also you cannot assume the R CMD config CC
will have trailing spaces, using the word boundary \\b
anchor is a better solution.
uses_icc <- function() {
compiler <- tryCatch(
paste(system(paste(R.home("bin"), "R --vanilla CMD config CC", sep="/"),
intern = TRUE), collapse=""),
error = function(e) "")
grepl("\\bicc\\b", compiler)
}
suggested changes are done. |
No description provided.