-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fixes in tests + Coverage #615
Conversation
tests/testthat/setup.R
Outdated
@@ -1,3 +1,5 @@ | |||
library(xml2) # This should be imported already |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being outside the test_that()
calls it needs to have ::
or imported with library()
tests/testthat/test-borders.R
Outdated
# output_file = pdf_file, | ||
# envir = new.env(), | ||
# quiet = TRUE | ||
# ) # need to tinytex::install_tinytex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is my local's problem, still to fix ;)
Hello,
I am sure it has not to be in separate lines to be valid DESCRIPTION but I don't mind if you write them in separate lines and alphabetic order. If you think it is easier to read, no problem at all
Why not deleting all visual tests made with doconv. I can isolate them on my disk and re-introduce them later. As I said before, I am not fully satisfied and I can see it generate confusion to collaborators. That way, you are free to work without the burden of these 4 files. We can proceed as follows: we merge this PR, I remove the visual tests from the package and clean up what needs to be cleaned up. You can then resume from the new sources. I could re-inject them and clean up later. What do you think about this?
I liked my library statements :) It helps me to work interactively. This were my thought: I need them to test, they are in the Imports/Suggests of the package (if 'suggests', it needs a I am not clear, let me know :) Best, |
I think it is easier to search for libraries; I will do it, and if you do not like it we can revert ;)
I have an idea. We could move the file in the snapshot folders from
I understand very well, and adding the library calls when writing tests is natural. There are not major issues in keeping them if not for having clearer tests that differentiate what is in imports and suggests. In general, library calls should be in I hope to have convinced you! ^^ let me know what you think |
tests/testthat/setup.R
Outdated
# Construct the path to the _snaps folder | ||
path_to_snaps <- file.path(path_to_testthat, "_snaps") | ||
|
||
file.copy(folder_to_copy, path_to_snaps, recursive = TRUE, overwrite = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to find a way to remove them at the end of the testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, drop them. Otherwise I fear we end with a "workaround" and not a clean solution - I will add them later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may add skip_on_ci on the general call so we do not lose the code maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or do you mean to remove the files only? I think it is complicated anyway to have a feedback from test to inst if things are changed, it makes it a bit too manual does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's on github, nothing is lost. I will isolate the files on my computer and maybe put them in inst later.
After all, it was only to me a way to check all is ok visually before git-comiting. They are not managed by CI/CD, they sometimes fail (I think because the license check takes too much time with my Office 365 account), etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files that could be deleted are:
- "test-borders.R"
- "test-md-captions.R"
- "test-as_flextable.R"
and then the directory tests/testthat/_snaps
Do as you wish, I'm already happy that the package has benefited from this attention and your time, I don't want to slow you down. We can always change things slightly later. I just never thought about using |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #615 +/- ##
==========================================
+ Coverage 61.92% 64.62% +2.69%
==========================================
Files 50 50
Lines 8604 8604
==========================================
+ Hits 5328 5560 +232
+ Misses 3276 3044 -232 ☔ View full report in Codecov by Sentry. |
Hi @Melkiades, should I merge now or should I wait the removal of visual tests (snaps and involved tests)? I can also iterate over your branch if you need to. Let me know :) |
tests/testthat/setup.R
Outdated
# Folder where the snapshots are stored | ||
folder_to_copy <- system.file("snapshots_for_manual_tests", package = "flextable") | ||
|
||
# Get the path to the tests/testthat directory | ||
path_to_testthat <- system.file("tests", "testthat", package = "flextable") | ||
|
||
# Construct the path to the _snaps folder | ||
path_to_snaps <- file.path(path_to_testthat, "_snaps") | ||
|
||
file.copy(folder_to_copy, path_to_snaps, recursive = TRUE, overwrite = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to fix this, but it is dependent on the flag do_manual_msoffice_snapshot_testing
that can be set TRUE on local, so it should not be a problem on ci
So in this PR, I moved the snapshots into |
Hi @Melkiades my week will be quite busy, but I did not forget this PR. I will try to achieve it during one evening of this week or next week |
Thank you David! I think I found a solution over the weekend for the snapshots, I will complete this PR today, and then when you have time you can review it and add/change what you want or need ;) |
do_manual_msoffice_snapshot_testing <- FALSE | ||
copy_back_new_snapshots <- FALSE # if snapshots are updated can be rewritten back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the main drivers of the manual snapshot testing
invisible(TRUE) | ||
} | ||
|
||
handle_manual_snapshots <- function(snapshot_folder, snapshot_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function copy snapshots into the folder and removes them with withr::defer
withr::defer( | ||
{ | ||
snap_file <- file.path(path_to_snaps, snapshot_name) | ||
if (copy_back_new_snapshots) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copying back is available here, it is the only reason to do defer here
@davidgohel we might want to merge and then up the coverage in another PR. Here, we fix more the testing of snapshots, that now can be done on demand. I could not fully test it as I do not have MSOffice on the server I use, so if you have time to check that all paths and withr calls work, that would be great! :) |
@Melkiades Thanks, everything works. I'll have to make a minor correction for the visual tests. I'm merging so we can move forward |
I do not know the current coverage, also because I work from a server so I cannot check any word snapshot (which is the defualt for CI/CD, I think). On my machine the coverage is currently 60% with 400 missed lines for
as_flextable
. It should be doable. Beforehand, I moved out alllibrary
calls that should not be in tests if are betweenImports:
in the DESCRIPTION file. They should be anyway referenced::
if not in thetest_that()
window. For now, I am only checking if these work on the PR ci. I got many removals of snapshots and I do not know if it is expected (probably missing some snap-related libs due to the servers). So questions:Imports:
are not loaded directly in the testing, should I keep it like this? Note that if you need to do tests manually,devtools::load_all()
does load the imports from package in the working directory.