Skip to content

Use expect_no_warning() - #1248

Merged
IndrajeetPatil merged 1 commit into
mainfrom
use-expect-no-warning
Dec 9, 2024
Merged

IndrajeetPatil merged 1 commit into
mainfrom
use-expect-no-warning

Conversation

@IndrajeetPatil

@IndrajeetPatil IndrajeetPatil commented Dec 9, 2024 •

Copy link
Copy Markdown
Collaborator

Instead of expect_warning() + NA combo.

Automated via:

replace_multiline <- function(dir = "tests/") {
  files <- list.files(dir, pattern = "\\.R$", full.names = TRUE, recursive = TRUE)
  
  pattern <- "(?s)expect_warning\\((.*?)\\,\\s*NA\\)"
  replacement <- "expect_no_warning(\\1)"
  
  for (f in files) {
    txt <- xfun::read_utf8(f)
    content <- paste(txt, collapse = "\n")
    new_content <- gsub(pattern, replacement, content, perl = TRUE)
    
    if (!identical(content, new_content)) {
      new_txt <- unlist(strsplit(new_content, "\n", fixed = TRUE))
      xfun::write_utf8(new_txt, f)
      message("Modified: ", f)
    }
  }
  
  invisible(NULL)
}

replace_multiline("tests/")

Instead of `expect_warning()` + `NA` combo
@github-actions

github-actions Bot commented Dec 9, 2024

Copy link
Copy Markdown
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 0d4cc51 is merged into main:

  • ✔️cache_applying: 165ms -> 165ms [-3.08%, +2.47%]
  • ✔️cache_recording: 559ms -> 559ms [-1.25%, +1.23%]
  • ✔️without_cache: 1s -> 997ms [-0.86%, +0.05%]

Further explanation regarding interpretation and methodology can be found in the documentation.

@lorenzwalthert lorenzwalthert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you do it yourself or instruct chatGPT or similar to do this? 😄

@IndrajeetPatil

Copy link
Copy Markdown
Collaborator Author

I started with a regex that didn't work and ChatGPT took it from there 😈

@IndrajeetPatil
IndrajeetPatil merged commit 4e3bc30 into main Dec 9, 2024
@IndrajeetPatil
IndrajeetPatil deleted the use-expect-no-warning branch December 9, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants