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

Function/Variables disappear using rmcdcheck() on tests #217

Closed
latot opened this issue Dec 1, 2023 · 6 comments
Closed

Function/Variables disappear using rmcdcheck() on tests #217

latot opened this issue Dec 1, 2023 · 6 comments
Labels
reprex needs a minimal reproducible example

Comments

@latot
Copy link

latot commented Dec 1, 2023

Hi all, this was initially related to moodymudskipper/typed#33.

Actually when we run tests on the sample I send we have this error:

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]

══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-bug_typed.R:4:3'): test_assert ─────────────────────────────────
Error: In `test_assert()` at `custom_var <- ...`:
could not find function "cassert"
Backtrace:1. ├─bugtyped::test_assert() at test-bug_typed.R:4:3
 2. └─typed (local) `<fn>`(base::quote(1L))

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]
Error: Test failures
Execution halted

1 error| 1 warning| 0 notes

What is weird, cassert is a function in the library, I thought this was a error on the typed library, until today when I notice this:

devtools::test()
ℹ Testing bugtyped| F W  S  OK | Context|          1 | bug_typed                                                                                                                                                                                         

══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 1 ]

Using devtools to run the tests actually works, so maybe this is more related to rcmdcheck and a bug in some part with env.

We can load the library, cassert exists, we can use it and all, only fails when we run rcmdcheck::rcmdcheck()

Thx!

bug_typed.zip

@gaborcsardi
Copy link
Member

Do you have a reproducible example? E.g. can you share your package with us?

@gaborcsardi gaborcsardi added bug an unexpected problem or unintended behavior reprex needs a minimal reproducible example and removed bug an unexpected problem or unintended behavior labels Dec 1, 2023
@latot
Copy link
Author

latot commented Dec 1, 2023

Hi, I included the zip file in the end of the issue when I posted it :)

@gaborcsardi
Copy link
Member

For the record, for us the easiest is if you share your reproducible example on GitHub, e.g. then we can refer to the code. In any case, I see the same issue with R CMD check, for which rcmdcheck is merely a wrapper of, so it is definitely not an issue with rcmdcheck.

@latot
Copy link
Author

latot commented Dec 1, 2023

Hi, @gaborcsardi I know is a wrapper, I usually agree, but in this case, all tests passes with devtools::test(), also all in the example works, only fails from rcmdcheck::rcmdcheck().

I would appreciate if you can tell me to where this would belongs if is not testthat nor typed nor devtools.

Here the example:
https://github.com/latot/bugs/tree/rcmdcheck-217

@gaborcsardi
Copy link
Member

I would appreciate if you can tell me to where this would belongs if is not testthat nor typed nor devtools.

If I remove testthat.R, and then add another file tests/mytest.R:

library(bugtyped)
test_assert()

and then run R CMD check:

* checking tests ...
  Running ‘mytest.R’
 ERROR
Running the tests in ‘tests/mytest.R’ failed.
Complete output:
  >
  > library(bugtyped)
  > test_assert()
  Error: In `test_assert()` at `custom_var <- ...`:
  could not find function "cassert"
  Execution halted

Actually, even if I just install the package, and then load it and run test_assert(), I get the same:

❯ library(bugtyped)
❯ test_assert()
Error: In `test_assert()` at `custom_var <- ...`:
could not find function "cassert"

So this happens without testthat, and without rcmdcheck.

I don't know enough of typed to know if this is a bug in typed or you are not using it correctly, but it must be either one or the other.

@latot
Copy link
Author

latot commented Dec 1, 2023

:O Thx! a new clue!

From the typed library, that is the way to declare assertions, I have a lot of them! and works pretty good, except this case which I have no idea why it fails, when I tried to get a reprex was also hard, touch one line and works, but seems to be more probable to happens with longer codes...

Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

2 participants