Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ jobs:
strategy:
fail-fast: false
matrix:
test-suite: [ renderer, compiler, CRAN ]
test-suite: [ R_coverage, JS_coverage, CRAN ]

name: Test Suite ${{ matrix.test-suite }}
env:
TEST_SUITE: ${{ matrix.test-suite }}
GITHUB_PAT: ${{ secrets.PAT_GITHUB }}
GH_ACTION: "ENABLED"
COLLECT_COVERAGE: "TRUE"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/checkout@v3
Expand All @@ -39,13 +38,13 @@ jobs:
run: git config --global user.email toby.hocking@r-project.org

- name: Setup Node.js
if: matrix.test-suite == 'renderer'
if: matrix.test-suite == 'JS_coverage'
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Node.js dependencies
if: matrix.test-suite == 'renderer'
if: matrix.test-suite == 'JS_coverage'
run: |
npm install v8-to-istanbul
echo "Node modules installed"
Expand All @@ -54,15 +53,16 @@ jobs:
run: |
if [ "$TEST_SUITE" == "CRAN" ]; then
bash build.sh
elif [ "$TEST_SUITE" == "compiler" ]; then
elif [ "$TEST_SUITE" == "JS_coverage" ]; then
echo "Running testthat with JS coverage collection..."
Rscript -e "source('tests/testthat.R', chdir = TRUE)"
Rscript -e 'covr::codecov(quiet = TRUE)'
else
Rscript -e "source('tests/testthat.R', chdir = TRUE)"
echo "Running testthat with R coverage collection..."
Rscript -e 'covr::codecov(quiet = FALSE, type = "tests", test_files = "tests/testthat.R", flags = "r")'
fi

- name: Convert JS coverage to Istanbul format
if: matrix.test-suite == 'renderer'
if: matrix.test-suite == 'JS_coverage'
run: |
if [ -f "tests/testthat/js-coverage.json" ]; then
echo "Converting JS coverage to LCOV format..."
Expand All @@ -73,7 +73,7 @@ jobs:
fi

- name: Upload JS coverage to Codecov
if: matrix.test-suite == 'renderer'
if: matrix.test-suite == 'JS_coverage'
run: |
if [ -f "coverage-istanbul.json" ]; then
curl -Os https://uploader.codecov.io/latest/linux/codecov
Expand Down
15 changes: 7 additions & 8 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ setwd("testthat")
source("helper-functions.R")
source("helper-HTML.R")
source("helper-plot-data.r")
filter <- Sys.getenv("TEST_SUITE")
gh.action <- Sys.getenv("GH_ACTION")
collect.coverage <- Sys.getenv("COLLECT_COVERAGE", "FALSE") == "TRUE" && filter=="renderer"
if(filter == ""){
filter <- NULL
}
is_js_coverage <- Sys.getenv("TEST_SUITE") == "JS_coverage"
message(gh.action)
tests_init()
# Start coverage if enabled
coverage_active <- FALSE
if(collect.coverage) {
if(is_js_coverage) {
coverage_active <- start_js_coverage()
if(coverage_active) {
message("JS coverage collection started")
}
}
# Run tests
tests_run(filter=filter)
message("\n=== Running COMPILER tests ===")
tests_run(filter = "compiler")
message("\n=== Running RENDERER tests ===")
tests_run(filter = "renderer")
Comment on lines +21 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

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

sometimes interactively we want to set filter to something else.
so I wonder if we need to separate these two?
why not tests_run() (without filter arg) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

running tests_run() without a filter would also run two other test files that I believe are currently not in working condition and produce errors:

Do you think we should remove test-tt-inter.R?

Once these test files are free of errors, we can update this part of the code to use tests_run() without the separate renderer and compiler filters, if you prefer that approach instead of printing the separation like it currently does.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes please remove test-tt-inter.R

Copy link
Collaborator

Choose a reason for hiding this comment

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

about the shiny tests, can you please review #209 ?

Copy link
Contributor Author

@suhaani-agarwal suhaani-agarwal Jul 29, 2025

Choose a reason for hiding this comment

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

about the shiny tests, can you please review #209 ?

Yes, I’ve gone through the PR and the related issue and dropped some comments about optimising it and aligning it better with the existing tests. Please take a look when you're free , and please let me know if I’ve misunderstood anything or if anything needs clarification!

# Save coverage and cleanup
if(coverage_active) {
stop_js_coverage()
}
tests_exit()
tests_exit()
1 change: 1 addition & 0 deletions tests/testthat/test-compiler-ghpages.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ test_that("animint2pages() returns list of meta-data", {
expect_Capture(update_list)
})

# This test is skipped under covr coverage collection due to environment manipulation.
test_that("animint2pages raises an error if no GitHub token is present", {
if (identical(Sys.getenv("R_COVR"), "true")) skip("Skip on covr: environment manipulation not supported")
env.names <- c("GITHUB_PAT", "GITHUB_PAT_GITHUB_COM")
Expand Down
72 changes: 0 additions & 72 deletions tests/testthat/test-tt-inter.R

This file was deleted.