Skip to content

Commit

Permalink
Merge pull request #19 from MichaelChirico/get-age-better-tests
Browse files Browse the repository at this point in the history
Drop GPL license, use testthat 3e
  • Loading branch information
MichaelChirico authored Dec 21, 2024
2 parents a3346d1 + 452cacc commit cbef3e3
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 95 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: master
pull_request:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

83 changes: 0 additions & 83 deletions .github/workflows/run_job.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Maintainer: Michael Chirico <[email protected]>
Depends: R (>= 3.2.2)
Description: YACFP (Yet Another Convenience Function Package). get_age() is a fast & accurate tool for measuring fractional years between two dates. abbr_to_colClass() is a much more concise way of feeding many types to a colClass argument in a data reader. stale_package_check() tries to identify any library() calls to unused packages.
Imports: data.table
Suggests: testthat, jsonlite
License: GPL (>= 2)
Suggests: testthat (>= 3.0.0), jsonlite
Config/testthat/edition: 3
License: MIT + file LICENSE
URL: https://github.com/MichaelChirico/funchir
Encoding: UTF-8
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2015-2024
COPYRIGHT HOLDER: Michael Chirico
2 changes: 1 addition & 1 deletion tests/testthat/stale_package_test_scripts/simple.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(stats)
require(tools)
library(tcltk) # unused
library(parallel) # unused

density(rnorm(100))

Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-io-utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context('I/O Utility Functions')

test_that('abbr_to_colClass works', {
expect_equal(
abbr_to_colClass('bcflinDtds', '1234567891'),
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-plot-utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context('Plotting utilities')

test_that('device-units-to-inches functions work', {
on.exit(dev.off())
grDevices::png(tempfile())
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context('Utility functions')

test_that('stale_package_check works', {
stale_package_path <- function(path) test_path('stale_package_test_scripts', path)

Expand All @@ -10,7 +8,7 @@ test_that('stale_package_check works', {
paste0("\t", toString(sort(c("density", "rnorm")))),
"Functions matched from package tools:",
"\tfile_ext",
"**No exported functions matched from tcltk**"),
"**No exported functions matched from parallel**"),
collapse = '\n'
),
fixed = TRUE
Expand Down Expand Up @@ -113,8 +111,8 @@ test_that('create_quantiles works', {
expect_equal(create_quantiles(1:10, 4L), factor(rep(1:4, c(3L, 2L, 2L, 3L))))
expect_equal(create_quantiles(1:10, 3L), factor(rep(1:3, c(3L, 3L, 4L))))

expect_error(create_quantiles(rep(1:2, c(100L, 1L)), 2L), error='Overlapping quantiles. Please provide 1 label.')
expect_error(create_quantiles(rep(1:2, c(2L, 1L)), 3L), error='Overlapping quantiles. Please provide 2 labels.')
expect_error(create_quantiles(rep(1:2, c(100L, 1L)), 2L), 'Overlapping quantiles. Please provide 1 label.')
expect_error(create_quantiles(rep(1:2, c(2L, 1L)), 3L), 'Overlapping quantiles. Please provide 2 labels.')
})

test_that('write_packages works', {
Expand Down

0 comments on commit cbef3e3

Please sign in to comment.