R Under development (unstable) (2024-05-17 r86565 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Overflow tests from testthat.unitize.R > > source(file.path("_helper", "init.R")) > source(file.path("_helper", "pkgs.R")) Install Packages Setup Demos > > library(unitizer) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "unreviewed variations" ---------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Test unreviewed > # Accept one and go to unreviewed > # Accept one more and browse and go to unreviewed > # Accept two remaining and confirm no unreviewed > # No unreviewed tests > unitizer:::read_line_set_vals( + c("Y", "Q", "U", "Y", "B", "U", "Y", "Y", "U", "B", "U", "Q") + ) > out <- unitizer:::capture_output(unitize(FLM.TEST.FILE, interactive.mode = TRUE)) > unitizer:::clean_eval_exp(out) - Output ----------------------------------------------------------------------- +------------------------------------------------------------------------------+ | unitizer for: unitizer/fastlm1.R | +------------------------------------------------------------------------------+ Pass Fail New - - 4 ........................... - - 4 - New -------------------------------------------------------------------------- | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? # Assignments and calls to `library` are not considered tests by # `unitizer` so you will not need to review them > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) > dat <- data.frame(x = 1:100, y = (1:100)^2) > res <- fastlm(dat$x, dat$y) # The `unitizer>` prompt is like the standard R prompt. You may # enter expressions such as `lm(y ~ x, dat)$coefficients`, or # `str(res)`. # # Once you are done reviewing, you need to tell `unitizer` you # accept the test by typing 'Y' at the prompt. Enter 'H' for help. > res intercept slope rsq -1717.000 101.000 0.939 attr(,"class") [1] "fastlm" unitizer> Y # There are three more tests to review; accept them with 'Y' > get_slope(res) [1] 101 unitizer> Q = Finalize Unitizer ============================================================ | You have 3 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U]nreviewed, [R]erun)? unitizer> U # There are three more tests to review; accept them with 'Y' > get_slope(res) [1] 101 unitizer> Y > get_rsq(res) [1] 0.939 unitizer> B *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) . -:- *2. dat <- data.frame(x = 1:100, y = (1:100)^2) . . . . . . -:- *3. res <- fastlm(dat$x, dat$y) . . . . . . . . . . . . -:- 4. res . . . . . . . . . . . . . . . . . . . . New:Y 5. get_slope(res) . . . . . . . . . . . . . . . . New:Y 6. get_rsq(res) . . . . . . . . . . . . . . . . . New:- 7. fastlm(1:100, 1:10) . . . . . . . . . . . . . . New:- | What test do you wish to review (input a test number, [U]nreviewed)? unitizer> U - New -------------------------------------------------------------------------- | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? > get_rsq(res) [1] 0.939 unitizer> Y # This last test is expected to cause an error; press 'Y' to # accept it so future checks can confirm the same error persists > fastlm(1:100, 1:10) unitizer> Y = Finalize Unitizer ============================================================ | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)? unitizer> U | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)? unitizer> B *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) . -:- *2. dat <- data.frame(x = 1:100, y = (1:100)^2) . . . . . . -:- *3. res <- fastlm(dat$x, dat$y) . . . . . . . . . . . . -:- 4. res . . . . . . . . . . . . . . . . . . . . New:Y 5. get_slope(res) . . . . . . . . . . . . . . . . New:Y 6. get_rsq(res) . . . . . . . . . . . . . . . . . New:Y 7. fastlm(1:100, 1:10) . . . . . . . . . . . . . . New:Y | What test do you wish to review (input a test number, [U]nreviewed)? unitizer> U = Finalize Unitizer ============================================================ | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)? unitizer> Q | unitizer unchanged. - Message ---------------------------------------------------------------------- | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by: | - Adding 1 out of 4 new tests Error in fastlm(1:100, 1:10) : Arguments `x` and `y` must be the same length. | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by: | - Adding 4 out of 4 new tests Error in : object 'U' not found | No unreviewed tests. | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by: | - Adding 4 out of 4 new tests | Changes discarded. > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Re-eval" ------------------------------------------------------------------ > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Test re-eval > # Re-eval and jump back to file 1 > # Quit from file 1 and back to main menu > # Accept one test in file 2 and quit > # Go to file 3, accept one, and Re-eval all > > unitizer:::read_line_set_vals( + c("1", "Y", "R", "Y", "Q", "2", "Y", "Y", "3", "Y", "RR", "Y", "Q", "Q") + ) > untz1 <- unitize_dir(FLM.TEST.DIR, interactive.mode = TRUE) | Summary of files in common directory 'unitizer': | | Pass Fail New | *1. fastlm1.R - - 4 | *2. fastlm2.R - - 1 | *3. unitizer.fastlm.R - - 3 | ..................................... | - - 8 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> 1 +------------------------------------------------------------------------------+ | unitizer for: unitizer/fastlm1.R | +------------------------------------------------------------------------------+ Pass Fail New - - 4 ........................... - - 4 - New -------------------------------------------------------------------------- | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? # Assignments and calls to `library` are not considered tests by # `unitizer` so you will not need to review them > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) > dat <- data.frame(x = 1:100, y = (1:100)^2) > res <- fastlm(dat$x, dat$y) # The `unitizer>` prompt is like the standard R prompt. You may # enter expressions such as `lm(y ~ x, dat)$coefficients`, or # `str(res)`. # # Once you are done reviewing, you need to tell `unitizer` you # accept the test by typing 'Y' at the prompt. Enter 'H' for help. > res intercept slope rsq -1717.000 101.000 0.939 attr(,"class") [1] "fastlm" unitizer> Y # There are three more tests to review; accept them with 'Y' > get_slope(res) [1] 101 unitizer> R | Toggling re-run mode ON for this unitizer = Finalize Unitizer ============================================================ | You have 3 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by: | - Adding 1 out of 4 new tests | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U] | nreviewed, [R]erun)? unitizer> Y | unitizer updated. +------------------------------------------------------------------------------+ | unitizer for: unitizer/fastlm1.R | +------------------------------------------------------------------------------+ Pass Fail New 1 - 3 ........................... 1 - 3 - New -------------------------------------------------------------------------- | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? | Jumping to test #5 because that was the test under review when test re-run was | requested. # There are three more tests to review; accept them with 'Y' > get_slope(res) [1] 101 unitizer> Q | No changes recorded. | unitizer unchanged. | Summary of files in common directory 'unitizer': | | Pass Fail New | *1. fastlm1.R 1 - 3 | *2. fastlm2.R - - 1 | *3. unitizer.fastlm.R - - 3 | ..................................... | 1 - 7 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> 2 +------------------------------------------------------------------------------+ | unitizer for: unitizer/fastlm2.R | +------------------------------------------------------------------------------+ Pass Fail New - - 1 ........................... - - 1 - New -------------------------------------------------------------------------- | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, | [R]erun, [Q]uit, [H]elp)? # For internal tests only; not for demo > x <- 1:10 > y <- 1:10^3 > res <- summary(lm(y ~ x, data.frame(x = x, y = y))) > intercept <- res$coefficients[1, 1] > slope <- res$coefficients[2, 1] > rsq <- res$r.squared > structure(c(intercept = intercept, slope = slope, rsq = rsq), + class = "fastlm") intercept slope rsq 4.95e+02 1.00e+00 9.90e-05 attr(,"class") [1] "fastlm" unitizer> Y = Finalize Unitizer ============================================================ | You will IRREVERSIBLY modify 'unitizer/fastlm2.unitizer' by: | - Adding 1 out of 1 new tests | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)? unitizer> Y | unitizer updated. | Summary of files in common directory 'unitizer': | | Pass Fail New | *1. fastlm1.R 1 - 3 | $2. fastlm2.R ? ? ? | *3. unitizer.fastlm.R - - 3 | ..................................... | ? ? ? | Legend: | * `unitizer` requires review | $ `unitizer` has been modified and needs to be re-run to recompute summary | Type number of unitizer to review, 'A' to review all that require review, 'R' | to re-run all updated unitizer> 3 +------------------------------------------------------------------------------+ | unitizer for: unitizer/unitizer.fastlm.R | +------------------------------------------------------------------------------+ Pass Fail New - - 3 ........................... - - 3 - New -------------------------------------------------------------------------- | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? # Extra test file for internal tests; not for DEMO > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) > x <- 1:10 > y <- x^3 > res <- fastlm(x, y) > get_slope(res) [1] 105 unitizer> Y > get_rsq(res) [1] 0.862 unitizer> RR | Toggling re-run mode ON for all loaded unitizers = Finalize Unitizer ============================================================ | You have 2 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | You will IRREVERSIBLY modify 'unitizer/unitizer.fastlm.unitizer' by: | - Adding 1 out of 3 new tests | Update unitizer and re-run all loaded unitizers ([Y]es, [N]o, [P]rev, [B] | rowse, [U]nreviewed, [R]erun)? unitizer> Y | unitizer updated. | Summary of files in common directory 'unitizer': | | Pass Fail New | *1. fastlm1.R 1 - 3 | 2. fastlm2.R 1 - - | *3. unitizer.fastlm.R 1 - 2 | ..................................... | 3 - 5 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> Q > print(untz1) Summary of tests (accept/total): id test.file New Passed Totals 1 fastlm1.R 0/3 1/1 1/4 $ 2 fastlm2.R 0/0 1/1 1/1 $ 3 unitizer.fastlm.R 0/2 1/1 1/3 $ ----------------------------------------------------- 0 Totals 0/5 3/3 3/8 $ unitizer was saved in prior evaluation Test files in common directory 'tests/unitizer' > # remove temp file names and display > invisible(lapply(untz1, function(x) {print(x); cat('\n')})) Test File: tests/unitizer/fastlm1.R Store ID: tests/unitizer/fastlm1.unitizer id call ignored status user reviewed 1 4 library(utzflm, lib.loc = g... * Passed Y FALSE 2 5 dat <- data.frame(x = 1:100... * Passed Y FALSE 3 6 res <- fastlm(dat$x, dat$y) * Passed Y FALSE 4 7 res Passed Y FALSE 5 1 get_slope(res) New N FALSE 6 2 get_rsq(res) New N FALSE 7 3 fastlm(1:100, 1:10) New N FALSE You chose NOT to save these changes to the unitizer store Test File: tests/unitizer/fastlm2.R Store ID: tests/unitizer/fastlm2.unitizer id call ignored status user reviewed 1 1 x <- 1:10 * Passed Y FALSE 2 2 y <- 1:10^3 * Passed Y FALSE 3 3 res <- summary(lm(y ~ x, da... * Passed Y FALSE 4 4 intercept <- res$coefficien... * Passed Y FALSE 5 5 slope <- res$coefficients[2... * Passed Y FALSE 6 6 rsq <- res$r.squared * Passed Y FALSE 7 7 structure(c(intercept = int... Passed Y FALSE You chose NOT to save these changes to the unitizer store Test File: tests/unitizer/unitizer.fastlm.R Store ID: tests/unitizer/unitizer.fastlm.unitizer id call ignored status user reviewed 1 3 library(utzflm, lib.loc = g... * Passed Y FALSE 2 4 x <- 1:10 * Passed Y FALSE 3 5 y <- x^3 * Passed Y FALSE 4 6 res <- fastlm(x, y) * Passed Y FALSE 5 7 get_slope(res) Passed Y FALSE 6 1 get_rsq(res) New N FALSE 7 2 get_intercept(res) New N FALSE You chose NOT to save these changes to the unitizer store > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Section Extra" ------------------------------------------------------------ > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Make sure that deleted items from a section are still marked from that > # section upgrade to version two to use the files that are set up for that > # there; notice update_fastlm_*extra* > # Re-set by dropping unitizers > > unlink(list.dirs(FLM.TEST.DIR, recursive = FALSE), recursive = TRUE) > unitizer:::update_fastlm_extra(FLM) > inst_pak(FLM) > test.file.1 <- file.path(FLM.TEST.DIR, "unitizer.fastlm.R") > test.file.2 <- file.path(FLM.TEST.DIR, "unitizer.fastlm2.R") > test.store <- file.path(FLM.TEST.DIR, "store2.unitizer") > # First auto accept all initial tests, and then re-run with second version to > # make sure deleted tests are where we think they should be > out.1 <- + unitizer:::capture_output(unitize(test.file.1, test.store, auto.accept = "new")) > unitizer:::read_line_set_vals(c("B", "Q")) > out.2 <- unitizer:::capture_output( + untz.2 <- unitize(test.file.2, test.store, interactive.mode = TRUE) + ) > attributes(untz.2) <- NULL > untz.2 [[1]] [1] 1 2 3 4 5 6 7 [[2]] [1] "library(utzflm, lib.loc = getOption(\"unitizer.tmp.lib.loc\"))" [2] "x <- 1:10" [3] "y <- x^2" [4] "res <- fastlm(x, y)" [5] "get_slope(res)" [6] "get_rsq(res)" [7] "2 * get_slope(res) + get_intercept(res)" [[3]] [1] "Basic Tests" "Basic Tests" "Basic Tests" "Basic Tests" [5] "Basic Tests" "Advanced Tests" "Advanced Tests" [[4]] [1] TRUE TRUE TRUE TRUE FALSE FALSE FALSE [[5]] [1] Failed Failed Failed Failed Failed Failed Removed Levels: New Passed Failed Removed Corrupted [[6]] [1] N N N N N N N Levels: Y N [[7]] [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "warning when comp funs produce output" ------------------------------------ > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Sections with comp funs that output to stdout/stderr > temp.loc <- tempfile() > dir.create(temp.loc) > file.copy(file.path(START.DIR, "_helper", "unitizers", "sects.R"), temp.loc) [1] TRUE > f.sec <- file.path(temp.loc, "sects.R") > odir <- setwd(temp.loc) > out <- unitizer:::capture_output( + unitize(f.sec, auto.accept = "new", interactive.mode = FALSE + ) ) > > unitize(f.sec, interactive.mode = FALSE) Warning in close_and_clear(e1@global$cons) : Test comparison functions appear to have produced output, which should not happen (see `?unitizer_sect` for more details). If you did not provide custom testing functions, contact maintainer. First 50 lines follow: I'm outputting to stdout I'm outputting to stderr I'm outputting to both 1 I'm outputting to both 2 Warning in history_capt(history, interactive.mode) : Unable to capture history in non-interactive mode. | 3/3 tests passed; nothing to review. > setwd(odir) > unlink(temp.loc, recursive = TRUE) > > # - "Corner Case Files" -------------------------------------------------------- > > # Corner case files > # empty > temp.empty <- paste0(tempfile(), "-empty.R") > cat("\n", file = temp.empty) > empty.capt <- unitizer:::capture_output(unitize(temp.empty, force = TRUE)) > # File, but does not end in .R > temp.bad <- paste0(tempfile()) > > cat("\n", file = temp.bad) > badname.capt <- unitizer:::capture_output(try(unitize(temp.bad))) > any(grepl("`get_unitizer` error", out$message)) [1] FALSE > > any(grepl("Empty unitizer", empty.capt$output)) [1] TRUE > any(grepl("No valid unitizers available", badname.capt$message)) [1] FALSE > unlink(c(temp.empty, temp.bad)) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Re-eval change" ----------------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # re-eval reeval with a modified file > temp.reeval.base <- paste0(tempfile(), "-reeval") > temp.reeval <- paste0(temp.reeval.base, ".R") > temp.reeval.utz <- paste0(temp.reeval.base, ".unitizer") > cat("1 + 1\n2 + 2\n", file = temp.reeval) > # force re-review > unitizer:::read_line_set_vals(c("Y", "P", "Y", "cat(\"1 + 1\n2 + 3\n\", file=temp.reeval)", + "R", "Y", "Q")) > # state = environment() so we can access variables from this local > reeval.capt <- unitizer:::capture_output(unitize(temp.reeval, + state = environment(), interactive.mode = TRUE)) > unlink(c(temp.reeval, temp.reeval.utz), recursive = TRUE) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Condition fail" ----------------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Fail test with conditions > temp.cond.base <- paste0(tempfile(), "-cond") > temp.cond <- paste0(tempfile(), ".R") > temp.cond.utz <- paste0(tempfile(), ".unitizer") > cond.message <- "hello world" > cat("warning(cond.message)", file = temp.cond) > unitizer:::read_line_set_vals(c("Y", "Y")) > # state = environment() so we can access variables from this local > unitizer:::capture_output( + unitize(temp.cond, state = environment(), interactive.mode = TRUE) + ) > cond.message <- "goodbye world" > unitizer:::read_line_set_vals("Q") > cond.capt <- + unitizer:::capture_output( + unitize(temp.cond, state = environment(), interactive.mode = TRUE) + ) > sum(grepl("Conditions mismatch", cond.capt$output)) == 1L [1] TRUE > unlink(c(temp.cond, temp.cond.utz), recursive = TRUE) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Force" -------------------------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # > # Toggle force update, in order for this to work we need to create a situation > # where in a `unitize_dir`, one file passes, the other doesn't, and we review > # the file that passes. Otherwise the only other way to do it is to set force > # from the beginning, but that ruins the toggle effect. One possible issue > # here is that we don't have a great way to check the file actually changed. > > temp.forceup.base.dir <- tempfile() > dir.create(temp.forceup.base.dir) > temp.forceup.1 <- file.path(temp.forceup.base.dir, "force1.R") > temp.forceup.2 <- file.path(temp.forceup.base.dir, "force2.R") > cat("force.var\n", file = temp.forceup.1) > cat("4 + 1\n", file = temp.forceup.2) > force.var <- 1 > unitizer:::capture_output({ + unitize(temp.forceup.1, auto.accept = "new", state = environment()) + unitize(temp.forceup.2, auto.accept = "new", state = environment()) + }) > force.var <- 2 > unitizer:::read_line_set_vals(c("2", "1", "Y", "O", "Q", "Q")) > force.capt <- unitizer:::capture_output(unitize_dir(temp.forceup.base.dir, + state = environment(), interactive.mode = TRUE)) > unlink(temp.forceup.base.dir, recursive = TRUE) > sum(grepl("Toggling force update mode ON", force.capt$message)) == + 1L [1] TRUE > sum(grepl("You are about to .* with re-evaluated", force.capt$message)) == + 1L [1] TRUE > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Compare Funs" ------------------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Bad comparison functions > temp.bad.comp <- paste0(tempfile(), ".R") > cat("\n unitizer_sect(\n 'bad comp', {1 + 1; 2 + 2},\n compare=function(x, y) list('failed', 'comparison')\n )\n", + file = temp.bad.comp) > unitizer:::capture_output(unitize(temp.bad.comp, auto.accept = "new")) > unitizer:::read_line_set_vals(c("Q")) > bad.comp.capt <- unitizer:::capture_output(unitize(temp.bad.comp, + interactive.mode = TRUE)) > unlink(temp.bad.comp) > > sum(grepl("Unable to compare value", bad.comp.capt$message)) == 1L [1] TRUE > sum(grepl("Corrupted", bad.comp.capt$output)) >= 1L [1] TRUE > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "bad map" ------------------------------------------------------------------ > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Bad store mapping functions > > try(unitize_dir(FLM.TEST.DIR, store.ids = function(x) stop("Bad store map fun"))) Error in FUN(X[[i]], ...) : Bad store map fun Error in unitize_dir(FLM.TEST.DIR, store.ids = function(x) stop("Bad store map fun")) : Argument `store.ids` is a function, but caused an error when attempting to use it to convert test file names to `unitizer` ids. > > unitizer:::read_line_set_vals(NULL) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Multiple Bookmarks" ------------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Issue 245: In review-all mode should not move to next unitizer until the > # review bookmark is cleared. > > temp.dir <- tempfile() > dir.create(temp.dir) > writeLines("'hello'\n'world'", file.path(temp.dir, "a.R")) > writeLines("2 + 1\n3 + 2", file.path(temp.dir, "b.R")) > writeLines("pi\n2 * pi\nsqrt(pi)", file.path(temp.dir, "c.R")) > unitizer:::read_line_set_vals( + c("A","N","N","Y","Y","R","Y","Q","Y","R","Y","Y","Y","Y","Q") + ) > unitize_dir(temp.dir, interactive.mode=TRUE) | Summary of files in common directory '.': | | Pass Fail New | *1. a.R - - 2 | *2. b.R - - 2 | *3. c.R - - 3 | ....................... | - - 7 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> A +------------------------------------------------------------------------------+ | unitizer for: a.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > "hello" [1] "hello" unitizer> N > "world" [1] "world" unitizer> N = Finalize Unitizer ============================================================ | You made no changes to the unitizer so there is no need to update it. While | unnecessary, you can force an update by typing O at the prompt. | Exit unitizer ([Y]es, [P]rev, [B]rowse, [R]erun, f[O]rce, [QQ]uit All)? unitizer> Y | unitizer unchanged. +------------------------------------------------------------------------------+ | unitizer for: b.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > 2 + 1 [1] 3 unitizer> Y > 3 + 2 [1] 5 unitizer> R | Toggling re-run mode ON for this unitizer = Finalize Unitizer ============================================================ | You have 1 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | You will IRREVERSIBLY modify 'b.unitizer' by: | - Adding 1 out of 2 new tests | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U] | nreviewed, [R]erun, [QQ]uit All)? unitizer> Y | unitizer updated. +------------------------------------------------------------------------------+ | unitizer for: b.R | +------------------------------------------------------------------------------+ Pass Fail New 1 - 1 ........................... 1 - 1 - New -------------------------------------------------------------------------- | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, | [R]erun, [QQ]uit All, [Q]uit, [H]elp)? | Jumping to test #2 because that was the test under review when test re-run was | requested. > 3 + 2 [1] 5 unitizer> Q | No changes recorded. | unitizer unchanged. +------------------------------------------------------------------------------+ | unitizer for: c.R | +------------------------------------------------------------------------------+ Pass Fail New - - 3 ........................... - - 3 - New -------------------------------------------------------------------------- | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > pi [1] 3.14 unitizer> Y > 2 * pi [1] 6.28 unitizer> R | Toggling re-run mode ON for this unitizer = Finalize Unitizer ============================================================ | You have 2 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | You will IRREVERSIBLY modify 'c.unitizer' by: | - Adding 1 out of 3 new tests | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U] | nreviewed, [R]erun, [QQ]uit All)? unitizer> Y | unitizer updated. +------------------------------------------------------------------------------+ | unitizer for: c.R | +------------------------------------------------------------------------------+ Pass Fail New 1 - 2 ........................... 1 - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [Q]uit, [H]elp)? | Jumping to test #2 because that was the test under review when test re-run was | requested. > 2 * pi [1] 6.28 unitizer> Y > sqrt(pi) [1] 1.77 unitizer> Y = Finalize Unitizer ============================================================ | You will IRREVERSIBLY modify 'c.unitizer' by: | - Adding 2 out of 2 new tests | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)? unitizer> Y | unitizer updated. | Summary of files in common directory '.': | | Pass Fail New | *1. a.R - - 2 | *2. b.R 1 - 1 | $3. c.R ? ? ? | ....................... | ? ? ? | Legend: | * `unitizer` requires review | $ `unitizer` has been modified and needs to be re-run to recompute summary | Type number of unitizer to review, 'A' to review all that require review, 'R' | to re-run all updated unitizer> Q > > # Make sure re-eval all clears all bookmarks > unlink( + list.files(temp.dir, full.names=TRUE, pattern="\\.unitizer$"), + recursive=TRUE + ) > unitizer:::read_line_set_vals(c("A","Q","Y","RR","Y","Q")) > unitize_dir(temp.dir, interactive.mode=TRUE) | Summary of files in common directory '.': | | Pass Fail New | *1. a.R - - 2 | *2. b.R - - 2 | *3. c.R - - 3 | ....................... | - - 7 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> A +------------------------------------------------------------------------------+ | unitizer for: a.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > "hello" [1] "hello" unitizer> Q | No changes recorded. | unitizer unchanged. +------------------------------------------------------------------------------+ | unitizer for: b.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > 2 + 1 [1] 3 unitizer> Y > 3 + 2 [1] 5 unitizer> RR | Toggling re-run mode ON for all loaded unitizers = Finalize Unitizer ============================================================ | You have 1 unreviewed tests; press `B` to browse tests, `U` to go to first | unreviewed test. | You will IRREVERSIBLY modify 'b.unitizer' by: | - Adding 1 out of 2 new tests | Update unitizer and re-run all loaded unitizers ([Y]es, [N]o, [P]rev, [B] | rowse, [U]nreviewed, [R]erun, [QQ]uit All)? unitizer> Y | unitizer updated. | Summary of files in common directory '.': | | Pass Fail New | *1. a.R - - 2 | *2. b.R 1 - 1 | *3. c.R - - 3 | ....................... | 1 - 6 | Legend: | * `unitizer` requires review | Type number of unitizer to review, 'A' to review all that require review unitizer> Q > > unitizer:::read_line_set_vals(NULL) > unlink(temp.dir, recursive=TRUE) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Non-Standard Conditions" -------------------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Issue 272: some conditions don't produce any output, but for `unitizer` we > # consider normally non-test expressions that produce conditions as tests. So > # we need a mechanism for clarifying what happened. > > temp.dir <- tempfile() > temp.file <- file.path(temp.dir, 'a.R') > dir.create(temp.dir) > > unitizer:::read_line_set_vals("Q") > writeLines( + c( + "cond <- simpleCondition('hello')", + "class(cond) <- c('svgchop_unsupported', 'svgchop', class(cond))", + "invisible(signalCondition(cond))" + ), + temp.file + ) > unitize(temp.file, interactive.mode=TRUE) +------------------------------------------------------------------------------+ | unitizer for: a.R | +------------------------------------------------------------------------------+ Pass Fail New - - 1 ........................... - - 1 - New -------------------------------------------------------------------------- | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, | [R]erun, [Q]uit, [H]elp)? > cond <- simpleCondition("hello") > class(cond) <- c("svgchop_unsupported", "svgchop", class(cond)) > invisible(signalCondition(cond)) | Test silently signalled conditions (use e.g. .NEW$conditions[[1]] to inspect): Condition list with 1 condition: 1. svgchop_unsupported: hello unitizer> Q | No changes recorded. | unitizer unchanged. > > unitizer:::read_line_set_vals(NULL) > unlink(temp.dir, recursive=TRUE) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Output Transcript in non-Interactive" ------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Issue 286: don't capture output in non-interactive. > # We need `try` because we're testing what happens when the unitizer fails. > > temp.dir <- tempfile() > temp.file <- file.path(temp.dir, 'a.R') > dir.create(temp.dir) > writeLines('warning("boom")', temp.file) # can't use error b/c try below > old.opt <- options(unitizer.transcript=NULL, unitizer.show.progress=TRUE) > try(unitize(temp.file)) Warning in check_call_stack() : It appears you are running unitizer inside an error handling function such as `withCallingHanlders`, `tryCatch`, or `withRestarts`. This is strongly dis- couraged as it may cause unpredictable behavior from unitizer in the event tests produce conditions / errors. We strongly recommend you re-run your tests outside of such handling functions. Preloads... Loading unitizer data... Parsing tests... Parsing a.R Evaluating tests... warning("boom") Warning in withVisible(warning("boom")) : boom Prepping Unitizers... Warning in history_capt(history, interactive.mode) : Unable to capture history in non-interactive mode. +------------------------------------------------------------------------------+ | unitizer for: a.R | +------------------------------------------------------------------------------+ Pass Fail New - - 1 ........................... - - 1 - New -------------------------------------------------------------------------- | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, | [R]erun, [Q]uit, [H]elp)? > warning("boom") | Test signalled conditions (use e.g. .NEW$conditions[[1]] to inspect): Condition list with 1 condition: 1. Warning: boom | User input required to proceed, but we are in non-interactive mode. | unitizer unchanged. | * New: warning("boom") | in 'a.R' | Newly evaluated tests do not match unitizer (New: 1); see above for more info, | or run in interactive mode. | Running in transcript mode: only stderr text that is also part of a signalled | condition is in the test review section (scroll up to the evaluation section | for the rest). See `transcript` parameter in `?unitize`. Error in unitize_core(test.file.inf, list(store.id.inf), state = state, : Cannot proceed in non-interactive mode. > options(old.opt) > unlink(temp.dir, recursive=TRUE) > > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > # - "Display All Tests in non-Interactive" ------------------------------------- > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ > > # Issue 293: don't stop after first failing test > # We need `try` because we're testing what happens when the unitizer fails. > > temp.dir <- tempfile() > temp.file.a <- file.path(temp.dir, 'a.R') > temp.file.b <- file.path(temp.dir, 'b.R') > dir.create(temp.dir) > writeLines(c("1 + 1", "warning('hello')"), temp.file.a) > writeLines(c("2 + 1", "warning('goodbye')"), temp.file.b) > try(unitize_dir(temp.dir, transcript=FALSE)) Warning in check_call_stack() : It appears you are running unitizer inside an error handling function such as `withCallingHanlders`, `tryCatch`, or `withRestarts`. This is strongly dis- couraged as it may cause unpredictable behavior from unitizer in the event tests produce conditions / errors. We strongly recommend you re-run your tests outside of such handling functions. Warning in history_capt(history, interactive.mode) : Unable to capture history in non-interactive mode. | Summary of files in common directory '.': | | Pass Fail New | *1. a.R - - 2 | *2. b.R - - 2 | ....................... | - - 4 | Legend: | * `unitizer` requires review +------------------------------------------------------------------------------+ | unitizer for: a.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > 1 + 1 [1] 2 > warning("hello") Warning: hello | User input required to proceed, but we are in non-interactive mode. | unitizer unchanged. +------------------------------------------------------------------------------+ | unitizer for: b.R | +------------------------------------------------------------------------------+ Pass Fail New - - 2 ........................... - - 2 - New -------------------------------------------------------------------------- | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)? > 2 + 1 [1] 3 > warning("goodbye") Warning: goodbye | User input required to proceed, but we are in non-interactive mode. | unitizer unchanged. | * New: 1 + 1 | * New: warning("hello") | in 'a.R' | * New: 2 + 1 | * New: warning("goodbye") | in 'b.R' | Newly evaluated tests do not match unitizer (New: 4); see above for more info, | or run in interactive mode. Error in unitize_core(test.files = test.files, store.ids = store.ids, : Cannot proceed in non-interactive mode. > options(old.opt) > unlink(temp.dir, recursive=TRUE) > > > proc.time() user system elapsed 5.23 0.29 12.84