Skip to content

Pr/1183 #1185

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

Merged
merged 14 commits into from
Oct 16, 2021
Merged

Pr/1183 #1185

merged 14 commits into from
Oct 16, 2021

Conversation

traversc
Copy link
Contributor

I added some syntax checking based on @Enchufa2 's feedback.

Tests here: https://github.com/traversc/RcppTest/tree/master/inst. These tests incorporate the examples from @Enchufa2.

Currently, you can run them with make install && make test, but I'm not sure the best way to add the tests as a pull request.

@eddelbuettel
Copy link
Member

Currently, you can run them with make install && make test, but I'm not sure the best way to add the tests as a pull request.

Hm, can you explain how that is supposed to work when a) we have no Makefile and b) nobody calls make test and c) you only committed to src/attributes.cpp?

It has been a while since I wrote new non-standard tests but we have a lot of them in the package you could study. There are even ones for package building etc (though not all may run at all times). One could attempt building a package (including a call to compileAttributes() invoking the attributes parser on expression meant to break. Not quite sure right now how to test multiple breaking expressions though without having to concoct multiple packages. Maybe by copying variants of a source file in, attempting a build for each and logging the expected failure.

@Enchufa2
Copy link
Member

If @traversc is not familiar with tinytest or unit testing in general, I can help with that.

@eddelbuettel
Copy link
Member

eddelbuettel commented Oct 13, 2021

Me too, of course. Always happy to help with tinytest which, via its "it is just a script" approach really makes it easy.

@Enchufa2
Copy link
Member

@traversc Checking your RcppTest repo, I see that you made a package specifically to test this. So the idea would be to integrate those tests into inst/tinytest as part of this PR, removing the manual prints, stopifnots, etc., and replacing them with the proper tinytest utilities that Rcpp already uses. You can take a look there to see how other similar tests are implemented.

@Enchufa2
Copy link
Member

Also, @traversc you can check past PRs with added tests. For example: #1180 (very simple one) and #1139 (more complex tests).

@eddelbuettel
Copy link
Member

And we have done just that: embed mock packages bnelow inst/tinytest/ to be used (only !!) by the tests.

@traversc
Copy link
Contributor Author

Okay, I added some tiny tests. The test script is test_attribute_package.R which builds the package testRcppAttributePackage.

The test script tests two things:

  1. that the package builds and the signature attribute produce the expected results
  2. that it also works inline (sourceCpp) and gives you an error when incorrect syntax is used (rather than falling through and segfaulting ;))

The test package only contains correct syntax so doesn't test for handling incorrect syntax within a package, but since it's the same code path to build R function signatures inline and via package, I think that's OK?

Copy link
Member

@Enchufa2 Enchufa2 left a comment

Choose a reason for hiding this comment

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

Comments inline. Also, please:

Comment on lines 19 to 20
## This now (Dec 2011) appears to fail on Windows
.onWindows <- .Platform$OS.type == "windows"
Copy link
Member

Choose a reason for hiding this comment

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

Did you test this? Does this fail on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and tested it on windows.

Copy link
Member

Choose a reason for hiding this comment

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

And... does it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested and working on windows (and also in CI).

@traversc
Copy link
Contributor Author

@Enchufa2 Replies inline. A bunch of commits for minor things, but hopefully they can be squashed at the end.

Also, one comment: I noticed the ChangeLog is a mixture of spaces and tabs -- is that intentional?

@Enchufa2
Copy link
Member

Looking very good, thanks for all the changes! I left a few more comments. I also activated the CI and everything passes (don't worry about the covr report).

@Enchufa2 Replies inline. A bunch of commits for minor things, but hopefully they can be squashed at the end.

Sure, no problem.

Also, one comment: I noticed the ChangeLog is a mixture of spaces and tabs -- is that intentional?

Yeap, I asked the same thing some time ago, but I don't recall @eddelbuettel's answer. :)

@eddelbuettel
Copy link
Member

Spaces vs tabs is accidental, we don't have control over all the editors in the world. I usually just resists global changes across the file as large white-space only commits are just noise. I can clean it up another time (there is yet another emacs function for it that does it well).

@eddelbuettel
Copy link
Member

(don't worry about the covr report).

Yes. We actually addressed that in the branch this would merge into.

So thanks for making all the changes (even if you some commits are sequentlial with the same commit message --> I prefer the amend option and force-pushing which is admissable to branches). (Just bringing this up as we're at the topic of gentle nags now ;-) )

@traversc
Copy link
Contributor Author

Updated, hopefully I addressed everything properly this time :)

@eddelbuettel
Copy link
Member

That looks pretty good now. There are two trivial whitespace things I might change but it's not worth making an issue over now.

Copy link
Member

@Enchufa2 Enchufa2 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! We can squash and merge this into #1183#1184, and then ping JJ to take a last look at src/attributes.cpp there?

@eddelbuettel
Copy link
Member

Yep that's the idea: by squashing it into our pr/1183 branch the pending PR #1184 should auto-update.

Giving that a whirl now.

@eddelbuettel eddelbuettel merged commit 27a072f into RcppCore:pr/1183 Oct 16, 2021
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.

3 participants