Closed
Bug 1252995
Opened 9 years ago
Closed 9 years ago
Add method names and uncovered lines to per-test coverage output
Categories
(Testing :: Code Coverage, defect)
Testing
Code Coverage
Tracking
(firefox48 fixed)
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: chmanchester, Assigned: sparky)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 8 obsolete files)
In addition to covered lines, we'd like to be able to get method names and uncovered lines. Greg has a patch for this we'd like to get reviewed and landed.
Assignee | ||
Comment 1•9 years ago
|
||
This is the function that gathers all uncovered lines. It does so by going through each script and getting all lines that were not covered and have a count of 0. If a script has no coverage, we consider all lines in that script as uncovered. Then, we add into tempCovered all the lines which have been covered so that if we hit a second access to the script which has no coverage, we won't consider them as uncovered. Finally, we retrieve all uncovered lines which held a count of 0 until the end.
Review commit: https://reviewboard.mozilla.org/r/37873/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37873/
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 2•9 years ago
|
||
This function is used to get the method names contained in the scripts. It returns an array containing keys in the form "lineNumber#methodName" that has each line number associated to a method. If the method is found to have an undefined name, we give it a name "undefined_integer" and every time we find a new undefined method, we increment the integer. There is the possibility that multiple functions can be caught on the same line. If a method has not been covered at all, we use lineNumber == '-1' to designate that it will not have any lines covered. This is needed to be able to have an empty covered array for the uncovered method.
Review commit: https://reviewboard.mozilla.org/r/37875/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37875/
Attachment #8726236 -
Flags: review?(cmanchester)
Assignee | ||
Comment 3•9 years ago
|
||
This part is the modification to recordTestCoverage. In addition to what it did before, it now gets methods, their coverage, and uncovered lines of the entire script. The methods are obtained by going through the array returned from getMEthodNames, seperating the keys returned, and placing them into approriate records. The uncovered lines are retrieved in the same way that covered lines were retrieved.
Review commit: https://reviewboard.mozilla.org/r/37877/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37877/
Attachment #8726237 -
Flags: review?(cmanchester)
Reporter | ||
Comment 4•9 years ago
|
||
Thanks for the patches, Greg. I'll have some feedback here by end of day tomorrow.
Something that may be nice to have is a "version" attribute to describe the jscov format we're producing. This would make parsing the jscov files easier later on each time we have a format change.
Reporter | ||
Updated•9 years ago
|
Attachment #8726235 -
Flags: review?(cmanchester)
Reporter | ||
Comment 6•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review34883
What would you think of a much simpler approach, which would be to find every line with code on it from getAllOffsets on each script, and compare that to the lines we have as covered? I think that would achieve what we're aiming for here.
::: testing/modules/CoverageUtils.jsm:104
(Diff revision 1)
> +
There are a couple of places mozreview is showing trailing white space, let's clean that up before checking this in. Many editors have a setting to show you this when you're typing, that can be quite helpful.
::: testing/modules/CoverageUtils.jsm:110
(Diff revision 1)
> + cov = s.getAllColumnOffsets();
Why is getAllOffsets not sufficient for this? I don't see us making meaningful use of the column info.
::: testing/modules/CoverageUtils.jsm:113
(Diff revision 1)
> + if(!currentUncovered[scriptName][lineNumber]){
> + currentUncovered[scriptName][lineNumber] = 0;
I see properties on `currentUncovered` intialized to an empty set (above, on line 106), indexing like this makes me think they should be initialized to an empty object.
::: testing/modules/CoverageUtils.jsm:129
(Diff revision 1)
> + if (!count){
> + if (!currentUncovered[scriptName][lineNumber]){
In practice, do we reach this often? I'm curious whether no coverage is something getOffsetsCoverage is intended to capture.
::: testing/modules/CoverageUtils.jsm:152
(Diff revision 1)
> + //Gather all lines uncovered based on whether they were counted or not.
Nit: I usually see a space after "//" in one-line comments.
Reporter | ||
Comment 7•9 years ago
|
||
Comment on attachment 8726236 [details]
MozReview Request: Bug 1252995 - Add method names and uncovered lines to per-test coverage output.
https://reviewboard.mozilla.org/r/37875/#review34887
::: testing/modules/CoverageUtils.jsm:184
(Diff revision 1)
> + let cov = s.getOffsetsCoverage();
> +
Should we consider the job of this function to be to associate line numbers with method names, ignoring coverage? This might allow us to simplify things a bit, provided the output doesn't become too large. If this is an issue, we may want to do this once at the end of the test run and store it a seperate file.
::: testing/modules/CoverageUtils.jsm:207
(Diff revision 1)
> + if (!this._allCoverage[scriptName]) {
> + this._allCoverage[scriptName] = {};
> + }
this._allCoverage isn't mentioned elsewhere in this function, this looks a bit out of place.
::: testing/modules/CoverageUtils.jsm:212
(Diff revision 1)
> + if (!methodNames[scriptName][key]) {
> + methodNames[scriptName][key] = key;
Can we model this as:
{
<script name>: {
<method name>: [ <lines> ]
...
}
}
?
Having our "key" be both the key and value in this object is a little weird.
::: testing/modules/CoverageUtils.jsm:212
(Diff revision 1)
> + if (!methodNames[scriptName][key]) {
> + methodNames[scriptName][key] = key;
Can we model this as:
{
<script name>: {
<method name>: [ <lines> ]
...
}
}
?
Having our "key" be both the key and value in this object is a little weird.
::: testing/modules/CoverageUtils.jsm:212
(Diff revision 1)
> + if (!methodNames[scriptName][key]) {
> + methodNames[scriptName][key] = key;
Can we model this as:
{
<script name>: {
<method name>: [ <lines> ]
...
}
}
?
Having our "key" be both the key and value in this object is a little weird.
Attachment #8726236 -
Flags: review?(cmanchester)
Reporter | ||
Comment 8•9 years ago
|
||
Comment on attachment 8726237 [details]
MozReview Request: Bug 1252995 - Add method anmes and uncovered lines to per-test coverage.
https://reviewboard.mozilla.org/r/37877/#review34889
I think some developments in the earlier commits will impact what we have here, so I'll hold off reviewing for now.
Attachment #8726237 -
Flags: review?(cmanchester)
Assignee | ||
Comment 9•9 years ago
|
||
https://reviewboard.mozilla.org/r/37873/#review34883
I think that this would be a great solution! I'm curious to see if this solution will catch more uncovered lines than what there is right now. I'll start implementing this.
Assignee | ||
Comment 10•9 years ago
|
||
https://reviewboard.mozilla.org/r/37873/#review34883
> In practice, do we reach this often? I'm curious whether no coverage is something getOffsetsCoverage is intended to capture.
Actually, it does return lines within a method or script which have not been counted. I am sure of that because the first few uncovered lines that I was catching were coming from here. However, I don't think this is useful anymore because I think they are now caught at lines 109-118 but I'll have to test that. If I change the way I get uncovered lines to the way you suggested above, I don't think this will be an issue anymore.
Assignee | ||
Comment 11•9 years ago
|
||
https://reviewboard.mozilla.org/r/37873/#review34883
> Why is getAllOffsets not sufficient for this? I don't see us making meaningful use of the column info.
With your proposed solution this shouldn't be an issue anymore. But, you are correct, getAllOffsets will be sufficient for this.
Assignee | ||
Comment 12•9 years ago
|
||
https://reviewboard.mozilla.org/r/37873/#review34883
> I see properties on `currentUncovered` intialized to an empty set (above, on line 106), indexing like this makes me think they should be initialized to an empty object.
I think this will be changed because of the propsed solution. But, if it doesn't I'll have it initialized to an empty object.
Assignee | ||
Comment 13•9 years ago
|
||
https://reviewboard.mozilla.org/r/37875/#review34887
> Should we consider the job of this function to be to associate line numbers with method names, ignoring coverage? This might allow us to simplify things a bit, provided the output doesn't become too large. If this is an issue, we may want to do this once at the end of the test run and store it a seperate file.
We definitely can and it would be much simpler. I think that the size will be increased by quite a bit, but I'd have to see by how much. It will go up by quite a bit though because there would be a lot of duplicate values in the methods and uncovered arrays. I'll test out this solution first and let you now how big the file gets.
> Can we model this as:
>
> {
> <script name>: {
> <method name>: [ <lines> ]
> ...
> }
> }
>
> ?
>
> Having our "key" be both the key and value in this object is a little weird.
I'll have it set up this way for the next review.
Assignee | ||
Comment 14•9 years ago
|
||
Comment on attachment 8726237 [details]
MozReview Request: Bug 1252995 - Add method anmes and uncovered lines to per-test coverage.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37877/diff/1-2/
Attachment #8726237 -
Attachment description: MozReview Request: Bug 1252995 - Add method names and uncovered lines to per-test coverage output. → MozReview Request: Bug 1252995 - Add method anmes and uncovered lines to per-test coverage.
Attachment #8726237 -
Flags: review?(cmanchester)
Assignee | ||
Comment 15•9 years ago
|
||
This method now compares all offsets to the lines covered to determine uncovered lines.
Review commit: https://reviewboard.mozilla.org/r/38827/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/38827/
Assignee | ||
Comment 16•9 years ago
|
||
The methods are now obtained along with the lines that they contain, regardless of coverage.
Review commit: https://reviewboard.mozilla.org/r/38829/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/38829/
Assignee | ||
Comment 17•9 years ago
|
||
It's now much simpler than what it was before. Methods, uncovered lines, and covered lines are all pushed to the record in a similar way
Review commit: https://reviewboard.mozilla.org/r/38853/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/38853/
Attachment #8728195 -
Flags: review?(cmanchester)
Assignee | ||
Comment 18•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/38855/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/38855/
Assignee | ||
Comment 19•9 years ago
|
||
https://reviewboard.mozilla.org/r/37875/#review34887
> We definitely can and it would be much simpler. I think that the size will be increased by quite a bit, but I'd have to see by how much. It will go up by quite a bit though because there would be a lot of duplicate values in the methods and uncovered arrays. I'll test out this solution first and let you now how big the file gets.
The JSON output is now quite large ~1,800kB for the single JSON from running browser/components/newtab/tests/browser/.
Assignee | ||
Updated•9 years ago
|
Attachment #8728195 -
Attachment is obsolete: true
Attachment #8728195 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8728196 -
Attachment is obsolete: true
Assignee | ||
Comment 20•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/1-2/
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8726237 -
Attachment is obsolete: true
Attachment #8726237 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8726236 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8726235 -
Attachment is obsolete: true
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8726235 -
Attachment is obsolete: false
Assignee | ||
Updated•9 years ago
|
Attachment #8726236 -
Attachment is obsolete: false
Assignee | ||
Updated•9 years ago
|
Attachment #8726237 -
Attachment is obsolete: false
Assignee | ||
Updated•9 years ago
|
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 21•9 years ago
|
||
This function is used to get the method names contained in the scripts. It returns an array containing keys in the form "lineNumber#methodName" that has each line number associated to a method. If the method is found to have an undefined name, we give it a name "undefined_integer" and every time we find a new undefined method, we increment the integer. There is the possibility that multiple functions can be caught on the same line. If a method has not been covered at all, we use lineNumber == '-1' to designate that it will not have any lines covered. This is needed to be able to have an empty covered array for the uncovered method.
* * *
Bug 1252995 - Method names revision.
This is the revision for getMethodNames. It now uses getAllOffsets to get the lines each method covers.
Review commit: https://reviewboard.mozilla.org/r/39361/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39361/
Attachment #8729639 -
Flags: review?(cmanchester)
Assignee | ||
Comment 22•9 years ago
|
||
* * *
Bug 1252995 - recordTestCoverage revision.
This is a modification to recordTestCoverage. It now get methods and all lines they cover, has a version control block, and gets uncovered lines also.
Review commit: https://reviewboard.mozilla.org/r/39363/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39363/
Attachment #8729640 -
Flags: review?(cmanchester)
Assignee | ||
Comment 23•9 years ago
|
||
Comment on attachment 8729639 [details]
MozReview Request: Bug 1252995 - Add method names and uncovered lines to per-test coverage output.
This function is used to get the method names contained in the scripts. It returns an array containing keys in the form "lineNumber#methodName" that has each line number associated to a method. If the method is found to have an undefined name, we give it a name "undefined_integer" and every time we find a new undefined method, we increment the integer. There is the possibility that multiple functions can be caught on the same line. If a method has not been covered at all, we use lineNumber == '-1' to designate that it will not have any lines covered. This is needed to be able to have an empty covered array for the uncovered method.
* * *
Bug 1252995 - Method names revision.
This is the revision for getMethodNames. It now uses getAllOffsets to get the lines each method covers.
Review commit: https://reviewboard.mozilla.org/r/39361/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39361/
Assignee | ||
Comment 24•9 years ago
|
||
Comment on attachment 8729640 [details]
MozReview Request: Bug 1252995 - Add method anmes and uncovered lines to per-test coverage.
* * *
Bug 1252995 - recordTestCoverage revision.
This is a modification to recordTestCoverage. It now get methods and all lines they cover, has a version control block, and gets uncovered lines also.
Review commit: https://reviewboard.mozilla.org/r/39363/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39363/
Reporter | ||
Comment 25•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review36237
Attachment #8726235 -
Flags: review?(cmanchester)
Reporter | ||
Updated•9 years ago
|
Attachment #8729639 -
Flags: review?(cmanchester)
Reporter | ||
Updated•9 years ago
|
Attachment #8729640 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8729639 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8729640 -
Attachment is obsolete: true
Assignee | ||
Comment 26•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/2-3/
Attachment #8726235 -
Attachment description: MozReview Request: Bug 1252995 - Add method names and uncovered lines to per-test coverage output. → MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 27•9 years ago
|
||
This method gets method names and the lines each method spans. It uses getAllOffsets to get the lines.
Review commit: https://reviewboard.mozilla.org/r/39569/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39569/
Attachment #8729738 -
Flags: review?(cmanchester)
Assignee | ||
Comment 28•9 years ago
|
||
This is a modification to recordTestCoverage. It now gathers methods and the lines each span, uncovered lines, and now also places a version control block at the beginning of every artifact.
Review commit: https://reviewboard.mozilla.org/r/39571/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/39571/
Attachment #8729739 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8728193 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8728194 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8726237 -
Attachment is obsolete: true
Assignee | ||
Updated•9 years ago
|
Attachment #8726236 -
Attachment is obsolete: true
Reporter | ||
Comment 29•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review36427
Looking good, a few small things we should address before landing.
::: testing/modules/CoverageUtils.jsm:101
(Diff revision 3)
> +CoverageCollector.prototype._getUncoveredLines = function() {
> + let uncoveredLines = {};
> + let tempUncov = {};
> + this._scripts.forEach(s => {
> + let scriptName = s.url;
> + let cov2 = s.getAllOffsets();
Let's name this variable something else, like "scriptOffsets", it's not recording coverage here.
::: testing/modules/CoverageUtils.jsm:104
(Diff revision 3)
> + if(!tempUncov[scriptName]){
> + tempUncov[scriptName] = cov2;
It looks like this needs to be initialized to an empty object.
::: testing/modules/CoverageUtils.jsm:109
(Diff revision 3)
> + if(!tempUncov[scriptName]){
> + tempUncov[scriptName] = cov2;
> + }
> +
> + // Get all lines in the script
> + cov2.forEach( function(element, index, array) {
Unused `array` parameter, no need to specify it in this signature.
::: testing/modules/CoverageUtils.jsm:121
(Diff revision 3)
> + });
> + });
> +
> + // For all covered lines, set their value to -1
> + for (let scriptName in this._allCoverage){
> + for(let key in this._allCoverage[scriptName]){
Not: space after `for`.
::: testing/modules/CoverageUtils.jsm:123
(Diff revision 3)
> +
> + // For all covered lines, set their value to -1
> + for (let scriptName in this._allCoverage){
> + for(let key in this._allCoverage[scriptName]){
> + let [lineNumber, columnNumber, offset] = key.split('#');
> + tempUncov[scriptName][lineNumber] = -1;
Alternatively, remove entries here (this would simplify the loop below as well).
Attachment #8726235 -
Flags: review?(cmanchester)
Reporter | ||
Comment 30•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
https://reviewboard.mozilla.org/r/39569/#review36431
Very nice. I'd just like to take another look after we resolve the question below.
::: testing/modules/CoverageUtils.jsm:156
(Diff revision 1)
> + // Give method a default name if it does not exist
> + if (!method){
> + method = "unknown_" + temp++;
> + }
Can we just return early if we have an unnamed method? Are these going to end up being useful in the output?
::: testing/modules/CoverageUtils.jsm:167
(Diff revision 1)
> + * Get all lines contained within the method and
> + * push a record of the form:
> + * <method name> : <lines covered>
> + */
> + covTemp.forEach(function (element, index, array){
> + if(!element){
Nit: space after `if`.
Attachment #8729738 -
Flags: review?(cmanchester)
Reporter | ||
Comment 31•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
https://reviewboard.mozilla.org/r/39571/#review36435
This is close. Can we see the result of this modification on try before the next round of review? Thanks.
::: testing/modules/CoverageUtils.jsm:186
(Diff revision 1)
> + let methods = this._getMethodNames(testName);
> + let uncoveredLines = this._getUncoveredLines(testName);
Neither of these methods take an argument, you can leave `testName` out here.
::: testing/modules/CoverageUtils.jsm:196
(Diff revision 1)
> +
> for (let scriptName in rawLines) {
> let rec = {
> testUrl: testName,
> sourceFile: scriptName,
> - covered: []
> + method: [],
Let's call this "methods" and re-name the variable above, and let's make it an object, not an array.
::: testing/modules/CoverageUtils.jsm:203
(Diff revision 1)
> + let methodRec = {method: methodLines, cov: covering};
> + rec.method.push(methodRec)
If we're able to make this an object, not an array, we can use the method name as a key, and the array of covered lines as a value. How does that sound?
Attachment #8729739 -
Flags: review?(cmanchester)
Assignee | ||
Comment 32•9 years ago
|
||
https://reviewboard.mozilla.org/r/39569/#review36431
> Can we just return early if we have an unnamed method? Are these going to end up being useful in the output?
We can return early here but if we do then we miss the first script which seems to almost always be the globals of the script. I say almost always because I don't remember any source file that doesn't have it. I'm not sure if that's useful information though. The other unnamed methods seem to be a limitation of the Debugger, so maybe if the limitations are overcome in the future they could become as useful as the named ones. Should I take it out for now?
Assignee | ||
Comment 33•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/3-4/
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 34•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39569/diff/1-2/
Attachment #8729738 -
Flags: review?(cmanchester)
Assignee | ||
Updated•9 years ago
|
Attachment #8729739 -
Flags: review?(cmanchester)
Assignee | ||
Comment 35•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39571/diff/1-2/
Reporter | ||
Updated•9 years ago
|
Attachment #8726235 -
Flags: review?(cmanchester)
Reporter | ||
Comment 36•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review39345
This looks good. I'm going to hold off on r+ until we get this tested on try and we can sanity check this all fits together as expected. I have a few more comments, which you may want to address if you feel inclined, but are strictly optional for this bug.
::: testing/modules/CoverageUtils.jsm:104
(Diff revision 4)
> + this._scripts.forEach(s => {
> + let scriptName = s.url;
> + let scriptOffsets = s.getAllOffsets();
> +
> + if (!tempUncov[scriptName]){
> + tempUncov[scriptName] = {};
This is fine, but a Set might be a more appropriate data structure now that I think about it. I should have noticed this before. Convert before landing if you think that's a worthwhile change.
::: testing/modules/CoverageUtils.jsm:122
(Diff revision 4)
> +
> + // For all covered lines, set their value to 0
> + for (let scriptName in this._allCoverage){
> + for (let key in this._allCoverage[scriptName]){
> + let [lineNumber, columnNumber, offset] = key.split('#');
> + tempUncov[scriptName][lineNumber] = 0;
Alternatively, use the `delete` operator here.
::: testing/modules/CoverageUtils.jsm:133
(Diff revision 4)
> + for (let line in tempUncov[scriptName]){
> + if (!uncoveredLines[scriptName]){
> + uncoveredLines[scriptName] = new Set();
> + }
> + if (tempUncov[scriptName][line]){
> + uncoveredLines[scriptName].add(parseInt(line,10));
Nit: space after `,`
Reporter | ||
Updated•9 years ago
|
Attachment #8729738 -
Flags: review?(cmanchester)
Reporter | ||
Comment 37•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
https://reviewboard.mozilla.org/r/39569/#review39349
Looking good. Just a few nits that should be addressed.
::: testing/modules/CoverageUtils.jsm:152
(Diff revision 2)
> + let scriptOffsets = s.getAllOffsets();
> +
> + if (!methodNames[scriptName]){
> + methodNames[scriptName] = {};
> + }
> + // Give method a default name if it does not exist
This comment should be updated now.
::: testing/modules/CoverageUtils.jsm:153
(Diff revision 2)
> + if (!method){
> + return;
> + }
This early return could be moved closer to the declaration of `method`. I think this would make the function a little easier to read.
::: testing/modules/CoverageUtils.jsm:162
(Diff revision 2)
> + scriptOffsets.forEach(function (element, index){
> + if (!element){
> + return;
> + }
> + tempMethodCov.push(index);
> + });
To save space, we may be able to just store [start, end] instead of every line, but let's see how this goes, we may not need to.
Reporter | ||
Updated•9 years ago
|
Attachment #8729739 -
Flags: review?(cmanchester)
Reporter | ||
Comment 38•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
https://reviewboard.mozilla.org/r/39571/#review39357
This is pretty much ready to land, I'll go back over this once we've seen it on try and you've updated any issues. Thanks!
::: testing/modules/CoverageUtils.jsm:197
(Diff revision 2)
> + for (let methodLines in methods[scriptName]){
> + rec.methods[methodLines] = methods[scriptName][methodLines];
Is `methodLines` a good name for this variable? It's more like `methodName`, right?
Assignee | ||
Comment 39•9 years ago
|
||
https://reviewboard.mozilla.org/r/37873/#review39345
> Alternatively, use the `delete` operator here.
I tried using the delete operator but it isn't deleting anything for some odd reason. I've got something else I'm going to try to get it working but if it doesn't work then I'll just leave it as it is.
Assignee | ||
Comment 40•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/4-5/
Attachment #8726235 -
Flags: review?(cmanchester)
Attachment #8729738 -
Flags: review?(cmanchester)
Attachment #8729739 -
Flags: review?(cmanchester)
Assignee | ||
Comment 41•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39569/diff/2-3/
Assignee | ||
Comment 42•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39571/diff/2-3/
Reporter | ||
Comment 43•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review40385
::: testing/modules/CoverageUtils.jsm:104
(Diff revisions 4 - 5)
> this._scripts.forEach(s => {
> let scriptName = s.url;
> let scriptOffsets = s.getAllOffsets();
>
> if (!tempUncov[scriptName]){
> - tempUncov[scriptName] = {};
> + tempUncov[scriptName] = new Set();
If we move to a Set here, we should also modify interactions with the data structure, so below we'd have `tempUncov[scriptName].add(index)`, etc.
Attachment #8726235 -
Flags: review?(cmanchester)
Reporter | ||
Comment 44•9 years ago
|
||
I have this on try here: https://treeherder.mozilla.org/#/jobs?repo=try&revision=232db2940e992fe4c998dbb0a498703fbf463e0d
Assuming I applied everything correctly, we should have coverage json to look at in a few hours.
Comment 45•9 years ago
|
||
As I'm seeing it the "version" property is currently inside an object (the first one) inside the outermost array. This requires the parser to know that the first object inside the array is not like the others, which I think is not optimal. A better way to organize it is to do something like
{
"meta": {
"version": 1
},
"data": [
// the original array of jscov objects
]
}
Comment 46•9 years ago
|
||
Also, I think this format is nicer for the "methods" property:
"methods": [
{
"name": "XPCU_generateQI",
"covered": [
110,
...
]
},
{
"name": "XPCU_generateCI",
"covered": [
132,
...
],
},
...
]
It is more consistent with the existing object structure.
Reporter | ||
Comment 47•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
https://reviewboard.mozilla.org/r/39569/#review41153
Attachment #8729738 -
Flags: review?(cmanchester) → review+
Reporter | ||
Comment 48•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
https://reviewboard.mozilla.org/r/39571/#review41155
I think Trung's suggestion from comment 45 makes a lot of sense, but no need to block landing this!
Attachment #8729739 -
Flags: review?(cmanchester) → review+
Assignee | ||
Comment 49•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/5-6/
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 50•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39569/diff/3-4/
Assignee | ||
Comment 51•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39571/diff/3-4/
Reporter | ||
Comment 52•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review41613
::: testing/modules/CoverageUtils.jsm
(Diff revisions 5 - 6)
> - for (let line in tempUncov[scriptName]){
> - if (!uncoveredLines[scriptName]){
> + if (!uncoveredLines[scriptName]){
> - uncoveredLines[scriptName] = new Set();
> + uncoveredLines[scriptName] = new Set();
> - }
> + }
> - if (tempUncov[scriptName][line]){
> - uncoveredLines[scriptName].add(parseInt(line, 10));
> + for (let line of tempUncov[scriptName]){
> + uncoveredLines[scriptName].add(line);
> - }
I was going to suggest just doing `uncoveredLines[scriptName] = tempUncov[scriptName];`, but looking at this again, I think we can just get rid of `tempUncov` altogether and modify `uncoveredLines` througout.
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 53•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/6-7/
Attachment #8726235 -
Flags: review?(cmanchester)
Assignee | ||
Comment 54•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39569/diff/4-5/
Assignee | ||
Comment 55•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39571/diff/4-5/
Reporter | ||
Comment 56•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
https://reviewboard.mozilla.org/r/37873/#review42041
Looking good. Just one small nit that should be fixed before landing. Thanks!
::: testing/modules/CoverageUtils.jsm:111
(Diff revisions 6 - 7)
> - if (!tempUncov[scriptName].index){
> - tempUncov[scriptName].add(index);
> + if (!uncoveredLines[scriptName].index){
> + uncoveredLines[scriptName].add(index);
> }
Nit: No need to guard here, the set will not retain duplicates.
Attachment #8726235 -
Flags: review?(cmanchester) → review+
Assignee | ||
Comment 57•9 years ago
|
||
Comment on attachment 8726235 [details]
MozReview Request: Bug 1252995 - Add a method to get uncovered lines.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/37873/diff/7-8/
Assignee | ||
Comment 58•9 years ago
|
||
Comment on attachment 8729738 [details]
MozReview Request: Bug 1252995 - Add a method to get lines and name of methods.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39569/diff/5-6/
Assignee | ||
Comment 59•9 years ago
|
||
Comment on attachment 8729739 [details]
MozReview Request: Bug 1252995 - recordTestCoverage modification.
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/39571/diff/5-6/
Comment 60•9 years ago
|
||
Comment 61•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b72f1f574aba
https://hg.mozilla.org/mozilla-central/rev/1602320ae208
https://hg.mozilla.org/mozilla-central/rev/c155349cb403
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in
before you can comment on or make changes to this bug.
Description
•