Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for test.data.table() in foreign mode #6808

Merged
merged 12 commits into from
Feb 11, 2025

Conversation

aitap
Copy link
Contributor

@aitap aitap commented Feb 9, 2025

This is to improve the the quality of life when running test.data.table() without an English locale set or translation disabled. Tests that previously used capture.output now use output=..., which is skipped in foreign mode. Tests are also skipped in foreign mode for ignore.warnings and notOutput.

Copy link

codecov bot commented Feb 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.64%. Comparing base (deb31d9) to head (81b09fb).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6808   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files          79       79           
  Lines       14639    14642    +3     
=======================================
+ Hits        14440    14444    +4     
+ Misses        199      198    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Feb 9, 2025

Comparison Plot

Generated via commit 81b09fb

Download link for the artifact containing the test results: ↓ atime-results.zip

Task Duration
R setup and installing dependencies 4 minutes and 31 seconds
Installing different package versions 8 minutes and 36 seconds
Running and plotting the test cases 2 minutes and 33 seconds

This is already done for warnings and errors. Unfortunately, some tests
do check output and conditions by hand, so test.data.table() still
requires LANGUAGE=en for now.
A comment near 1832.2 said that output= was inapplicable due to square
bracket matching. The actual source of the problem was the caret only
matching start of string instead of start of line.
While not all all.equal() output is translated, those cases that are
result in test failures when comparing the output in test() calls. Use
output= so that the test would be skipped in 'foreign' mode.
We already only count warnings in foreign mode, don't match their text
contents. With ignore.warning set, we lack a way to figure out when the
translated warning should be skipped, so don't count them at all.
The length(output) || length(notOutput) branch makes length(output) at
least 1. Later, 'y' value check is skipped if length(output) is nonzero.

Instead of skipping this branch altogether in foreign mode, make sure
that it's taken so that the 'y' value check is later skipped when
foreign mode is on.
Instead of applying passed options= for the rest of the call frame, undo
them immediately after evaluating the call. This prevents testing for
options(datatable.alloccol=...) from breaking the internal data.table
usage and allows rewriting the tests using the options=... and error=...
arguments, which skip tests as appropriate in foreign mode.
@aitap aitap force-pushed the interactive-test.data.table branch from f48097b to 2068510 Compare February 10, 2025 14:26
@aitap
Copy link
Contributor Author

aitap commented Feb 10, 2025

The important part now exists as #6811. May need more changes if more of all.equal.data.table() ends up being translated.

@aitap aitap marked this pull request as ready for review February 10, 2025 14:34
test(432.3, inherits(err3,"try-error") && grep("is a numeric vector ok but its length is 2. Its length should be 1.", err3))
test(432.4, inherits(err4,"try-error") && grep("It must be >=0 and not NA.", err4))
test(432.5, inherits(err5,"try-error") && grep("It must be >=0 and not NA.", err5))
# Test that unsetting datatable.alloccol is caught, #2014
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great fix & modernization!

R/test.data.table.R Outdated Show resolved Hide resolved
R/test.data.table.R Outdated Show resolved Hide resolved
Copy link
Member

@MichaelChirico MichaelChirico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! For posterity please also tidy up the PR description which still discusses the catf() part that was split off to #6811.

@aitap aitap changed the title Fixes for interactive test.data.table() Fixes for test.data.table() in foreign mode Feb 11, 2025
@MichaelChirico MichaelChirico merged commit c29e313 into master Feb 11, 2025
11 checks passed
@MichaelChirico MichaelChirico deleted the interactive-test.data.table branch February 11, 2025 18:04
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.

2 participants