diff --git a/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 b/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 index 3441b1cd2..fadecc7c0 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 and b/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 differ diff --git a/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-utf8 b/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-utf8 index 937bd0eb7..0bdc7d316 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-utf8 and b/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-utf8 differ diff --git a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-non-utf8 b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-non-utf8 index 9e341c81c..a08b5db80 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-non-utf8 and b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-non-utf8 differ diff --git a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-utf8 b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-utf8 index 6ed173898..50f4ced6c 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-utf8 and b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-utf8 differ diff --git a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-non-utf8 b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-non-utf8 index 61f66a365..afb59c6f8 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-non-utf8 and b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-non-utf8 differ diff --git a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 index bf209814d..76e4b6f9e 100644 Binary files a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 and b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 differ diff --git a/tests/testthat/test-public_api.R b/tests/testthat/test-public_api.R index 062bdf1e8..7489bf290 100644 --- a/tests/testthat/test-public_api.R +++ b/tests/testthat/test-public_api.R @@ -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( @@ -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)) @@ -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)) @@ -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))