Bug 789401 - CoverObject, work in progress #624

Merged
merged 1 commit into from Jan 7, 2013

Conversation

Projects
None yet
2 participants

@Gozala Gozala commented on an outdated diff Oct 24, 2012

lib/sdk/test/harness.js
@@ -203,6 +204,15 @@ function cleanup() {
"be indicative of aberrant behavior.");
}
+ // read the coverobject
+ if (loader.globals.global) {
+ let CO = loader.globals.global['__$coverObject'];
@Gozala

Gozala Oct 24, 2012

Member

Could you please add comment explaining where that property could have came from. Also assuming that CO is not undefined feels little fragile tome. Could you please add || {} at least ?

@Gozala Gozala commented on an outdated diff Oct 24, 2012

lib/sdk/test/harness.js
@@ -214,6 +224,19 @@ function cleanup() {
};
setTimeout(showResults, 1);
+
+ // dump the coverobject
+ if (Object.keys(coverObject).length){
+ const self = require('self');
+ const {pathFor} = require("sdk/system");
+ let file = require('file');
+ let out = file.join(pathFor('Home'),self.id+'.coverstats.json');
@Gozala

Gozala Oct 24, 2012

Member

I would rather expect that json to be written into CWD, also maybea it's should have a cfx option to enable this. I don't mind to enable coverage by default, but I do mind writing .json files to users machine on each cfx test.

Member

gregglind commented Nov 3, 2012

@Gozala , how does once get / write to CWD from inside the test harness?

Member

Gozala commented Nov 5, 2012

I believe pathFor('CurProcD') should do it. There is more complete list here:
https://developer.mozilla.org/en-US/docs/Code_snippets/File_I_O#Getting_files_in_special_directories

Member

gregglind commented Nov 6, 2012

CurProcD is wrong too :(

CurProcD: /Applications/Firefox.app/Contents/MacOS

Maybe it needs to be passed in from cfx very early in as a special build variable as the source dir.

Member

Gozala commented Nov 26, 2012

Oh I guess it's related to the way cfx invokes it :(
I guess you could set actual cwd through cfx in an env variable or something and that use that.

Member

Gozala commented Jan 3, 2013

Hi @gregglind are you interested in running this to completion ? Otherwise we should consider closing this pull request.

Member

gregglind commented Jan 4, 2013

@Gozala, I am not sure how to pull this in. I will review things today, and see where it is at.

Member

gregglind commented Jan 4, 2013

@Gozala, updated the code to write to source directory. Better link to usage recipe.

@Gozala Gozala added a commit that referenced this pull request Jan 7, 2013

@Gozala Gozala Merge pull request #624 from gregglind/coverage
Bug 789401 - CoverObject, work in progress r=@gozala
2b94404

@Gozala Gozala merged commit 2b94404 into mozilla:master Jan 7, 2013

Member

gregglind commented Jan 7, 2013

Needs a minor fix:

 coverObject = loader.globals.global['__$coverObject'] || {};
Member

Gozala commented Jan 7, 2013

@gregglind could you plz send pull request

@gregglind gregglind added a commit to gregglind/addon-sdk that referenced this pull request Jan 7, 2013

@gregglind gregglind Handle undefined __$coverObject (re #624)
If `CoverJS` is not installed, `globals.global.__$coverObject` will be
undefined.  Handle this case.
1d07713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment