Skip to content

Commit

Permalink
remote temp dir from comparison string because it is unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Jun 16, 2019
1 parent b46fbf2 commit 2414ddf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 26 additions & 10 deletions tests/testthat/test-public_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ test_that("styler can style directory", {

test_that("styler can style files", {
# just one
capture_output(expect_equivalent(
{
out <- style_file(c(
testthat_file("public-api", "xyzfile", "random-script.R")
), strict = FALSE)
out$changed
},
rep(FALSE, 1)
))
# multiple not in the same working directory
capture_output(expect_equivalent(
{
out <- style_file(c(
Expand Down Expand Up @@ -82,13 +92,13 @@ test_that("messages (via cat()) of style_file are correct", {
temp_path <- copy_to_tempdir(testthat_file(
"public-api", "xyzdir-dirty", "dirty-sample-with-scope-tokens.R"
))
expect_equal_to_reference(
capture.output(
expect_known_value(
gsub(dirname(temp_path), "", capture.output(
style_file(temp_path, scope = "tokens")
),
), fixed = TRUE),
testthat_file(paste0(
"public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-",
ifelse(cli::is_utf8_output(), "utf8", "non-utf8")
ifelse(encoding, "utf8", "non-utf8")
))
)
unlink(dirname(temp_path))
Expand All @@ -97,11 +107,14 @@ test_that("messages (via cat()) of style_file are correct", {
temp_path <- copy_to_tempdir(testthat_file(
"public-api", "xyzdir-dirty", "clean-sample-with-scope-tokens.R"
))
expect_equal_to_reference(
capture.output(style_file(temp_path, scope = "tokens")),
expect_known_value(
gsub(dirname(temp_path), "",
capture.output(style_file(temp_path, scope = "tokens")),
fixed = TRUE
),
testthat_file(paste0(
"public-api/xyzdir-dirty/clean-reference-with-scope-tokens-",
ifelse(cli::is_utf8_output(), "utf8", "non-utf8")
ifelse(encoding, "utf8", "non-utf8")
))
)
unlink(dirname(temp_path))
Expand All @@ -110,11 +123,14 @@ test_that("messages (via cat()) of style_file are correct", {
temp_path <- copy_to_tempdir(testthat_file(
"public-api", "xyzdir-dirty", "dirty-sample-with-scope-spaces.R"
))
expect_equal_to_reference(
capture.output(style_file(temp_path, scope = "spaces")),
expect_known_value(
gsub(dirname(temp_path), "",
capture.output(style_file(temp_path, scope = "spaces")),
fixed = TRUE
),
testthat_file(paste0(
"public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-",
ifelse(cli::is_utf8_output(), "utf8", "non-utf8")
ifelse(encoding, "utf8", "non-utf8")
))
)
unlink(dirname(temp_path))
Expand Down

0 comments on commit 2414ddf

Please sign in to comment.