-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1031 from r-lib/issue-1027
Run some tests sequentially
- Loading branch information
Showing
6 changed files
with
64 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
library(testthat) | ||
library(styler) | ||
test_check("styler") # checks multiple files, in parallel | ||
|
||
test_check("styler") | ||
# checks file one by one, not parallel | ||
Sys.setenv(STYLER_TEST_IS_TRULY_PARALLEL = FALSE) | ||
test_file("testthat/test-cache-high-level-api.R") | ||
test_file("testthat/tests-cache-require-serial.R") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
test_that("top-level test: Caches top-level expressions efficiently on style_text()", { | ||
local_test_setup(cache = TRUE) | ||
text <- test_path("cache-with-r-cache/mlflow-1-in.R") %>% | ||
readLines() | ||
benchmark <- system.time(text_styled <- as.character(style_text(text))) | ||
expect_equal(text, text_styled) | ||
full_cached_benchmark <- system.time(text_styled2 <- as.character(style_text(text_styled))) | ||
expect_equal(text, text_styled2) | ||
|
||
# modify one function declaration | ||
text_styled[2] <- gsub(")", " )", text_styled[2], fixed = TRUE) | ||
partially_cached_benchmark <- system.time( | ||
text_cached_partially <- as.character(style_text(text_styled)) | ||
) | ||
expect_equal(text, text_cached_partially) | ||
cache_deactivate() | ||
not_cached_benchmark <- system.time( | ||
text_not_cached <- as.character(style_text(text_styled)) | ||
) | ||
expect_equal(text, text_not_cached) | ||
|
||
skip_on_cran() | ||
skip_on_covr() | ||
expect_lt( | ||
partially_cached_benchmark["elapsed"] * 2.4, | ||
not_cached_benchmark["elapsed"] | ||
) | ||
expect_lt(full_cached_benchmark["elapsed"] * 45, benchmark["elapsed"]) | ||
}) | ||
|
||
|
||
test_that("roxzgen code examples are written to cache as whole expressions bring speedgain", { | ||
skip_on_cran() | ||
local_test_setup(cache = TRUE) | ||
text <- readLines(test_path("cache-with-r-cache/roxygen-cache-1.R")) | ||
first <- system.time(styled <- style_text(text)) | ||
# don't use full cache, only roxygen cache | ||
styled[1] <- "#' This is a nother text" | ||
second <- system.time(style_text(styled)) | ||
expect_gt(first["elapsed"], 4 * second["elapsed"]) | ||
}) |