Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing language has no effect when envvar LC_ALL='C.UTF-8' #1925

Closed
tbrown122387 opened this issue Jan 30, 2024 · 8 comments · Fixed by #1879
Closed

Changing language has no effect when envvar LC_ALL='C.UTF-8' #1925

tbrown122387 opened this issue Jan 30, 2024 · 8 comments · Fixed by #1879
Labels
bug an unexpected problem or unintended behavior tests 📘
Milestone

Comments

@tbrown122387
Copy link

I had a lot of tests that started not passing on a Docker container. They continue to work on my local machine. When I print the traceback, it's complaining about some environment variable.

If lr is a ListReporter, then I'm printing lr$results$as_list()[[1]]$results

I assume this is the result of some update. How can I cirumvent this behavior and go back to the old behavior?

<expectation_warning/expectation/condition>
Changing language has no effect when envvar LC_ALL='C.UTF-8'
Backtrace:
     ▆
  1. └─global calcGradesForGradescope("hw1.R", "hw1_test.R")
  2.   └─testthat::test_file(test_file, reporter = lr, env = scriptResults)
  3.     └─testthat:::test_files(...)
  4.       └─testthat:::test_files_serial(...)
  5.         ├─testthat::with_reporter(...)
  6.         │ └─base::tryCatch(...)
  7.         │   └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  8.         │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9.         │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 10.         └─base::lapply(...)
 11.           └─testthat (local) FUN(X[[i]], ...)
 12.             └─testthat::source_file(path, env = env(env), desc = desc, error_call = error_call)
 13.               └─testthat:::test_code(test = NULL, code = exprs, env = env, default_reporter = StopReporter$new())
 14.                 ├─base::tryCatch(...)
 15.                 │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 16.                 │   ├─base (local) tryCatchOne(...)
 17.                 │   │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 18.                 │   └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
 19.                 │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 20.                 │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 21.                 ├─base::withCallingHandlers(...)
 22.                 └─base::eval(code, test_env)
 23.                   └─base::eval(code, test_env)
 24.                     └─testthat::test_that(...) at hw1_test.R:117:1
 25.                       └─testthat:::test_code(desc, code, env = parent.frame(), default_reporter = local_interactive_reporter())
 26.                         └─testthat:::testthat_state_condition(before, after, call = sys.call(-1))
 27.                           └─testthat:::waldo_compare(before, after, x_arg = "before", y_arg = "after")
 28.                             └─testthat:::local_reporter_output()
 29.                               └─reporter$local_user_output(.env)
 30.                                 └─testthat::local_reproducible_output(...)
 31.                                   └─withr::local_language(lang, .local_envir = .env)
 32.                                     └─withr:::check_language_envvar("LC_ALL")

@tbrown122387
Copy link
Author

Adding LC_ALL= at the beginning of the Rscript line in the shell script fixes this, but this seems hacky. Why does test_file care about environment variables?

@torbjorn
Copy link

This is hitting us as well, was this issue ever resolved?

@tbrown122387
Copy link
Author

@torbjorn I received no response from test that. I ended up having to set environment variables on my own to get things working again

@torbjorn
Copy link

We downgraded to withr 2.5.0 for now

@fh-mthomson
Copy link

See also r-lib/withr#254

@torbjorn
Copy link

Seems nothing is happening here and nothing is happening in withr.

If this is a feature and behavior that is intended, could someone from either camp at least offer guidance on how to code or test differently so this warning doesn't break things that shouldn't break?

@hadley hadley added this to the v3.2.2 milestone Oct 22, 2024
@hadley
Copy link
Member

hadley commented Oct 22, 2024

We set these environment variables in an attempt to ensure that you get consistent error message if there are translations present. It looks like we should be able to simplify skip this step if you're not in an environment where translations are possible in the first place.

@hadley hadley added bug an unexpected problem or unintended behavior tests 📘 labels Oct 22, 2024
@hadley
Copy link
Member

hadley commented Oct 22, 2024

Might be fixed by #1879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior tests 📘
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants