nealrichardson / httptest

A Test Environment for HTTP Requests in R
https://enpiar.com/r/httptest/
Other
79 stars 10 forks source link

How to get rid of "tracing function "form_file" in package "curl"" #34

Closed dmenne closed 3 years ago

dmenne commented 3 years ago

Great package - I had some fears that I would be fiddling a day to get the configuration right, things just worked out of the box!

A minor issue: My test output is a bit polluted by this output

tracing function "form_file" in package "curl"

which I do not understand where it comes from. How do I suppress it?

Note: I am using the "third edition": https://testthat.r-lib.org/articles/third-edition.html

so I cannot rule out that this is the result of the new "messages are not suppressed" feature.

== Testing test-AuthenticatedAccount.R ===============================================================
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ]Loading required package: curl
Tracing function "form_file" as seen from package "httr"
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 4 ] Done!
Untracing function "form_file" in package "curl"
nealrichardson commented 3 years ago

It looks like https://github.com/nealrichardson/httptest/blob/master/R/trace.R#L23 (as well as L28 below it) is missing the quietly() wrapper to suppress messages that all the other trace() calls in the file have. And you're probably right, we didn't notice this before because testthat was suppressing the messages anyway.

Would you be interested in submitting a PR to add quietly() to those two lines?

dmenne commented 3 years ago

https://github.com/dmenne/httptest

Strange, still printing


Loading odkapi
Testing odkapi
v |  OK F W S | Context
/ |   0       | AccountsAndUsersApi_Apiary                                  Tracing body_config(body, match.arg(encode)) on exit 
| |   3       | AccountsAndUsersApi_Apiary                                  Tracing body_config(body, match.arg(encode)) on exit 
\ |  10       | AccountsAndUsersApi_Apiary                                  Tracing body_config(body, match.arg(encode)) on exit 
nealrichardson commented 3 years ago

Ah, that one is also missing print=getOption("httptest.debug", FALSE)

dmenne commented 3 years ago

Thanks.

dmenne commented 3 years ago

Sorry to reopen this: I had not tested carefully enough. It still prints on exit. Any ideas?


Loading odkapi

== Testing test-ProjectManagementApi_Apiary.R ==============================
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 32 ] Done!
Untracing function "form_file" in package "curl"

Test complete
nealrichardson commented 3 years ago

Sounds like we need a CI job running the 3rd edition and checking for unsuppressed tracing messages. I won't get to this today but hopefully soon. @jonkeane any suggestions?

jonkeane commented 3 years ago

Yeah, lemme work on a branch to add 3rd/2nd edition testing. I started down the road to getting it working but ran into some issues with testing public() with the dev version of testthat (IIRC the tests with either edition were no longer working appropriately) which might no longer be a problem.

dmenne commented 3 years ago

I downloaded the latest master (SHA1 88dc7b5c), and it still shows the Untracing message in mock mode (not in capture)

I saw the mentioning of the newline in change log. Note in the printout below that it is similar to the first version I reported above (Untracing without newline before), while the second time reported there was a newline.


v |  OK F W S | Context
v |  30       | AccountsAndUsersApi_Apiary [1.0 s]                                                         
/ |   0       | AppUsers_Apiary                                                                            Untracing function "form_file" in package "curl"
| |   3       | AppUsers_Apiary                                                                            Unt
nealrichardson commented 3 years ago

The most recent change I tagged you on is still on a branch

dmenne commented 3 years ago

Works fine with the new version. Thanks.