Open bedantaguru opened 5 years ago
Easiest solution for shinytest is to use brio, replacing existing calls to write_ut8()
and readLines()
. Needs to wait on #336 so it's easy to test that the change actually works.
brio isn't a viable solution because it always adds a trailing newline when writing. This is probably desired behaviour, but it's change from the current writer, so would invalidate all existing snapshots.
This probably requires someone with a windows computer to figure out; I've given up (see my attempts in the attached PR). Alternatively, I think a better long term approach would be to read the JSON back into R and perform the comparisons with waldo.
Are there any news on this? I am developing an app in a package and am using gitlab ci mainly based on a windows ci server, windows docker image and windows runner. I have put the auto crlf to false, however my tests still fail. I cannot find a diff when manually inspecting the test artifacts (they both have \n as eol), also the check output gives me no diff:
== Failed tests ================================================================
-- Failure (test-app-function.R:60:1): (code run outside of `test_that()`) -----
Not all shinytest scripts passed for apps/my_app_name: full_run_register, login_screen, select_run
Diff output:
==== full_run_register ====
==== login_screen ====
==== select_run ====
If this is expected, use `snapshotUpdate('apps/my_app_name')` to update
While at the same time reporting a diff in every single json:
Running full_run_register.R login_screen.R select_run.R
==== Comparing full_run_register...
Differences detected between full_run_register-current/ and full_run_register-expected/:
Name Status
001.json != Files differ
002.json != Files differ
003.json != Files differ
004.json != Files differ
005.json != Files differ
006.json != Files differ
007.json != Files differ
008.json != Files differ
009.json != Files differ
010.json != Files differ
011.json != Files differ
==== Comparing login_screen...
Differences detected between login_screen-current/ and login_screen-expected/:
Name Status
001.json != Files differ
002.json != Files differ
==== Comparing select_run...
Differences detected between select_run-current/ and select_run-expected/:
Name Status
001.json != Files differ
002.json != Files differ
003.json != Files differ
I am using portable R (4.1.2) and app + dev dependencies from MRAN date 28.02.2022. I am actually developing on windows for windows, however we might have to cover unix as well in the near future.
Thank you for your effort!
I spent some time to figure out, where the supposed diff was coming from and it turns out that fc.exe - the windows diff application - returns the correct exit code (i.e. no difference), while diff.exe from rtools detects some difference at the end of the JSON (I couldn't figure out what it is). Not sure if this has any other implications, but it might be worthwhile to have fc as the default diff tool on a windows platform. It does the trick for me if I change which_diff() like so:
which_diff <- function() {
path <- Sys.which("fc")
if (path == "")
path <- Sys.which("diff")
if (path != "")
return(path)
abort("No program named `diff` or `fc` found in path.")
}
Best, Milena
Thanks a lot for this wonderful package.
I have used this to test a few shiny modules developed in my package. I have noticed a thing about json comparison which is described below
Problem : If I record the test and then push the same in GitHub I'm getting messages like
Full log here
The tests are passed locally. Then I clone the same GitHub project in another folder now the test fails
Here is a reproducible example
Created on 2019-07-31 by the reprex package (v0.3.0)