You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written some tests using the testthat framework. I'm working in Rstudio, currently devtools 2.2.0 is installed. When running them with devtools::test() or ctrl + shit + T they pass, running them with devtools::check() or ctrl + shift + E they fail, citing a changed alphabetical order of expected outputs. The failure occurs with "." and "_" being sorted differently, though I have not tried other combinations of symbols/characters.
I have reproduced the issue in the attached minimal package. In essence the code writes a number of variables to an environment and at some point prints all names in that environment. I'm using testthat::expect_known_output() match this printed list with a previous, verified printout stored in "tests/testthat/ref.txt" (produced by running devtools::test() once before).
I realize that this issue may be caused by a lot of different things along the execution paths up to and including the language settings of the host . But as the devtools are my current entry point I'm posting it here first.
I'm running R3.6.1 on Ubuntu 18.04.3 LTS 64bit.
The files/functions as reference point:
print_env.R:
Running these commands either from the console or hotkeys:
devtools::test()
# Loading orderingTest# Testing orderingTest# ✔ | OK F W S | Context# ✔ | 1 | print_env## ══ Results ## OK: 1# Failed: 0# Warnings: 0# Skipped: 0
devtools::check()
# (omited output)# > test_check("orderingTest")# ── 1. Failure: print_env_comparison (@test-print_env.R#3) # Results have changed from known value recorded in 'ref.txt'.# 3/3 mismatches# x[1]: "a.c"# y[1]: "a_b"## x[2]: "a_b"# y[2]: "a_c"## x[3]: "a_c"# y[3]: "a.c"
Obviously I'd expect the test to produce the same result independently on how it is called.
Attached is the minimal package, including the reference output file for the testcase.
The text was updated successfully, but these errors were encountered:
benj919
changed the title
Alphabetical ordering incositent between test() and check() using testthat::expect_known_output()
Alphabetical ordering incosistent between test() and check() using testthat::expect_known_output()
Sep 23, 2019
benj919
changed the title
Alphabetical ordering incosistent between test() and check() using testthat::expect_known_output()
Alphabetical ordering inconsistent between test() and check() using testthat::expect_known_output()
Sep 23, 2019
This is just due to the collation setting, R CMD check always runs with a C locale in the collation, but you are likely using a UTF-8 collation, e.g. here is your example without using devtools at all.
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
lockbot
locked and limited conversation to collaborators
Mar 22, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi All
I have written some tests using the testthat framework. I'm working in Rstudio, currently devtools 2.2.0 is installed. When running them with devtools::test() or ctrl + shit + T they pass, running them with devtools::check() or ctrl + shift + E they fail, citing a changed alphabetical order of expected outputs. The failure occurs with "." and "_" being sorted differently, though I have not tried other combinations of symbols/characters.
I have reproduced the issue in the attached minimal package. In essence the code writes a number of variables to an environment and at some point prints all names in that environment. I'm using testthat::expect_known_output() match this printed list with a previous, verified printout stored in "tests/testthat/ref.txt" (produced by running devtools::test() once before).
I realize that this issue may be caused by a lot of different things along the execution paths up to and including the language settings of the host . But as the devtools are my current entry point I'm posting it here first.
I'm running R3.6.1 on Ubuntu 18.04.3 LTS 64bit.
The files/functions as reference point:
print_env.R:
tests/testthat/test-print_env.R:
Running these commands either from the console or hotkeys:
Obviously I'd expect the test to produce the same result independently on how it is called.
Attached is the minimal package, including the reference output file for the testcase.
Thank you and cheers.
orderingTest.zip
The text was updated successfully, but these errors were encountered: