Skip to content

Conversation

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Apr 1, 2024

Closes #6039.


The simple version 0b683fb doesn't work right because of our non-hermetic tests. A version with just try({x,y}, silent=TRUE) worked but spewed a ton of output. In any case, it still takes ~30 seconds to run the suite on my computer for testPattern='1111' -- again because our tests are so non-hermetic and we wind up needing to evaluate the x&y parts for every test because of this.

Why is this the case? think of tests like:

test(1, x, y <- 2)
test(2, z, y)

a <- foo(y)

We need to evaluate y<-2 in order for test(2) to pass, and moreover we need y for a outside of tests so even early return of test() doesn't help.

@MichaelChirico
Copy link
Member Author

@ben-schwen PTAL if this suits your needs

@codecov
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.53%. Comparing base (53df7e5) to head (f7f62f7).
Report is 32 commits behind head on master.

❗ Current head f7f62f7 differs from pull request most recent head e8123bf. Consider uploading reports for the commit e8123bf to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6040      +/-   ##
==========================================
+ Coverage   97.51%   97.53%   +0.01%     
==========================================
  Files          80       80              
  Lines       14920    14916       -4     
==========================================
- Hits        14549    14548       -1     
+ Misses        371      368       -3     

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

@ben-schwen
Copy link
Member

@ben-schwen PTAL if this suits your needs

Basically yes. However, I just noticed that it has problems when the test uses fread.

@MichaelChirico
Copy link
Member Author

@ben-schwen PTAL if this suits your needs

Basically yes. However, I just noticed that it has problems when the test uses fread.

Could you elaborate? I just tried test.data.table(testPattern="1552|2251") and it worked fine. I suspect it's probably related to my comment...

@ben-schwen
Copy link
Member

Could you elaborate? I just tried test.data.table(testPattern="1552|2251") and it worked fine. I suspect it's probably related to my comment...

I tried test.data.table(testPattern='2025') which ends up with

Running 3 of 6832 tests matching '2025'
Error in parse(n = -1, file = file, srcfile = NULL, keep.source = FALSE) : 
  184:1: unexpected '}'
183: test(2025.01, fread(testDir("issue_3400_fread.txt"), skip=1, header=TRUE), data.table(A=INT(1,3,4), B=INT(2,2,5), C=INT(3,1,6)))
184: }
     ^

but maybe thats because these tests use the test_no + 0.1 instead of fixed numbers?

@ben-schwen
Copy link
Member

ben-schwen commented Apr 3, 2024

Maybe another more simple approach:
What if we add a global option for the testPattern and add this option to the signature of the test function. Then we could set this global parameter with test.data.table.

@MichaelChirico
Copy link
Member Author

Maybe another more simple approach: What if we add a global option for the testPattern and add this option to the signature of the test function. Then we could set this global parameter with test.data.table.

that was done in 0b683fb as elaborated in PR description. it doesn't work well with our test setup :\

@MichaelChirico
Copy link
Member Author

I tried test.data.table(testPattern='2025') which ends up with

the problem with 2025 is here:

https://github.com/Rdatatable/data.table/blob/d35dcebc9ea022a0a80f55e0abbcc84f4adbcffc/inst/tests/tests.Rraw#L14712-L14733

Some but not all of the suite have literal '2025' in the name, we wind up with that dangling } as part of the "setup code".

We can fix this by making more changes in #6041, but the shortcomings of the static approach remain.

@MichaelChirico MichaelChirico changed the base branch from master to test-numbering April 3, 2024 18:51
Copy link
Member Author

MichaelChirico commented Apr 3, 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

@MichaelChirico
Copy link
Member Author

@ben-schwen restacked this onto #6041, with the latest change there test.data.table(testPattern='2025') now works.

The fundamental issue remains; as a workaround, I added a step to at least check the subsetted script parses, if not we back up to running the full suite instead of the cryptic error.

MichaelChirico added a commit that referenced this pull request Apr 9, 2024
Related to #6040 -- it will be good to keep to a pattern where `test()` always has a numeric literal in the `num=` argument, even if it's a dynamic test where the base number is incremented by a variable amount. Doing so will make the `testPattern=` argument to `test.data.table()` more usable.

We can add a linter for this (#5908) to prevent regression later.

<details>

Linter to find these:

```r
l=make_linter_from_xpath(
  "//SYMBOL_FUNCTION_CALL[text() = 'test']/parent::expr/following-sibling::expr[1][SYMBOL or expr[1]/SYMBOL]",
  "xxx")
lint("inst/tests/tests.Rraw", l())
```

</details>
Base automatically changed from test-numbering to master April 9, 2024 20:06
@MichaelChirico
Copy link
Member Author

This doesn't affect CI or R CMD check, so taking 👍 from @ben-schwen as GTG. Let's iterate more to improve this feature as needed later.

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 have an option to start at certain test

2 participants