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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timing issue when running tests #88

Merged
merged 1 commit into from
Nov 4, 2015
Merged

Conversation

mrcljx
Copy link
Contributor

@mrcljx mrcljx commented Nov 4, 2015

Ran into this a few times.

Bacon::Error: #<XcodeInstall::Xcode:0x007fcfbd7003c0 @date_modified=1446633908, @name="6.3.2 GM seed", @path="/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_seed.dmg", @url="https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_seed.dmg", @release_notes_url="https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_Seed_Release_Notes.pdf", @version=#<Gem::Version "6.3.2">>.==(#<XcodeInstall::Xcode:0x007fcfbd7023f0 @date_modified=1446633909, @name="6.3.2 GM seed", @path="/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_seed.dmg", @url="https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_seed.dmg", @release_notes_url="https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.3.2_GM_seed/Xcode_6.3.2_GM_Seed_Release_Notes.pdf", @version=#<Gem::Version "6.3.2">>) failed
  spec/prerelease_spec.rb:45:in `block (2 levels) in <module:XcodeInstall>': XcodeInstall::Installer - can parse prereleases from 20150508
  spec/prerelease_spec.rb:41:in `block in <module:XcodeInstall>'
  spec/prerelease_spec.rb:4:in `<module:XcodeInstall>'
  spec/prerelease_spec.rb:3:in `<top (required)>'

Happens in the prerelease-spec when those lines are executed during different seconds of the time:

prereleases = parse_prereleases('20150414')
prereleases.should == [Xcode.new_prerelease('6.4', '/Developer_Tools/Xcode_6.4_Beta/Xcode_6.4_beta.dmg', '/Developer_Tools/Xcode_6.4_Beta/Xcode_6.4_beta_Release_Notes.pdf')]

I know, this fix doesn't fix the test but changes library code 馃槺.
The alternative solution would have been to mock Time.now.

Semantic implications: This effectively moves items from the
back to the front of the result of parse_seedlist if they don't have
a dateModified field which doesn't matter as far as I can tell.
This could be prevented by setting dateModified to INT_MAX or
changing the comparator block to handle 0 differently.

Semantic implications: This effectively moves items from the
back to the front of the result of `parse_seedlist` if they don't have
a `dateModified` field which doesn't matter as far as I can tell.
neonichu added a commit that referenced this pull request Nov 4, 2015
Fix timing issue when running tests
@neonichu neonichu merged commit 9623b40 into xcpretty:master Nov 4, 2015
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.

None yet

2 participants