From 71db246d5cddd7e03cfc913b05fed0c07f41e4ea Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Sun, 28 Aug 2022 19:17:12 +0200 Subject: [PATCH] unit test fix --- .github/workflows/check-pr.yaml | 3 ++ .github/workflows/check.yaml | 1 + .github/workflows/codecovr.yaml | 42 ++++++---------------------- .github/workflows/lintr.yaml | 29 ++++++------------- DESCRIPTION | 4 +-- NEWS.md | 2 +- R/first_isolate.R | 2 +- R/mo.R | 12 +++++--- data-raw/_install_deps.R | 1 - data-raw/_pre_commit_hook.R | 5 ++++ data-raw/microorganisms.old.dta | Bin 2125139 -> 2125139 bytes data-raw/microorganisms.old.feather | Bin 580522 -> 579858 bytes data-raw/microorganisms.old.md5 | 2 +- data-raw/microorganisms.old.parquet | Bin 469907 -> 469183 bytes data-raw/microorganisms.old.rds | Bin 212828 -> 212840 bytes data-raw/microorganisms.old.sas | Bin 2191360 -> 2191360 bytes data-raw/microorganisms.old.sav | Bin 1348687 -> 1348687 bytes data-raw/microorganisms.old.xlsx | Bin 503125 -> 503125 bytes data/microorganisms.codes.rda | Bin 25888 -> 23456 bytes data/microorganisms.old.rda | Bin 212716 -> 212732 bytes inst/tinytest/test-_misc.R | 2 +- inst/tinytest/test-ab_property.R | 6 ++-- inst/tinytest/test-count.R | 2 +- inst/tinytest/test-data.R | 1 - inst/tinytest/test-first_isolate.R | 4 +-- inst/tinytest/test-proportion.R | 2 +- tests/tinytest.R | 5 ++-- 27 files changed, 51 insertions(+), 74 deletions(-) diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index 0a51be69..f91b8bca 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -32,6 +32,9 @@ name: R-code-check-PR jobs: R-code-check-PR: + # do not run if we are the authors - the other checks will already run + if: ${{ github.event.comment.author_association != 'MEMBER' && github.event.comment.author_association != 'OWNER' }} + runs-on: ${{ matrix.config.os }} continue-on-error: ${{ matrix.config.allowfail }} diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 56f463fc..bec95ebd 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -131,6 +131,7 @@ jobs: _R_CHECK_LENGTH_1_LOGIC2_: verbose # during 'R CMD check', R_LIBS_USER will be overwritten, so: R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} + # this is a required value to run the unit tests: R_RUN_TINYTEST: true run: | cd .. diff --git a/.github/workflows/codecovr.yaml b/.github/workflows/codecovr.yaml index cf935069..b0bafc5a 100644 --- a/.github/workflows/codecovr.yaml +++ b/.github/workflows/codecovr.yaml @@ -33,54 +33,30 @@ name: code-coverage jobs: code-coverage: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} steps: - uses: actions/checkout@v3 + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-r@v2 with: r-version: release - - - uses: r-lib/actions/setup-pandoc@v2 - # with: - # pandoc-version: '2.7.3' # The pandoc version to download (if necessary) and use. + # use RStudio Package Manager to quickly install packages + use-public-rspm: true - - name: Query dependencies - # this will change once a week, so it will cache dependency updates - run: | - writeLines(paste(format(Sys.Date(), "week %V %Y"), sprintf("R-%i.%i", getRversion()$major, getRversion()$minor)), ".github/week-R-version") - shell: Rscript {0} - - - name: Restore cached R packages - # this step will add the step 'Post Restore cached R packages' on a succesful run - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ hashFiles('.github/week-R-version') }}-v4 - - - name: Unpack AMR and install R dependencies - run: | - tar -xf data-raw/AMR_latest.tar.gz - Rscript -e "source('data-raw/_install_deps.R')" - shell: bash - - - name: Show session info - run: | - options(width = 100) - utils::sessionInfo() - as.data.frame(utils::installed.packages())[, "Version", drop = FALSE] - shell: Rscript {0} + extra-packages: any::covr - name: Test coverage env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }} R_RUN_TINYTEST: true run: | - install.packages("covr", repos = "https://cran.rstudio.com/") - library(AMR) - library(tinytest) x <- covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/translate.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R")) print(x) shell: Rscript {0} diff --git a/.github/workflows/lintr.yaml b/.github/workflows/lintr.yaml index 8f302eed..fecc0d56 100644 --- a/.github/workflows/lintr.yaml +++ b/.github/workflows/lintr.yaml @@ -33,34 +33,23 @@ name: lintr jobs: lintr: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-r@v2 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + r-version: release + # use RStudio Package Manager to quickly install packages + use-public-rspm: true - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("lintr") - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::lintr - name: Lint run: lintr::lint_package(linters = lintr::with_defaults(line_length_linter = NULL, trailing_whitespace_linter = NULL, object_name_linter = NULL, cyclocomp_linter = NULL, object_length_linter = lintr::object_length_linter(length = 50L)), exclusions = list("R/aa_helper_pm_functions.R")) diff --git a/DESCRIPTION b/DESCRIPTION index dc3381d1..527ce06f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.1.9034 +Version: 1.8.1.9039 Date: 2022-08-28 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) @@ -42,7 +42,7 @@ Suggests: rvest, tinytest, xml2 -VignetteBuilder: knitr +VignetteBuilder: knitr,rmarkdown URL: https://msberends.github.io/AMR/, https://github.com/msberends/AMR BugReports: https://github.com/msberends/AMR/issues License: GPL-2 | file LICENSE diff --git a/NEWS.md b/NEWS.md index 9050d52d..55ee8c17 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.1.9034 +# AMR 1.8.1.9039 ### New * EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations. diff --git a/R/first_isolate.R b/R/first_isolate.R index 869e9fb9..e0eb7615 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -529,7 +529,7 @@ first_isolate <- function(x = NULL, } if (!is.null(col_icu)) { if (icu_exclude == TRUE) { - message_("Excluding ", format(sum(!col_icu, na.rm = TRUE), big.mark = ","), " isolates from ICU.", + message_("Excluding ", format(sum(col_icu, na.rm = TRUE), big.mark = ","), " isolates from ICU.", add_fn = font_black, as_note = FALSE ) diff --git a/R/mo.R b/R/mo.R index 952d0dd0..968a8f23 100755 --- a/R/mo.R +++ b/R/mo.R @@ -204,12 +204,12 @@ as.mo <- function(x, )) } + reference_df <- repair_reference_df(reference_df) if (!is.null(reference_df) && check_validity_mo_source(reference_df) && isFALSE(Becker) && isFALSE(Lancefield) && - all(x %in% unlist(reference_df), na.rm = TRUE)) { - reference_df <- repair_reference_df(reference_df) + all(x %in% reference_df[, 1, drop = TRUE], na.rm = TRUE)) { suppressWarnings( y <- data.frame(x = x, stringsAsFactors = FALSE) %pm>% pm_left_join(reference_df, by = "x") %pm>% @@ -221,6 +221,7 @@ as.mo <- function(x, y <- x } else { # will be checked for mo class in validation and uses exec_as.mo internally if necessary + y <- mo_validate( x = x, property = "mo", Becker = Becker, Lancefield = Lancefield, @@ -420,7 +421,7 @@ exec_as.mo <- function(x, } # all empty - if (all(identical(trimws(x_input), "") | is.na(x_input) | length(x) == 0)) { + if (all(identical(trimws(x_input), "") | is.na(x_input) | length(x) == 0, na.rm = TRUE)) { if (property == "mo") { return(set_clean_class(rep(NA_character_, length(x_input)), new_class = c("mo", "character") @@ -428,7 +429,7 @@ exec_as.mo <- function(x, } else { return(rep(NA_character_, length(x_input))) } - } else if (all(x %in% reference_df[, 1, drop = TRUE][[1]])) { + } else if (all(x %in% reference_df[, 1, drop = TRUE], na.rm = TRUE)) { # all in reference df colnames(reference_df)[1] <- "x" suppressWarnings( @@ -2357,6 +2358,9 @@ replace_ignore_pattern <- function(x, ignore_pattern) { } repair_reference_df <- function(reference_df) { + if (is.null(reference_df)) { + return(NULL) + } # has valid own reference_df reference_df <- reference_df %pm>% pm_filter(!is.na(mo)) diff --git a/data-raw/_install_deps.R b/data-raw/_install_deps.R index f22b7aea..d0529fd9 100644 --- a/data-raw/_install_deps.R +++ b/data-raw/_install_deps.R @@ -26,7 +26,6 @@ # some old R instances have trouble installing tinytest, so we ship it too install.packages("data-raw/tinytest_1.3.1.tar.gz", dependencies = c("Depends", "Imports", "LinkingTo")) install.packages(getwd(), repos = NULL, type = "source") -# install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE) pkg_suggests <- gsub( "[^a-zA-Z0-9]+", "", diff --git a/data-raw/_pre_commit_hook.R b/data-raw/_pre_commit_hook.R index e744e285..0eea76f5 100644 --- a/data-raw/_pre_commit_hook.R +++ b/data-raw/_pre_commit_hook.R @@ -475,6 +475,11 @@ rm(current_globalenv) devtools::load_all(quiet = TRUE) +# Update URLs ------------------------------------------------------------- +usethis::ui_info("Checking URLs for redirects") +invisible(capture.output(urlchecker::url_update())) + + # Document pkg ------------------------------------------------------------ usethis::ui_info("Documenting package") suppressMessages(devtools::document(quiet = TRUE)) diff --git a/data-raw/microorganisms.old.dta b/data-raw/microorganisms.old.dta index 4e7a735855bb046707d3096ee5b45f7e54ee3a8d..552c99a23461c98009f843122ed75e0e8ac96974 100644 GIT binary patch delta 127 zcmWN=xedZV002Rm*Zju(|CN9*0y3&0Aw?o}u+oM!LluP1s0K!w>RTq&|Ld8>Q@B2E zAs%B4#raZ{VuCfSV*{Jm!ZxPZ!7lc&j{_Xy2s0dGjuV{X4ClDOC9ZId8{Fa!_jq_4 GKKCDifG-&U delta 127 zcmWN=xedZV002Rm|Hs(;@0DQA86{8)B10l|u+oM!LluP1s0K!w`dcOS|Ld6+Ww<`> zAr>))b9srCm|z2&*upk;u!}wH;{b;^!ZA*8iYd-8!yMMU*!DY%78ser4r0b0hxs13> zfg}(Dr9tWpO^vw>4Y*PgOA__ciV|~EfjlE5Ia97YpkOhIdQ-0CoW$Z{E+bPDuxTb> z7KjJKU^7e&!PWppA=X&bbETE$dl1x2Z4i8-lx z$v}-jTaZmRLQ1LxF+NP3S1zD1$+k6^k3IGdW a1}yw=#7{hpA_y3!u=wHX0Ok)!egObe7MtGy diff --git a/data-raw/microorganisms.old.md5 b/data-raw/microorganisms.old.md5 index ce38bc35..ad0f168b 100644 --- a/data-raw/microorganisms.old.md5 +++ b/data-raw/microorganisms.old.md5 @@ -1 +1 @@ -19af89838b60bc8549d4474609629e8d +b57c9cc7380a233a2616a80e8e904a81 diff --git a/data-raw/microorganisms.old.parquet b/data-raw/microorganisms.old.parquet index 2abfbd2c5d04ce810ddafb7ff516287f1ec735a7..b8234690a9779bf129235f22da3872f1e7febef8 100644 GIT binary patch delta 426 zcmbPyU1tA9nT8g|7N!>F7M2#)7Pc+yf7I$_BzPQyg8aj+ijy-^a}yC?5e+4<|i{)oy8D^7AZ%}5FlOH0ZP zGX@*s3({s0=;#y(@~1n{Fh{VNKsz8_0;&oO1&0&Z^T^%+8Q>menB-nj8X0bw12zvR bkF3?v(bkqhVtR}=yFSMkW(I};#~?!haD#Ux delta 1142 zcmZ8f&2G~`5N->!XvG6Wq6bcZ5IeRL4C{AiS7jpX^GEaj9|!-Q z=dTO9SrW5RUS@M{oc!>0TEY&j?ua)mQ~-FX;)FUv?+3kC+=u%V}|EM z4O@d=y*jmq`T4*xji%OyO!p!rHzdukaxKAxp^R9EF5F9CG`mtda7)yPQCt>6+u%Ax zncluy#)Y41rwzPsq}Wu7HHf#WQC9QN;!ZuCc1<2^0IBAU!k(GNPFR~*os+5c!QFU) z)^x*8xW$K2f-$LUrhyacl#80VUmX9+x_GL=Xpr~LTA6L0^In}^x&}*XsNXqforyDC zzEVtsrln+J8niWOWJ*NGg%D_0iX;y@KuQSQ(k4bo2cZ=J_v}3Ag|$4kOxd> z6cJjnRA|mHRRx`DO$bF1#D!)AMZ;amEVB#2B~njLxA`PdAv$4k6Af?t*;nG%3N)nz z*fB~N#n%NT0m@F26;;3feR1&g8A1TouoF9Vl7~SqJ#NkV{PIA0{A+(_=Mq}{KZhzu Avj6}9 diff --git a/data-raw/microorganisms.old.rds b/data-raw/microorganisms.old.rds index 3c56245059781781bc94a69e7fa2b307fb229c40..5d01dc504a5e7f8ec316b13caa9378baa1d45034 100644 GIT binary patch delta 155 zcmV;M0A&B%{tW2;41k0Iv;rv519xv9w=2*ByKaA#QUM-8ub4}_wUSuQlm16_KGqv+ zVU5Ohp)|$_IL6_CCN=cxGIa_#XGFH|Vb3KN@^m>VO%Qn#QyDR1>^Naaqr>}yRhFkn zf83^G@@x1^502EtL_5cC5{tUU+Pm^87f<7<}ivj=u00045TFnJLU;qFB diff --git a/data-raw/microorganisms.old.sas b/data-raw/microorganisms.old.sas index 5d9891bb9b356b8b7258e7d19842131dbb5651c7..ee9632b756cd9e8d765343082258781d64d4948b 100644 GIT binary patch delta 125 zcmWN?yA6T>06;-d6a{~Xihpzz7hn}TYb;*R7W6N%cM%gS=aAxZ^_Q^jG;P}c9-mtf zyt|)bh&}9MgaaI6j3XRlf+ z5(Mw|MhvloU5v1YeT;E{LrgHm5sqH%K!iX diff --git a/data-raw/microorganisms.old.sav b/data-raw/microorganisms.old.sav index fd371edf49d1cb93d53e18cf308b713e116d6239..0665830674866b434c307b7d753b9d966c437f37 100644 GIT binary patch delta 96 zcmV~$D-wcG06@_Z@&83#09$ykAdJN=knLoHUBm4%?!ZL3k#(>o&KbIT=<4qyi`V@A wYVsIES%snsW&6Cf@AM;1Fu^INIKw$EaEU8i;|905!#y7Gh#8*n+?Y-NG$BNxV^*;tY~iO9IWIyM$k= diff --git a/data-raw/microorganisms.old.xlsx b/data-raw/microorganisms.old.xlsx index 7e9540672a3f802b8de804e7192ac59d1310895c..ed658de34b6af5e9a13c6dbe151051abf9fab64f 100644 GIT binary patch delta 586 zcmcb5OYZ6|IlcgIW)=|!4h{|m%~>*`8~NlJSwM`f3Hd>_16e+Gm@`wNO;1dQ1AZ+ZX$0y!V-2>vZ7S%~=~3sYpgV zEy*@Ft&GzBqVAu$)q*eWoy-}wEV|IhC_Qmg z)5ZAwmV^)Y8yzL*TIaZj-~aAvFIl50xLE)6@8gO!_ii0l6rJFfaWs@cGB$%}pCiNS zzzdV(7uvj6IhLB0bhl~W&G}OQyB=A;5oECPo>+0`_mvy{pKNySjn?%Do*FuJ`sF>d z*4^mYtdo5%ZGHRQ^v}Huo{O5t2Y9n{OjN0RDapvdpvA<%fEt*aNpq kgtd1yyB&n}e>F^<)f$*d)oa)-A+kHxu=_$-oNL*A0JA6J1^@s6 delta 586 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 diff --git a/data/microorganisms.old.rda b/data/microorganisms.old.rda index d3a1c6c86b5865387b6422370c5156b1d60fb5ec..a42d6023f9ddcad8d0bd344ebe5b820f4d6de38a 100644 GIT binary patch delta 162 zcmV;T0A2s={S5s541k0Iv;r&81F&wbw=U2EMQ(qcuDNh$nlA7c8AbDxOtQ|{m^2!5 z%HT>Ix|;4)kau!B3bz)RAO;Dm!|qsyAboTx3!>1ZLbn_s(Zi3%FVley67?RtXQ`*^ zaC|8@l&^mcp@UXAURBPWu~(+Th4oLK z>fzL*uzD22B&9v!R3=ggVi3S{IUq$R0abjhsX!!{p&~ai*s~;aw_5=^gx)NKeM)fR zr>hy|n7cABy-s9{_Y4g?rvLx|2pe)u00GDS4CK~NVV5APJ}?c70ssI200CKAQ&Bq@ diff --git a/inst/tinytest/test-_misc.R b/inst/tinytest/test-_misc.R index 6871292c..ff511589 100755 --- a/inst/tinytest/test-_misc.R +++ b/inst/tinytest/test-_misc.R @@ -47,7 +47,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE)) } -# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this: +# we rely on "grouped_tbl" being a class of grouped tibbles, so run a test that checks for this: if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(ward))) } diff --git a/inst/tinytest/test-ab_property.R b/inst/tinytest/test-ab_property.R index b80e4db2..4ce82eeb 100644 --- a/inst/tinytest/test-ab_property.R +++ b/inst/tinytest/test-ab_property.R @@ -68,15 +68,15 @@ expect_true(ab_url("AMX") %like% "whocc.no") expect_warning(ab_url("ASP")) expect_identical( - colnames(set_ab_names(example_isolates[, 20:25])), + colnames(set_ab_names(example_isolates[, 17:22])), c("cefoxitin", "cefotaxime", "ceftazidime", "ceftriaxone", "gentamicin", "tobramycin") ) expect_identical( - colnames(set_ab_names(example_isolates[, 20:25], language = "nl", snake_case = FALSE)), + colnames(set_ab_names(example_isolates[, 17:22], language = "nl", snake_case = FALSE)), c("Cefoxitine", "Cefotaxim", "Ceftazidim", "Ceftriaxon", "Gentamicine", "Tobramycine") ) expect_identical( - colnames(set_ab_names(example_isolates[, 20:25], property = "atc")), + colnames(set_ab_names(example_isolates[, 17:22], property = "atc")), c("J01DC01", "J01DD01", "J01DD02", "J01DD04", "J01GB03", "J01GB01") ) diff --git a/inst/tinytest/test-count.R b/inst/tinytest/test-count.R index 262018bf..ac64d773 100644 --- a/inst/tinytest/test-count.R +++ b/inst/tinytest/test-count.R @@ -79,7 +79,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { combination = count_susceptible(CIP, GEN) ) %>% pull(combination), - c(253, 465, 192, 558) + c(946, 428, 94) ) # count_df diff --git a/inst/tinytest/test-data.R b/inst/tinytest/test-data.R index 4086f6d2..22e2b003 100644 --- a/inst/tinytest/test-data.R +++ b/inst/tinytest/test-data.R @@ -57,7 +57,6 @@ expect_identical(as.ab(antibiotics$name), antibiotics$ab) datasets <- data(package = "AMR", envir = asNamespace("AMR"))$results[, "Item", drop = TRUE] for (i in seq_len(length(datasets))) { dataset <- get(datasets[i], envir = asNamespace("AMR")) - expect_identical(class(dataset), "data.frame") expect_identical(AMR:::dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i]) } diff --git a/inst/tinytest/test-first_isolate.R b/inst/tinytest/test-first_isolate.R index 2ec4fe53..ceb0d86a 100755 --- a/inst/tinytest/test-first_isolate.R +++ b/inst/tinytest/test-first_isolate.R @@ -75,7 +75,7 @@ expect_equal( ), na.rm = TRUE ), - 941 + 942 ) # set 1500 random observations to be of specimen type 'Urine' @@ -160,7 +160,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { # support for WHONET expect_message(example_isolates %>% - select(-patient_id) %>% + select(-patient) %>% mutate( `First name` = "test", `Last name` = "test", diff --git a/inst/tinytest/test-proportion.R b/inst/tinytest/test-proportion.R index bfaab47a..79e6683f 100755 --- a/inst/tinytest/test-proportion.R +++ b/inst/tinytest/test-proportion.R @@ -84,7 +84,7 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) { combination_n = n_rsi(CIP, GEN) ) %>% pull(combination_n), - c(305, 617, 241, 711) + c(1181, 577, 116) ) # proportion_df diff --git a/tests/tinytest.R b/tests/tinytest.R index 2753f082..b54662b4 100644 --- a/tests/tinytest.R +++ b/tests/tinytest.R @@ -27,8 +27,9 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { # env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so: .libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths())) - if (AMR:::pkg_is_available("tinytest")) { + if (AMR:::pkg_is_available("tinytest", also_load = TRUE)) { library(AMR) + set_AMR_locale("English") out <- test_package("AMR", testdir = ifelse(AMR:::dir.exists("inst/tinytest"), "inst/tinytest", @@ -37,7 +38,7 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) { verbose = 99, color = FALSE ) - cat("SUMMARY:\n") + cat("\n\nSUMMARY:\n") print(summary(out)) } }