Skip to content

Failure to fail when a test fails #936

@kenahoo

Description

@kenahoo

I'm tracking down a Heisenbug where sometimes a test failure in a testthat script doesn't actually cause failure of the test suite.

Changing various random things in the tests can get it to fail properly, and most importantly, running under devtools::test() makes it fail properly while running under R CMD check masks the failure. It also masks the failure when I run tools:::.check_packages(), the function in R that implements R CMD check.

Also, importantly, changing my testthat.R file from tmp <- test_check("gene", reporter="tap") to tmp <- test_check("gene") also makes it fail properly when running under R CMD check. So I'm suspecting a problem in TapReporter somehow.

The testthat.Rout file does show a failure in all cases - it includes the following (I've put in [...] various places to elide the output):

R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.7.0 (64-bit)
[...]
Loading required package: gene
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
WARN [2019-09-11 14:27:47] New power surface models need at least a timestamp argument ruc.ts, falling back to old models
1..23
# Context Testing sag and windspeed model generation
ok 1 # WARNING namespace 'wra.ops' is not available and has been replaced
by .GlobalEnv when processing object ''
ok 2 # WARNING namespace 'wra.ops' is not available and has been replaced
by .GlobalEnv when processing object ''
[...]
ok 20 # WARNING the condition has length > 1 and only the first element will be used
ok 21 # WARNING the condition has length > 1 and only the first element will be used
not ok 22 (unknown)
  object 'latitude' not found
  1: runTest(outputDirectory = "test-output", expectedFile = "expectedDailyClassification.rds") at testthat/test_daily-classification_output-files.R:68
  2: run.daily.classification(jsonInputFilePath) at testthat/test_daily-classification_output-files.R:38
[...]
  24: map(.x[sel], .f, ...)
  25: .f(.x[[i]], ...)
ok 23 multiplication works
Warning message:
replacing previous import 'dplyr::rename' by 'plyr::rename' when loading 'gene' 
> cat('Tests done', file='/tmp/testsdone')
> 
> proc.time()
   user  system elapsed 
  3.727   0.546   4.936 

Notice the not ok 22 in the output. But the R CMD check output contains this:

* checking tests ...
  Running ‘testthat.R’
 OK

To help me track this down - does this file get written and then parsed to determine whether there was a failure? Or do the results get tracked internally and then TapReporter simply writes out a file, the contents of which testthat never does anything with?

I've been trying to isolate the problem by doing the following:

# Location in R version 3.6.1:
trace(tools:::.check_packages, browser, at=list(c(34, 3, 3, 4, 3, 3, 14)))
tools:::.check_packages('../gene_2.18.tar.gz')

But as you probably know, debugging the R CMD blah code is super difficult because of how it keeps calling R through the command line over & over, so I'm trying to boil this down to something inside testthat that will be easier to figure out.

Thanks, hope that was coherent enough! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions