Skip to content
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

Merged
merged 28 commits into from
Jun 26, 2017
Merged

icc code coverage support #247

merged 28 commits into from
Jun 26, 2017

Conversation

chinqw
Copy link
Contributor

@chinqw chinqw commented Jan 25, 2017

No description provided.

Copy link
Member

@jimhester jimhester left a 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
Copy link
Member

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

@@ -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:
Copy link
Member

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")
})
}

Copy link
Member

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])
Copy link
Member

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)
Copy link
Member

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)]
Copy link
Member

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)
Copy link
Member

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")
}
Copy link
Member

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)

Copy link
Member

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", "")
Copy link
Member

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?

Copy link
Contributor Author

@chinqw chinqw left a 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.

@chinqw
Copy link
Contributor Author

chinqw commented Mar 29, 2017

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.

@chinqw
Copy link
Contributor Author

chinqw commented Mar 29, 2017

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.

@chinqw chinqw closed this Mar 29, 2017
@chinqw chinqw reopened this Mar 29, 2017
@jimhester jimhester mentioned this pull request Mar 31, 2017
20 tasks
@jimhester jimhester closed this Apr 28, 2017
@jimhester jimhester reopened this Apr 28, 2017
@CLAassistant
Copy link

CLAassistant commented Apr 28, 2017

CLA assistant check
All committers have signed the CLA.

@jimhester
Copy link
Member

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-io
Copy link

codecov-io commented Jun 11, 2017

Codecov Report

Merging #247 into master will decrease coverage by 5.94%.
The diff coverage is 23.84%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
R/icc.R 0% <0%> (ø)
R/zzz.R 0% <0%> (ø) ⬆️
R/covr.R 88.93% <69.23%> (-2.62%) ⬇️
R/compiled.R 94.02% <94.73%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 580c2fc...7be54d6. Read the comment docs.

@chinqw
Copy link
Contributor Author

chinqw commented Jun 11, 2017

oracle license statement has been removed. Changes are sync'ed with master branch.

Copy link
Member

@jimhester jimhester left a 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)),
Copy link
Member

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() {
Copy link
Member

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)
}

@chinqw
Copy link
Contributor Author

chinqw commented Jun 17, 2017

suggested changes are done.

@jimhester jimhester merged commit 7be54d6 into r-lib:master Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants