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

don't call extends.nonEnum in spy.resetHistory #1984

Merged
merged 5 commits into from Feb 26, 2019
Merged

don't call extends.nonEnum in spy.resetHistory #1984

merged 5 commits into from Feb 26, 2019

Conversation

Flarna
Copy link
Contributor

@Flarna Flarna commented Feb 25, 2019

Purpose (TL;DR) - mandatory

Fixes #1983 by not calling extends.nonEnum() in spy.resetHistory()

It seems that extends.nonEnum() is significant slower then just setting properties. By ensuring that the properties on the proxy exist as non enumerable during creation it's not needed to use extends.nonEnum() during updating them.

Refs: #1975

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Not sure what to write here as there is no functional change...

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@mantoni
Copy link
Member

mantoni commented Feb 25, 2019

Oh, nice! Is there already a test verifying that resetHistory doesn't make the properties enumerable again? If not, it'd be great to have one.

@Flarna
Copy link
Contributor Author

Flarna commented Feb 25, 2019

Well, seems in #1975 no test was added to verify that spy/subs/.. do not expose any enumerable properties.

I will add some test for this.

@Flarna
Copy link
Contributor Author

Flarna commented Feb 25, 2019

@ehmicky I found that an enumerable property named fakes is added if I call spy.withArgs(1). is this one of the properties you kept visible because it broke the tests?

@ehmicky
Copy link
Contributor

ehmicky commented Feb 25, 2019

@Flarna I unfortunately don't remember. However I do remember that I kept few properties visible because it broke the tests and/or it was introducing too many changes in a codebase I am not familiar with.

- fix spy.fakes should be non enumerable
- add tests
@Flarna
Copy link
Contributor Author

Flarna commented Feb 25, 2019

Added tests.
Additionally fixed mirroring of properties on spied function and make property fakes non enumerable.
If I should split this into two PRs let me know.

I found that stubs still have their properties enumerable. It would be quite easy to change this but I don't think I should add this here.

@mantoni
Copy link
Member

mantoni commented Feb 26, 2019

Thanks for putting this together. There is no need to split this into separate PRs.

However, I'd like those tests to be more focused on the enumerable porperties. We're already testing the spy functionality extensively. I can help and change them myself, if you give me permission to push to this PR.

@Flarna
Copy link
Contributor Author

Flarna commented Feb 26, 2019

@mantoni You should have permissions to add commits (according to the checkbox Allow edits from maintainers.).

The main idea here was to call serveral spy APIs to ensure that they don't add any enumerable properties. Maybe just remove the asserts there and keep only that ones checking the enumerable properties?

@mantoni
Copy link
Member

mantoni commented Feb 26, 2019

Yeah, that should be good enough I think 👍

test/spy-test.js Outdated Show resolved Hide resolved
@mantoni mantoni merged commit d0c073c into sinonjs:master Feb 26, 2019
@mantoni
Copy link
Member

mantoni commented Feb 26, 2019

Thank you 👍

@Flarna Flarna deleted the fix-performance-degrade branch February 26, 2019 20:34
@mroderick
Copy link
Member

This has been published as sinon@7.2.5.

@3z3qu13l
Copy link

Could you update Changelog and create new release based on 7.2.5 plz ?
Thanks

@mantoni
Copy link
Member

mantoni commented Feb 28, 2019

Sure thing. Will do right now.

@mantoni
Copy link
Member

mantoni commented Feb 28, 2019

@mroderick Do you have pending commits for master to push maybe?

@mantoni
Copy link
Member

mantoni commented Feb 28, 2019

@3z3qu13l Change log and documentation page have been updated.

franck-romano pushed a commit to franck-romano/sinon that referenced this pull request Oct 1, 2019
- don't call extends.nonEnum in spy.resetHistory
- fix that mirrored properties are kept enumerable
- fix spy.fakes should be non enumerable
- add tests
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.

7.2.4 is significant slower than 7.2.3
5 participants