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

color fix attempt #48

Merged
merged 10 commits into from
Apr 17, 2024
Merged
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
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Changes in version 2024.4.16

- If result is data frame with 1 row, save more.units.
- atime_pkg version names HEAD/base/CRAN defined in R color names are now translated to their expanded names on the plot (CRAN=1.15.0 etc), and default colors were added for Slow and Fast.

Changes in version 2024.4.12

Expand Down
35 changes: 29 additions & 6 deletions R/versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ atime_versions_install <- function(Package, pkg.path, new.Package.vec, sha.vec,
new.Package=new.Package,
sha=sha,
new.pkg.path=sha.path)
INSTALL.cmd <- paste("R CMD INSTALL", sha.path)
INSTALL.cmd <- paste(
shQuote(file.path(
Sys.getenv("R_HOME"),
"bin",
"R")),
'CMD INSTALL -l',
shQuote(.libPaths()[1]),
sha.path)
status.int <- system(INSTALL.cmd)
if(status.int != 0){
stop(INSTALL.cmd, " returned error status code ", status.int)
Expand Down Expand Up @@ -215,11 +222,27 @@ atime_pkg <- function(pkg.path=".", tests.dir="inst"){
test.env <- new.env()
tests.parsed <- parse(tests.R)
eval(tests.parsed, test.env)
color.vec <- if(is.null(test.env$version.colors)){
structure(c(#RColorBrewer::brewer.pal(7, "Dark2")
"#1B9E77", "#D95F02", "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D"),
names=c(HEAD.name, base.name, "merge-base", CRAN.name, "Before", "Regression", "Fixed"))
}else test.env$version.colors
color.vec <- if(is.character(test.env$version.colors)){
test.env$version.colors
}else{
c(#RColorBrewer::brewer.pal(7, "Dark2")
HEAD="#1B9E77",
base="#D95F02",
"merge-base"="#7570B3",
CRAN="#E7298A",
Before="#66A61E",
Regression="#E6AB02", Slow="#E6AB02",
Fixed="#A6761D", Fast="#A6761D"
)
}
abbrev2name <- c(
HEAD=HEAD.name,
base=base.name,
CRAN=CRAN.name)
names(color.vec) <- ifelse(
names(color.vec) %in% names(abbrev2name),
abbrev2name[names(color.vec)],
names(color.vec))
pkg.results <- list()
blank.dt.list <- list()
bench.dt.list <- list()
Expand Down
4 changes: 3 additions & 1 deletion man/atime_pkg.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
merge-base is most recent common ancestor commit between base and
HEAD.
The \code{tests.R} code file can define \code{version.colors} which should be
a character vector (names for versions, values for colors).
a character vector (names for versions, values for colors; names/versions are
HEAD, base, CRAN, merge-base, and any others you may define such as
Before, Regression, Slow, Fixed, Fast).
}
\value{Named list, names come from names of \code{test.list}, and values
come from results of \code{atime_versions}. Side effect is that
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ test_that("error if no versions specified", {
"need to specify at least one git SHA, in either sha.vec, or ...",
fixed=TRUE)
})

test_that("atime_pkg produces tests_all_facet.png", {
repo <- git2r::repository(tdir)
git2r::checkout(repo, branch="another-branch")
inst.atime <- file.path(tdir, "inst", "atime")
options(repos="http://cloud.r-project.org")#required to check CRAN version.
result.list <- atime::atime_pkg(tdir)
tests_all_facet.png <- file.path(inst.atime, "tests_all_facet.png")
expect_true(file.exists(tests_all_facet.png))
})
Loading