Try something like this to express that you expect no warning (I repeat your code then a variant):
library(testthat)
test_that("warnings cause travis to fail", {
odd <- 1:2 * 1:5
expect_equal(length(odd), 5)
})
test_that("warnings cause travis to fail", {
expect_warning(odd <- 1:2 * 1:5, NA)
expect_equal(length(odd), 5)
})
#> Error: Test failed: 'warnings cause travis to fail'
#> * `odd <- 1:2 * 1:5` generated warnings:
#> * longer object length is not a multiple of shorter object length
Created on 2018-03-15 by the reprex package (v0.2.0).
But, yes, I acknowledge this does not scale!