From d5aa2940fddc91912e583786d35460b0cde41d09 Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Thu, 4 Jul 2019 11:49:57 -0400 Subject: [PATCH] switch to tinytest; add code coverage --- .travis.yml | 3 +++ DESCRIPTION | 43 +++++++++++++++++++------------------------ inst/tinytest/test_ndjson.R | 13 +++++++++++++ tests/test-all.R | 2 -- tests/testthat/test-ndjson.R | 21 --------------------- tests/tinytest.R | 3 +++ 6 files changed, 38 insertions(+), 47 deletions(-) create mode 100644 inst/tinytest/test_ndjson.R delete mode 100644 tests/test-all.R delete mode 100644 tests/testthat/test-ndjson.R create mode 100644 tests/tinytest.R diff --git a/.travis.yml b/.travis.yml index 106e2d4..92b5dea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,3 +23,6 @@ before_install: - mkdir -p ~/.R - echo "VkVSPS03CkNDPWdjYyQoVkVSKSAtc3RkPWMxMSAKQ1hYPWcrKyQoVkVSKQpTSExJQl9DWFhMRD1nKyskKFZFUikKRkM9Z2ZvcnRyYW4KRjc3PWdmb3J0cmFuCg==" | base64 -d > ~/.R/Makevars - cat ~/.R/Makevars + +after_success: + - Rscript -e 'covr::codecov()' \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 8f881d1..3f1e89f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,36 +3,31 @@ Type: Package Title: Wicked-Fast Streaming 'JSON' ('ndjson') Reader Version: 0.8.0 Date: 2019-07-01 -Authors@R: c( - person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), - comment = c(ORCID = "0000-0001-5670-2640")), - person("Niels", "Lohmann", role = "aut", comment = "C++ json parser"), - person("Deepak", "Bandyopadhyay", role = "aut", comment = "C++ gzstream"), - person("Lutz", "Kettner", role = "aut", comment = "C++ gzstream"), - person("Neal", "Fultz", role = "ctb", comment = "Rcpp integration") - ) +Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = + c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")), + person("Niels", "Lohmann", role = "aut", comment = "C++ json + parser"), person("Deepak", "Bandyopadhyay", role = "aut", comment + = "C++ gzstream"), person("Lutz", "Kettner", role = "aut", + comment = "C++ gzstream"), person("Neal", "Fultz", role = "ctb", + comment = "Rcpp integration") ) Maintainer: Bob Rudis -Description: Streaming 'JSON' ('ndjson') has one 'JSON' record per-line and - many modern 'ndjson' files contain large numbers of records. These constructs - may not be columnar in nature, but it is often useful to read in these files - and "flatten" the structure out to enable working with the data in an R - 'data.frame'-like context. Functions are provided that make it possible to read - in plain 'ndjson' files or compressed ('gz') 'ndjson' files and either validate - the format of the records or create "flat" 'data.table' structures from them. +Description: Streaming 'JSON' ('ndjson') has one 'JSON' record per-line + and many modern 'ndjson' files contain large numbers of records. + These constructs may not be columnar in nature, but it is often + useful to read in these files and "flatten" the structure out to + enable working with the data in an R 'data.frame'-like context. + Functions are provided that make it possible to read in plain + 'ndjson' files or compressed ('gz') 'ndjson' files and either + validate the format of the records or create "flat" 'data.table' + structures from them. URL: http://gitlab.com/hrbrmstr/ndjson BugReports: https://gitlab.com/hrbrmstr/ndjson/issues SystemRequirements: zlib, C++14 NeedsCompilation: yes License: MIT + file LICENSE Encoding: UTF-8 -Suggests: - testthat -Depends: - R (>= 3.2.0) -Imports: - Rcpp, - data.table, - dplyr, - dtplyr +Suggests: tinytest, covr +Depends: R (>= 3.2.0) +Imports: Rcpp, data.table, dplyr, dtplyr LinkingTo: Rcpp RoxygenNote: 6.1.1 diff --git a/inst/tinytest/test_ndjson.R b/inst/tinytest/test_ndjson.R new file mode 100644 index 0000000..8a6233e --- /dev/null +++ b/inst/tinytest/test_ndjson.R @@ -0,0 +1,13 @@ +library(ndjson) + +f <- system.file("extdata", "test.json", package="ndjson") +expect_true(validate(f)) +expect_equal(nrow(stream_in(f)), 100) +expect_true(inherits(stream_in(f), "tbl_dt")) +expect_true(inherits(stream_in(f, "tbl"), "tbl_df")) + +gzf <- system.file("extdata", "testgz.json.gz", package="ndjson") +expect_true(validate(gzf)) +expect_equal(nrow(stream_in(gzf)), 100) +expect_true(inherits(stream_in(gzf), "tbl_dt")) +expect_true(inherits(stream_in(gzf, "tbl"), "tbl_df")) diff --git a/tests/test-all.R b/tests/test-all.R deleted file mode 100644 index 93d1da4..0000000 --- a/tests/test-all.R +++ /dev/null @@ -1,2 +0,0 @@ -library(testthat) -test_check("ndjson") diff --git a/tests/testthat/test-ndjson.R b/tests/testthat/test-ndjson.R deleted file mode 100644 index 5797fe1..0000000 --- a/tests/testthat/test-ndjson.R +++ /dev/null @@ -1,21 +0,0 @@ -context("uncompressed files (validation and streaming)") -test_that("validation and streaming works in uncompressed files (validation and streaming)", { - - f <- system.file("extdata", "test.json", package="ndjson") - expect_that(validate(f), equals(TRUE)) - expect_that(nrow(stream_in(f)), equals(100)) - expect_that(stream_in(f), is_a("tbl_dt")) - expect_that(stream_in(f, "tbl"), is_a("tbl_df")) - -}) - -context("compressed files (validation and streaming)") -test_that("validation and streaming works in compressed files", { - - gzf <- system.file("extdata", "testgz.json.gz", package="ndjson") - expect_that(validate(gzf), equals(TRUE)) - expect_that(nrow(stream_in(gzf)), equals(100)) - expect_that(stream_in(gzf), is_a("tbl_dt")) - expect_that(stream_in(gzf, "tbl"), is_a("tbl_df")) - -}) diff --git a/tests/tinytest.R b/tests/tinytest.R new file mode 100644 index 0000000..423aad8 --- /dev/null +++ b/tests/tinytest.R @@ -0,0 +1,3 @@ +if ( requireNamespace("tinytest", quietly=TRUE) ){ + tinytest::test_package("ndjson") +}