From f351dfda4e5007cf570b892430991e19e0ee762d Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 21 Mar 2024 07:39:17 +0100 Subject: [PATCH] Fix failing test on R-devel (#2528) * to kick off CI/CD * fix failing test * Test robust across R versions * with_content_to_parse doesn't get parent env variables? * revert changes to cran comments * better test * useBytes=TRUE --------- Co-authored-by: Michael Chirico --- tests/testthat/test-get_source_expressions.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-get_source_expressions.R b/tests/testthat/test-get_source_expressions.R index 055c4d7c4..5122d475c 100644 --- a/tests/testthat/test-get_source_expressions.R +++ b/tests/testthat/test-get_source_expressions.R @@ -93,8 +93,12 @@ test_that("Multi-byte character truncated by parser is ignored", { skip_if_not_utf8_locale() # \U2013 is the Unicode character 'en dash', which is # almost identical to a minus sign in monospaced fonts. - with_content_to_parse("y <- x \U2013 42", { - expect_identical(error$message, "unexpected input") + content <- "y <- x \U2013 42" + # message is like ':1:8: unexpected invalid token\n1: ...' + with_content_to_parse(content, { + base_msg <- conditionMessage(tryCatch(str2lang(content), error = identity)) + # Just ensure that the captured message is a substring of the parser error, #2527 + expect_true(grepl(error$message, base_msg, fixed = TRUE, useBytes = TRUE)) expect_identical(error$column_number, 8L) }) })