Skip to content

Commit 7d802e4

Browse files
authored
Fix CI problems (#268)
* correctly protect against non existence * Don't use random port * skip preview tests on CI they are passing but they make CI hang
1 parent becaf85 commit 7d802e4

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/testthat/test-preview.R

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
test_that("quarto_preview default functionality", {
22
skip_if_no_quarto()
33
skip_on_cran()
4+
skip_on_ci()
45

56
tmp_dir <- withr::local_tempdir()
67
withr::local_dir(tmp_dir)
@@ -23,22 +24,29 @@ test_that("quarto_preview default functionality", {
2324
test_that("quarto_preview can change port", {
2425
skip_if_no_quarto()
2526
skip_on_cran()
27+
skip_on_ci()
2628

2729
tmp_dir <- withr::local_tempdir()
2830
withr::local_dir(tmp_dir)
2931
xfun::write_utf8(c("---", "title: Test", "---", "", "# Hello"), "test.qmd")
3032

33+
known_port <- find_port()
3134
expect_no_error({
32-
url <- withr::with_dir(tmp_dir, {
33-
quarto_preview("test.qmd", port = 8888, browse = FALSE, quiet = TRUE)
35+
preview_url <- withr::with_dir(tmp_dir, {
36+
quarto_preview(
37+
"test.qmd",
38+
port = known_port,
39+
browse = FALSE,
40+
quiet = TRUE
41+
)
3442
})
3543
})
3644

3745
# Always clean up
3846
withr::defer(quarto_preview_stop())
3947

40-
if (exists("url")) {
41-
expect_true(grepl("^https?://", url))
42-
expect_true(grepl(":8888", url))
43-
}
48+
skip_if(!exists("preview_url", inherits = FALSE))
49+
skip_if(!is.character(preview_url))
50+
expect_true(grepl("^https?://", preview_url))
51+
expect_true(grepl(sprintf(":%s", known_port), preview_url))
4452
})

0 commit comments

Comments
 (0)