From a6c39cfb2265846a8aab4f77c8020b8625cdf667 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Tue, 16 Apr 2024 22:19:26 -0700 Subject: [PATCH 1/9] color fix attempt --- R/versions.R | 26 +++++++++++++++++++++----- man/atime_pkg.Rd | 4 +++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/R/versions.R b/R/versions.R index 994a8ae..29ab99f 100644 --- a/R/versions.R +++ b/R/versions.R @@ -215,11 +215,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() diff --git a/man/atime_pkg.Rd b/man/atime_pkg.Rd index 6de5590..9441cf7 100644 --- a/man/atime_pkg.Rd +++ b/man/atime_pkg.Rd @@ -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 From 6b804e2a77bcc65288acc9c65ebf2ebb43b24cfe Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Tue, 16 Apr 2024 22:31:15 -0700 Subject: [PATCH 2/9] test_pkg like vignette on binsegRcpp --- tests/testthat/test-versions.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index e8d69db..cc94f14 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -17,3 +17,12 @@ 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") + 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)) +}) From fd8f634dc870eba9c55ee5a7cb6011a57c7d7e07 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Tue, 16 Apr 2024 22:34:22 -0700 Subject: [PATCH 3/9] colors --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 2a1eeed..089210a 100644 --- a/NEWS +++ b/NEWS @@ -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 From 7b9f55c1274d4b2434eef32835a7b6dce0b757b3 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Tue, 16 Apr 2024 23:11:37 -0700 Subject: [PATCH 4/9] options repos --- tests/testthat/test-versions.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index cc94f14..6ac452c 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -22,6 +22,7 @@ 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)) From 177ca71b323e6efc66e44d0ee5f025a057c51b5d Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Tue, 16 Apr 2024 23:40:31 -0700 Subject: [PATCH 5/9] try $R_HOME --- R/versions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/versions.R b/R/versions.R index 29ab99f..4790535 100644 --- a/R/versions.R +++ b/R/versions.R @@ -79,7 +79,7 @@ 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('"$R_HOME/bin/R" CMD INSTALL', sha.path) status.int <- system(INSTALL.cmd) if(status.int != 0){ stop(INSTALL.cmd, " returned error status code ", status.int) From 116965a6b6a4e03a8607af5c8a21deade653a3b2 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Wed, 17 Apr 2024 11:49:28 -0700 Subject: [PATCH 6/9] try getenv and shQuote --- R/versions.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/versions.R b/R/versions.R index 4790535..9e6566d 100644 --- a/R/versions.R +++ b/R/versions.R @@ -79,7 +79,13 @@ 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_HOME/bin/R" CMD INSTALL', sha.path) + INSTALL.cmd <- paste( + shQuote(file.path( + Sys.getenv("R_HOME"), + "bin", + "R")), + 'CMD INSTALL', + sha.path) status.int <- system(INSTALL.cmd) if(status.int != 0){ stop(INSTALL.cmd, " returned error status code ", status.int) From 8bad156e47dfb9f103498304b1b74b25c434fa27 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Wed, 17 Apr 2024 13:42:19 -0700 Subject: [PATCH 7/9] print libPaths --- R/versions.R | 1 + tests/testthat/test-versions.R | 1 + 2 files changed, 2 insertions(+) diff --git a/R/versions.R b/R/versions.R index 9e6566d..2df27aa 100644 --- a/R/versions.R +++ b/R/versions.R @@ -86,6 +86,7 @@ atime_versions_install <- function(Package, pkg.path, new.Package.vec, sha.vec, "R")), 'CMD INSTALL', sha.path) + print(.libPaths()) status.int <- system(INSTALL.cmd) if(status.int != 0){ stop(INSTALL.cmd, " returned error status code ", status.int) diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index 6ac452c..bb22c4b 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -23,6 +23,7 @@ test_that("atime_pkg produces tests_all_facet.png", { 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. + print(.libPaths()) 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)) From c47204f51211ed63be07a81cba4e07c0fefe120c Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Wed, 17 Apr 2024 14:42:55 -0700 Subject: [PATCH 8/9] try -l --- R/versions.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/versions.R b/R/versions.R index 2df27aa..9cbd6c2 100644 --- a/R/versions.R +++ b/R/versions.R @@ -84,9 +84,11 @@ atime_versions_install <- function(Package, pkg.path, new.Package.vec, sha.vec, Sys.getenv("R_HOME"), "bin", "R")), - 'CMD INSTALL', + 'CMD INSTALL -l', + shQuote(.libPaths()[1]), sha.path) print(.libPaths()) + print(INSTALL.cmd) status.int <- system(INSTALL.cmd) if(status.int != 0){ stop(INSTALL.cmd, " returned error status code ", status.int) From 1cc3694e9da713b0842c958be539231bafe09bc5 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Wed, 17 Apr 2024 15:02:25 -0700 Subject: [PATCH 9/9] rm print --- R/versions.R | 2 -- tests/testthat/test-versions.R | 1 - 2 files changed, 3 deletions(-) diff --git a/R/versions.R b/R/versions.R index 9cbd6c2..a2f264a 100644 --- a/R/versions.R +++ b/R/versions.R @@ -87,8 +87,6 @@ atime_versions_install <- function(Package, pkg.path, new.Package.vec, sha.vec, 'CMD INSTALL -l', shQuote(.libPaths()[1]), sha.path) - print(.libPaths()) - print(INSTALL.cmd) status.int <- system(INSTALL.cmd) if(status.int != 0){ stop(INSTALL.cmd, " returned error status code ", status.int) diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index bb22c4b..6ac452c 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -23,7 +23,6 @@ test_that("atime_pkg produces tests_all_facet.png", { 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. - print(.libPaths()) 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))