Skip to content

Commit 3e109d8

Browse files
test: harden workspace setup assertions in run tests
Agent-Logs-Url: https://github.com/NIDAP-Community/MOSuite-write-moo-properties/sessions/172d71fb-e0ee-4c69-9192-c4f33e3baec3 Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
1 parent f31ca70 commit 3e109d8

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

tests/testthat/test-main.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,31 @@ assert_properties_output <- function(output_dir, label = "") {
3838
}
3939

4040
prepare_main_and_mosuite <- function(repo_root, code_dir) {
41-
file.copy(
41+
copied_main <- file.copy(
4242
file.path(repo_root, "code", "main.R"),
4343
file.path(code_dir, "main.R")
4444
)
45-
file.copy(
45+
copied_run <- file.copy(
4646
file.path(repo_root, "code", "run"),
4747
file.path(code_dir, "run")
4848
)
49-
file.copy(
49+
copied_mosuite <- file.copy(
5050
file.path(repo_root, "code", "MOSuite"),
5151
code_dir,
5252
recursive = TRUE
5353
)
54+
stopifnot(copied_main, copied_run, copied_mosuite)
5455
main_file <- file.path(code_dir, "main.R")
56+
load_all_call <- "devtools::load_all('/code/MOSuite')"
5557
main_lines <- readLines(main_file)
56-
main_lines <- gsub(
57-
"devtools::load_all\\('/code/MOSuite'\\)",
58+
updated_lines <- gsub(
59+
load_all_call,
5860
"devtools::load_all('MOSuite')",
59-
main_lines
61+
main_lines,
62+
fixed = TRUE
6063
)
61-
writeLines(main_lines, main_file)
64+
stopifnot(!identical(main_lines, updated_lines))
65+
writeLines(updated_lines, main_file)
6266
}
6367

6468
test_that("code/run executes successfully with default CLI arguments", {

0 commit comments

Comments
 (0)