-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Generate (test) coverage statistics #8632
Comments
Note that while Furthermore, note that the "transpilation with Babel" step can be skipped, if the |
@Rob--W I would like to work on this |
It's yours! Let us know (preferably on IRC) if you have questions. |
@timvandermeij I am thinking to use Karma tool.It works with the istanbul code coverage engine.Statistics can be checked for the tests execution, HTML reports can be made from it.Is it a good way to start? |
Using Karma I got test reports https://drive.google.com/file/d/0ByddvU1PKkWaWEZTWHFYT0Y0aTg/view?usp=sharing |
@Divya063 Could you share your code, e.g. by pushing your current code to a branch on your pdf.js fork on Github? I wonder whether webpack or babel is being run when necessary. And which version of Node.js are you using? |
Thank you for the response,Node version is 6.11.1. Here is the link to branch https://github.com/Divya063/pdf.js/tree/dev |
The errors are:
This indicates that the code is not transpiled before use. Currently there is built-in support for ES modules is not enabled by default in any browser (more info), so code needs to be transpiled first. I have edited my initial post to point out where the transpilation is configured in PDF.js's build system. Perhaps you can try to use an existing plugin to integrate istanbul and babel. A quick search shows https://github.com/istanbuljs/babel-plugin-istanbul, but there may be other options too. (and Firefox's current stable version is 55. You were testing with Firefox 43, which is ancient and not supported. I suggest that you upgrade to a recent version of Firefox before testing again) |
@Rob--W Thank you for indicating the errors.I will update soon with the results. |
@Rob--W I transpiled the code using |
Can you share the error messages? And if possible, try to use webpack instead of browserify, because webpack is what we use already. Doing so allows us to instrument the code that is actually used in the browser. And I also see that you are checking in .idea and other user-specific project/IDE files. When you contribute to an existing project, it's better to not add unrelated files to the project, because it clutters the repository and causes merge conflicts. In the final pull request, these files should not be included. |
Is this issue still up? If yes, I would like to work on it. |
Yes, feel free to work on this. |
@timvandermeij
I get the following error
I tried looking this uphere and here but to no avail. Any help on what the problem might be ? |
It's hard to tell without seeing the code. Could you push the code to a branch so contributors here can look along with you? |
@timvandermeij here it is. Please ignore the gem file. i've already removed it. |
Any comments @timvandermeij |
From a bit of Googling it looks like this error means that |
@timvandermeij
On googling, it seems that these are very common errors. and the error basically lies with istanbul. I tried switching between different versions of the same but the error kept occurring. However, at all places the testing has been done by mocha and not by lint or unittest etc. and thus most(almost) of the resolutions too are for mocha only. These were some sources I looked up gotwarlost/istanbul#262 The build gets passed on travis ( https://travis-ci.org/shikhar-scs/pdf.js/jobs/318422621 )but again the coverage is not generated. |
I'm not really sure why that's happening, but I also find a lot of people that did it successfully with Jasmine, so it must be possible. Could you try if https://bryce.fisher-fleig.org/blog/setting-up-istanbul-with-jasmine/index.html works for you? First just try those exact steps to see if works stand-alone, and then try to integrate it in PDF.js. |
@timvandermeij on it
This error is coming up with each and every js file and I'll work on it and file a PR soon. |
Here they are : the build passing and calling for coverage. However, as the import and export statements exist, even after reaching those files, they arent fully tested and thus we are getting 0% coverage reports. As far as I know I need to babelify these files to ES6 before jasmine testing and that is proving to be a problem. How do I provide ES6 code to jasmine ? |
You're indeed getting closer to the solution. From the coverage reports it looks like you run the coverage on the Line 965 in 6ac9e1c
Line 985 in 6ac9e1c
|
The problem was I was running the tests in the wrong folder.
Thank you for pointing this out. Finally, we are able to generate reports 🎉 and though they look a bit sad but reading the exact files will get you the reason why -
I obviously havent uploaded the generated reports my self but have hosted them on a link here http://pdfjscoveragereport.bitballoon.com. Please visit these links and you will get the exact report expected. However these results are not reflected on But still I hope all of this helps finally, though, our last problem is to show these reports somehow on coveralls. This is the link for my latest build.https://travis-ci.org/shikhar-scs/pdf.js Apart from the reports not being generated on coveralls.io everything is fine I guess. So shall I generate a PR as it will attract attention from many more people and might solve this issue earlier instead? |
Nice work! It's really good to have an idea of the coverage and the reports finally give us that. Indeed it clearly shows that we need a lot more unit testing, but all the methods we recently added unit tests for are indeed shown as covered in the report, so that looks perfectly fine. I do wonder if it would be possible to run the coverage over the source files instead of the built files. That makes it easier to understand, because now at http://pdfjscoveragereport.bitballoon.com/lib/display/metadata.js.html I see line 28 not being covered while that's not our code, but automatically generated code instead. If it turns out to be hard, we can just do the current approach as a first version and do this in a follow-up issue.
Yes, that's a good idea. We can then start the review process and see which issues are left to address. |
While it's certainly true that we could do with a lot more unit-tests, there're large portions of the code-base that probably won't ever get anywhere near "good" enough test-coverage just from unit-tests alone sadly. As mentioned in #8632 (comment) there's a few different test-suites, and unless I'm mistaken getting coverage results from |
This morning I've extensively tried finding coverage reports in all of the folders individually using the statement Though tests report are getting generated at times (not always), this is happening because of the one or two ES6 format js files lying in the specific directories (which is only bringing <2~3% of coverage reports). Sadly, any js file which contains the
And with this error, the file is not checked for coverage at all and thus returns a 0% report.
Again, the source folder contains files which have import and export statements and therefore the above errors occur because of which the related files are not checked at all, leading to 0% coverage. Thus, it is imperative that we test in the build folder itself.
@Snuffleupagus Where do these specific tests lie ? We can try testing them directly using the jasmine-node statement mentioned above.
Yep, we could rather do that.
Sure, I'll start with that. |
The PR at #9308 has shown an example of test coverage for the unit tests only. The generated reports provide little value because our set of unit tests is very small. For more details, see #9308 (comment) So, to get browser tests, we need:
To address 1), After finishing step 1, the browser tests will have a
|
@Rob--W Thanks for such a detailed review. I'll follow up and revert back as soon as possible. |
This comment offers tips for the implementation, and addresses the questions from #9308 (comment)
This instrumentation can be done on the fly while the program is being run (e.g. when you run In your current PR at #9308, you are invoking To get useful coverage reports, the coverage reports are preferably at a module level. This is a step ahead: you need to integrate But before diving in so deeply, let's start with something simpler: getting coverage reports from the browser. We have two ways of running tests in the browser, After doing that, you need to change Once you have replaced the normal |
@Rob--W I'm currently not available till the new year ... I'll catch on for sure after that |
@Rob--W |
For example, you can check whether a certain parameter is set in the query string ( |
@Rob--W I did manage to create a similar parameter in the Also if you could provide me links for joining the IRC channel or slack/gitter/mailing list specific to pdf.js . It would help me to get my doubts clear earlier |
@Rob--W Is the issue still up? If yes, I would like to work on it. |
The first attempt for this is in #9308, so you can use that as inspiration. Let's focus on getting a minimal version working, i.e., one that only works locally. It doesn't have to work on the bots or Travis CI; if we can make coverage reports locally that's already very significant. For locally, it would be good to make a command called |
@timvandermeij is it still active? I can give it a go as well |
Yes, feel free to work on this! We should start simple; see #8632 (comment) for a possible approach. |
@timvandermeij wondering if I can give this a shot? One larger question I have is if it's possible to use an npm script to generate the report instead, or if it has to be a I don't have too much familiarity with |
I don't think anyone is working on this, so go ahead! It's important to keep it simple for the initial patch. Since we use Gulp as our main tooling, it's preferred to use that, but we're also open for other suggestions. Refer to #8632 (comment) for implementation ideas. It doesn't require much experience with Gulp though because Gulp is a fairly simple task runner, i.e., it mostly wraps anything you would also do in an NPM script. Take a look at the Gulpfile to get some inspiration. |
I would like to work on this. Is the issue still open? And where can I get a better understanding of the bug? |
Thank you so much for the update. I think I can start working on it? Where
can I get more information? About the issue and rest of it ??
…On Sat, 16 May 2020, 5:56 pm Rob Wu, ***@***.***> wrote:
@jezhou <https://github.com/jezhou> was working on this and has made some
progress in #11580 <#11580>. The PR
hasn't recently been updatedt though.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8632 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKUZ65CGSIZF6OMFZWENWF3RR2A77ANCNFSM4DSK7SGQ>
.
|
I would like to work on this. Is the issue still open? |
To identify parts of our code that are not covered by tests, or dead code in practice, generating coverage reports would be helpful. Another use case is to quickly identify which parts of PDF.js are relevant when analysing an issue in a specific PDF file (this can especially be useful to new contributors).
There are multiple tools, but I have had a good experience with https://github.com/gotwarlost/istanbul.
It can be integrated with Travis, and the results can be published to an external service such as coveralls, see e.g. https://coveralls.io/github/Rob--W/cors-anywhere?branch=master (integrated with Rob--W/cors-anywhere@f9af03e).
PDF.js has different ways of execution that I know of (see
gulpfile.js
for more details):generic
build target, which uses code transpiled with babel and then bundled with webpack (configured in gulpfile.js).generic
build target, just like browsertest)Ideally we would obtain coverage statistics for the original sources, but to start with we could also settle for coverage statistics on the generated JS files that directly run in the browser / Node.js (if it is easier).
The text was updated successfully, but these errors were encountered: