@@ -53,6 +53,27 @@ test_that("mplusModel reads existing output", {
5353 expect_equal(nrow(m $ data ), 500 )
5454})
5555
56+ test_that(" mplusModel falls back to basename for missing data file" , {
57+ tmp <- tempdir()
58+ file.copy(testthat :: test_path(" submitModels" , " ex3.1.dat" ), tmp , overwrite = TRUE )
59+ file.copy(testthat :: test_path(" submitModels" , " ex3.1.inp" ), tmp , overwrite = TRUE )
60+ file.copy(testthat :: test_path(" ex3.1.out" ), tmp , overwrite = TRUE )
61+
62+ bad_path <- normalizePath(file.path(tempdir(), " nonexistent" , " path" , " ex3.1.dat" ),
63+ winslash = " /" , mustWork = FALSE )
64+ inp_lines <- readLines(file.path(tmp , " ex3.1.inp" ))
65+ inp_lines <- gsub(" ex3.1.dat" , bad_path , inp_lines , fixed = TRUE )
66+ writeLines(inp_lines , file.path(tmp , " ex3.1.inp" ))
67+ out_lines <- readLines(file.path(tmp , " ex3.1.out" ))
68+ out_lines <- gsub(" ex3.1.dat" , bad_path , out_lines , fixed = TRUE )
69+ writeLines(out_lines , file.path(tmp , " ex3.1.out" ))
70+
71+ mplus_fake <- tempfile(); file.create(mplus_fake )
72+ m <- mplusModel(inp_file = file.path(tmp , " ex3.1.inp" ), read = TRUE , Mplus_command = mplus_fake )
73+ expect_equal(nrow(m $ data ), 500 )
74+ expect_equal(m $ dat_file , file.path(tmp , " ex3.1.dat" ))
75+ })
76+
5677test_that(" mplusModel exposes readModels sections" , {
5778 tmp <- tempdir()
5879 file.copy(testthat :: test_path(" submitModels" ," ex3.1.inp" ), tmp , overwrite = TRUE )
0 commit comments