Skip to content

Conversation

@plietar
Copy link
Contributor

@plietar plietar commented Sep 8, 2025

The expect_vector function delegates most of its logic to vctrs::vec_assert, which can throw one of two errors, vctrs_error_assert and vctrs_error_scalar_type.

Only the former one was being handled, not the latter. This doesn't affect the behaviour of tests much, but it produces sub-par error messages and causes failing tests to terminate immediately rather than recording the error and continuing like other assertions do.

Fixes #2224

plietar and others added 4 commits September 8, 2025 15:20
The `expect_vector` function delegates most of its logic to
`vctrs::vec_assert`, which can throw one of two errors,
`vctrs_error_assert` and `vctrs_error_scalar_type`.

Only the former one was being handled, not the latter. This doesn't
affect the behaviour of tests much, but it produces sub-par error
messages and causes failing tests to terminate immediately rather than
recording the error and continuing like other assertions do.
@hadley hadley merged commit 2af856e into r-lib:main Oct 2, 2025
13 checks passed
@hadley
Copy link
Member

hadley commented Oct 2, 2025

@plietar thanks for working on this! I turned the two failure tests into snapshot tests to capture the actual message, and that revealed we ended up double quoting the variable name. I added a very quick and dirty hack to fix that.

@plietar plietar deleted the vector-assert branch October 3, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expect_vector with NULL terminates the test prematurely

2 participants