kadyb / rgugik

Download datasets from Polish Head Office of Geodesy and Cartography
https://kadyb.github.io/rgugik/
Other
33 stars 4 forks source link

Test coverage fails #26

Closed kadyb closed 4 years ago

kadyb commented 4 years ago
  1. Commit a9c9fdc - fail
  2. Commit 10a04aa - fail
  3. Commit 8a4437d - fail

In RStudio Test Package (CTRL + SHIFT + T) and covr::package_coverage() works.

@Nowosad any ideas?

Nowosad commented 4 years ago

I usually use:

      - name: Install package
        run: R CMD INSTALL .

      - name: Test coverage
        run: covr::codecov()
        shell: Rscript {0}
kadyb commented 4 years ago

This is exactly what I tried in 10a04aa with no success. It's hard to say what the error is about because there is no specific information.

Nowosad commented 4 years ago

One more thing I should add: I have zero experience with testit - I've been using testthat and tinytest.

kadyb commented 4 years ago

This may be the reason, but surprisingly, it works locally. It doesn't only work on GitHub Actions. I will try to create an issue on the covr repository, maybe they will be able to help us. If not, maybe I will have to rewritte tests to testthat or tinytest.

Edit: I created an covr issue (it isn't the source of the error) Edit2: testit issue (it isn't the source of the error)

kadyb commented 4 years ago

This error probably doesn't come from covr, testit, or testthat. There is probably something wrong with jsonlite during rcmdcheck. However, I have never had such a problem.

testthat:

> library(testthat)
> library(rgugik)
> 
> test_check("rgugik")
── 1. Error: (unknown) (@test-DEM_request.R#5)  ────────────────────────────────
lexical error: invalid char in json text.
                                       <html><head><title>Request Reje
                     (right here) ------^
Backtrace:
 1. rgugik::DEM_request(polygon)
 2. jsonlite::fromJSON(prepared_URL)
 3. jsonlite:::parse_and_simplify(...)
 4. jsonlite:::parseJSON(txt, bigint_as_char)
 5. jsonlite:::parse_con(txt, bigint_as_char)
Nowosad commented 4 years ago

Read https://stackoverflow.com/questions/41000112/reading-a-json-file-in-r-lexical-error-invalid-char-in-json-text#comment69209041_41000112. Is there a chance that the GUGiK servers are blocking GitHubs ip addresses (or something similar)?

kadyb commented 4 years ago

This may be the reason, but it's hard to say. DEM_request and orto_request use https://mapy.geoportal.gov.pl and fails. tile_download uses https://opendata.geoportal.gov.pl and works fine during rcmdcheck. I don't know about the other functions if they work because I didn't write rest of tests. Anyway, we use many APIs and servers.

kadyb commented 4 years ago

I added two more tests of functions which use jsonlite in 471a0b1. These tests didn't fail, so we can assume that requests from GitHub are only block in DEM_request and orto_request.

kadyb commented 4 years ago

I fixed this issue in #27.

Now we use testthat framework, but in the future it will be better to use testit. Especially when we solve the URL testing (#21). Then the sample test will look like this (this is a really simple notation compared to all testthat functions):

assert(
  "test output",
  nrow(output) > 0 || is.null(output)
  # NULL means gracefully fail (required by CRAN)
)

Code coverage includes all functions except geonames_download, geodb_download, borders_download (too large file size) and DEM_request, orto_request (requests from GitHub are blocked) - check test-coverage.yml. Additionally, test-DEM_request, test-orto_request testing is skipped on GitHub. Code coverage exceptions can also be written in .covrignore file instead in test-coverage.yml.

For this moment, code coverage is 79% including:

R/pointDTM100_download.R: 61.54%
R/tile_download.R: 61.54%
R/models3D_download.R: 69.70%
R/pointDTM_get.R: 80.65%
R/topodb_download.R: 82.61%
R/emuia_download.R: 84.00%
R/minmaxDTM_get.R: 85.71%
R/geocodePL_get.R: 93.94%
R/parcel_get.R: 95.00%

We should still improve it.