Skip to content

Commit

Permalink
test with previous dummy qmd
Browse files Browse the repository at this point in the history
  • Loading branch information
CGID (Cervan Girard) authored and CGID (Cervan Girard) committed Nov 14, 2024
1 parent 6a56fa2 commit 730c3ed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 55 deletions.
53 changes: 9 additions & 44 deletions inst/documents/dummy.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ params:
tmpdir: "."
---

```{r setup}
#| label: Setup
#| include: false
```{r setup, include=FALSE}
knitr::opts_chunk$set(
error = TRUE,
warning = TRUE,
Expand All @@ -22,56 +19,22 @@ knitr::opts_chunk$set(
.libPaths(c(character(), params$with_library_paths))
```

```{r}
#| label: Log R
#| eval: !expr grepl("\\.R$", params$script)
#| echo: false
```{r, echo=FALSE, eval=(grepl("\\.R$", params$script))}
knitr::spin_child(params$script)
```

```{r}
#| label: Log Quarto
#| child: !expr params$script
#| eval: !expr grepl("\\.qmd$", params$script)
#| include: !expr grepl("\\.qmd$", params$script)
```

```{r}
#| label: Log Rmarkdown
#| child: !expr params$script
#| eval: !expr grepl("\\.Rmd$", params$script)
#| include: !expr grepl("\\.Rmd$", params$script)
```{r, child = params$script, eval=(grepl("\\.qmd$", params$script))}
```

```{python}
#| label: Log Python
#| file: !expr params$script
#| eval: !expr grepl("\\.py$", params$script)
#| include: !expr grepl("\\.py$", params$script)
```{r, child = params$script, eval=(grepl("\\.Rmd$", params$script))}
```

```{python}
#| label: Python modules
#| file: !expr file.path(params$tmpdir, "python_modules.py")
#| eval: !expr grepl("\\.py$", params$script)
#| echo: false
```{r, child = params$script, eval=(grepl("\\.py$", params$script))}
```

```{r}
#| label: Session info
#| include: false
python_packages <- NULL
if (file.exists(file.path(params$tmpdir, "python_imports.json"))){
python_packages <- whirl:::python_package_info(file.path(params$tmpdir, "python_imports.json"))
}
```{r sessioninfo, include=FALSE}
saveRDS(
object = whirl:::session_info(
approved_folder_pkgs = params$check_approved_folder_pkgs,
approved_url_pkgs = params$check_approved_url_pkgs,
python_packages = python_packages
),
object = whirl:::session_info(params$check_approved_folder_pkgs, params$check_approved_url_pkgs),
file = file.path(params$tmpdir, "session_info.rds")
)
Expand All @@ -81,4 +44,6 @@ if (is.character(params$renv) && params$renv == "yes" | is.logical(params$renv)
file = file.path(params$tmpdir, "renv_status.rds")
)
}
```

22 changes: 11 additions & 11 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ withr::local_envvar(
R_USER_CACHE_DIR = tempfile(),
.local_envir = teardown_env()
)
if (interactive()) { # devtools::test
pkg_path <- "../.."
} else { # R CMD Check
pkg_path <- "../../00_pkg_src/whirl"
}
pak::local_install(
root = pkg_path,
upgrade = FALSE,
dependencies = FALSE,
ask = FALSE
)
# if (interactive()) { # devtools::test
# pkg_path <- "../.."
# } else { # R CMD Check
# pkg_path <- "../../00_pkg_src/whirl"
# }
# pak::local_install(
# root = pkg_path,
# upgrade = FALSE,
# dependencies = FALSE,
# ask = FALSE
# )

# Minimal prints to make it easier to read test output

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-run.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test_that("Run single R script", {
})

test_that("Run multiple R scripts", {
print(test_script(c("success.R", "warning.R", "error.R")))

res <- test_script(c("success.R", "warning.R", "error.R")) |>
run() |>
Expand Down

0 comments on commit 730c3ed

Please sign in to comment.