Skip to content
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

Initialize var suites early #112

Conversation

randakar
Copy link
Contributor

@randakar randakar commented Dec 5, 2016

As #61 (comment)
Minor cleanup. Doing it this way should be faster though (no constructor call overhead, less code to begin with).

Credit goes to https://github.com/robinj for this one. I just implemented it.

As karma-runner#61 (comment)
Minor cleanup. Doing it this way should be faster though (no constructor call overhead, less code to begin with).
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@randakar
Copy link
Contributor Author

randakar commented Dec 5, 2016

I signed it.

@googlebot
Copy link

CLAs look good, thanks!

Copy link

@robinj robinj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@dignifiedquire
Copy link
Member

Are you sure you can remove the init from run_start? This way if there are multiple runs it does not get reset

@dignifiedquire
Copy link
Member

I'm especially thinking about runs with autoWatch: true

@randakar
Copy link
Contributor Author

randakar commented Dec 5, 2016

The reset is exactly what was causing issues. In some cases the onRunComplete() event would reset the suites object (set it to null) and then a different run (that was running simultaneously) would access it. Kaboom.

See the commit merged to the tip of master - there's a reason that is done.
I have made a second pull request that nulls the individual suite stored in the suites object when the run ends. That way memory is still cleared after each run (hopefully preventing a massive leak).

@dignifiedquire dignifiedquire merged commit e09acb2 into karma-runner:master Dec 5, 2016
@dignifiedquire
Copy link
Member

Thanks :octocat:

@randakar randakar deleted the feature/issue-61-initialize-suites-early branch December 5, 2016 14:31
@randakar
Copy link
Contributor Author

randakar commented Dec 5, 2016

As an aside, I'm pretty sure a casual look at other reporters would show a repeat of this exact same pattern.

The only one I have in our builds is the Jenkins reporter, and that one does this:

this.onRunStart = function(browsers) {
suites = Object.create(null);
xml = builder.create('testsuites');

So there's probably an opportunity there for further patches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants