Skip to content

Commit

Permalink
Try new test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Feb 12, 2024
1 parent 1995fb7 commit cfa3b99
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ jobs:
message("Installing ", length(toinstall)," packages: ", paste0(toinstall, collapse = ","))
install.packages(toinstall,
dependencies = TRUE,
verbose = TRUE, quiet = TRUE
)
#install.packages(toinstall, dependencies = TRUE, verbose = TRUE, quiet = TRUE)
# Update binary
# update.packages(type = "binary")
Expand All @@ -122,7 +119,7 @@ jobs:
devtools::load_all()
# Run the tests
testthat::test_dir("tests/testthat/test_ci")
source("tests/testthat/test_ci/test-new.R")
shell: Rscript {0}

Expand All @@ -131,5 +128,5 @@ jobs:
shell: bash
run: |
# OK :)
cat ./tests/testthat/test_ci/_snaps/full_cff.md >$GITHUB_STEP_SUMMARY
cat ./tests/testthat/test_ci/results.md >$GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions tests/testthat/test_ci/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_snaps
CITATION
allpackages.csv
results.md
61 changes: 61 additions & 0 deletions tests/testthat/test_ci/test-new.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

library(cffr)

installed <- as.data.frame(installed.packages()[, c("Package", "Version")])
installed <- installed[order(installed$Package), ]
# installed <- installed[1:50, ]

Check warning on line 6 in tests/testthat/test_ci/test-new.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=tests/testthat/test_ci/test-new.R,line=6,col=3,[commented_code_linter] Commented code should be removed.

Check notice

Code scanning / lintr

Commented code should be removed. Note test

Commented code should be removed.

rownames(installed) <- seq_len(nrow(installed))

l <- nrow(installed)

dir_path <- "./tests/testthat/test_ci/"
dbcsv <- file.path(dir_path, "allpackages.csv")

# Initial set of packages
write.csv(installed, file = dbcsv, row.names = FALSE)

res <- c()
withcit <- c()
note <- c()
for (i in seq_len(nrow(installed))) {
pkg <- installed[i, ]$Package
# Display some advances
message(
"Testing ", i, "/", nrow(installed),

Check warning on line 25 in tests/testthat/test_ci/test-new.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=tests/testthat/test_ci/test-new.R,line=25,col=4,[indentation_linter] Hanging indent should be 10 spaces but is 4 spaces.

Check notice

Code scanning / lintr

Hanging indent should be 10 spaces but is 4 spaces. Note test

Hanging indent should be 10 spaces but is 4 spaces.
" (", sprintf("%05.02f", i / nrow(installed) * 100), "%) ["
,installed[i, ]$Package, "]")

Check warning on line 27 in tests/testthat/test_ci/test-new.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=tests/testthat/test_ci/test-new.R,line=27,col=2,[indentation_linter] Hanging indent should be 10 spaces but is 2 spaces.

Check notice

Code scanning / lintr

Hanging indent should be 10 spaces but is 2 spaces. Note test

Hanging indent should be 10 spaces but is 2 spaces.

Check notice

Code scanning / lintr

Commas should always have a space after. Note test

Commas should always have a space after.
cit_path <- file.path(find.package(installed[i, ]$Package), "CITATION")


if (file.exists(cit_path)) {
withcit <- c(withcit, TRUE)
} else {
withcit <- c(withcit, FALSE)
}

# Add cffobj
cffobj <- try(
cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE), silent = TRUE)

Check notice

Code scanning / lintr

Hanging indent should be 16 spaces but is 4 spaces. Note test

Hanging indent should be 16 spaces but is 4 spaces.

if(inherits(cffobj, "cff")){

Check notice

Code scanning / lintr

Place a space before left parenthesis, except in a function call. Note test

Place a space before left parenthesis, except in a function call.

Check notice

Code scanning / lintr

There should be a space before an opening curly brace. Note test

There should be a space before an opening curly brace.

Check notice

Code scanning / lintr

There should be a space between a right parenthesis and a body expression. Note test

There should be a space between a right parenthesis and a body expression.
s <- try(cff_validate(cffobj, verbose = FALSE), silent = TRUE)

Check notice

Code scanning / lintr

Indentation should be 4 spaces but is 2 spaces. Note test

Indentation should be 4 spaces but is 2 spaces.
if(!is.logical(s)) s <- FALSE

Check notice

Code scanning / lintr

Place a space before left parenthesis, except in a function call. Note test

Place a space before left parenthesis, except in a function call.

res <- c(res, s)

Check notice

Code scanning / lintr

Indentation should be 4 spaces but is 2 spaces. Note test

Indentation should be 4 spaces but is 2 spaces.
note <- c(note, "ok, cff")
} else {
res <- c(res, FALSE)
note <- c(note, "Other errors")
}
}

installed$with_citation <- withcit
installed$is_ok <- res
installed$note <- note


outmd <- file.path(dir_path, "results.md")
capture.output(knitr::kable(installed), file = outmd)

Check notice

Code scanning / lintr

Trailing blank lines are superfluous. Note test

Trailing blank lines are superfluous.

Check notice

Code scanning / lintr

Trailing blank lines are superfluous. Note test

Trailing blank lines are superfluous.

0 comments on commit cfa3b99

Please sign in to comment.