Skip to content

Conversation

MichaelChirico
Copy link
Member

Closes #5842.

Didn't touch tests.Rraw yet as there are 200+ existing calls to options(). Better to save that for a future clean-up. Converted the other scripts with a more manageable diff to demonstrate the new usage.

Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.53%. Comparing base (566bff0) to head (50a6d17).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5845   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files          80       80           
  Lines       14915    14915           
=======================================
  Hits        14547    14547           
  Misses        368      368           

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

@ben-schwen
Copy link
Member

Looking great!

The only thing we might have to think about is where to put the options argument in a test(...) call. Current practice is AFAIC to have test(num, call, expected) so test(num, options=options, call, expected) differs from that.

@MichaelChirico
Copy link
Member Author

Looking great!

The only thing we might have to think about is where to put the options argument in a test(...) call. Current practice is AFAIC to have test(num, call, expected) so test(num, options=options, call, expected) differs from that.

yes, this is a new style. basically this is a "set up" step as it might be called in other unit testing frameworks. so I think it's important to have it up front for clarity. that doesn't have a parallel among current arguments. I might even put it before the test number, but definitely not after the test outcome parts.

@ben-schwen
Copy link
Member

yes, this is a new style. basically this is a "set up" step as it might be called in other unit testing frameworks. so I think it's important to have it up front for clarity. that doesn't have a parallel among current arguments. I might even put it before the test number, but definitely not after the test outcome parts.

I also thought about the setup step, so 2nd place makes definitely sense.

Pls, do not put it before the test number because in searching for tests I often use test(testnum if the test number occurs multiple times in tests.Rraw

@tdhock
Copy link
Member

tdhock commented Dec 20, 2023

I would like to see a similar test(testnum, my_computed_value, my_expected_value, env=list(SOME_ENV_VAR="VALUE")) -- I was recently working on #5807 which involves environment variables for getting default number of threads, and the tests would be much easier to understand/modify with such an enhancement to test.

@jangorecki
Copy link
Member

@tdhock I understand the use case, but if it is not as common as options, then I think it can be left to R's functions to set variables. Contrary R options are very common in tests, as Michael said, more than 200 times.

@MichaelChirico
Copy link
Member Author

I would like to see a similar test(testnum, my_computed_value, my_expected_value, env=list(SOME_ENV_VAR="VALUE")) -- I was recently working on #5807 which involves environment variables for getting default number of threads, and the tests would be much easier to understand/modify with such an enhancement to test.

I think it's perfectly reasonable, but let's save it for a follow-up issue to keep PRs sharp

@MichaelChirico
Copy link
Member Author

MichaelChirico commented Mar 13, 2024

Here is a breakdown of the non-draft PRs touching each test script as of now:

data.table spacing style

document in Rd

Add options= to test()

document in Rd

missed staged chunk

convert most Rraw scripts to use test(options=)

Merge branch 'master' into test-options

Merge remote-tracking branch 'origin/test-options' into test-options
data.table spacing style

document in Rd

Add options= to test()

document in Rd

missed staged chunk

convert most Rraw scripts to use test(options=)

Merge branch 'master' into test-options

Merge remote-tracking branch 'origin/test-options' into test-options
@MichaelChirico MichaelChirico changed the base branch from master to test-options-simple-files March 20, 2024 05:58
Copy link
Member Author

MichaelChirico commented Mar 20, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @MichaelChirico and the rest of your teammates on Graphite Graphite

Base automatically changed from test-options-simple-files to master March 21, 2024 11:21
@MichaelChirico MichaelChirico marked this pull request as draft March 26, 2024 00:01
@MichaelChirico

This comment was marked as outdated.

@MichaelChirico MichaelChirico modified the milestones: 1.16.0, 1.17.0 Jul 10, 2024
@MichaelChirico MichaelChirico removed this from the 1.17.0 milestone Dec 3, 2024
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.

test() should get an options= argument to transparently & temporarily set options for a test
4 participants