[PATCH] Fixes MSpec on Windows
Reported by Luis Lavena | April 20th, 2008 @ 04:52 PM | in 1.0 preview
MSpec fail on some specs and some matchers in Windows. The attached patches fixes that.
Comments and changes to this ticket
-
-
Brian Ford April 21st, 2008 @ 09:01 AM
While this patch is only for MSpec, it does not uniformly address the issue of temp directories for the ruby specs. We don't want to have stdlib dependencies in the core lib specs, so this solution doesn't translate.
I don't consider the name of the temp directory to be a platform issue (i.e. there is not really anything in a platform that dictates where you put temp files, there is only a convention). Rather, this is an environment issue.
Given this,
mkdir /tmpis the simplest solution. MSpec specs pass 100% for me on Windows XP with that.Another possibility is a helper method something like
def tmp(name) ["/tmp", "/temp"].each do |dir| if File.directory? dir return File.join dir, name end end endIn the specs you would write
MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))The list of directories to test can be expanded. But in general, this solution (and Dir.tmpdir) offer nothing better than
mkdir /tmpand are certainly more complex. Granted, making sure you have a /tmp directory requires some setup on Windows, but that can be covered in the README.I'd like to hear a good reason not to require that /tmp exist for running MSpec specs and the ruby specs.
-
Luis Lavena April 21st, 2008 @ 02:27 PM
I agree with you about depending on stdlib stuff. but in first place
Dir.tmpdirshouldn't be part of it, but core instead.I also agree with you that this patch don't address the issues with Rubyspecs, but I couldn't trust on the results of a testing tool that was failing it's own specs, as I commented on #rubinius when send the patches.
In any case, put things in
/tmpor/tempwill generate garbage that will not be traceable or be collected by tools that clean TEMP folders.Does Linux/OSX support
ENV['TEMP']or similar? if so, we can put into the MSpec helpertmp(name)and lookup for /tmp, /temp and ENV['TEMP'], something likeDir:is doing.Please let me know and I'll provide the required patches for you to review.
-
Luis Lavena April 21st, 2008 @ 03:02 PM
Also, forgot to add in the previous comment, how we should tackle file operations that are related to binary/ascii operations?
On example is
getcandungetc. They work ok under *nix but unless you state'b'(binary mode) when opening the file, it will not work on Windows.What we should do in this case in the specs? conditionally guard the before blocks, or provide specs that make File/IO operation ignores 'b' mode on any platforms that doesn't support it? (Like currently MRI does).
Thanks for your time.
-
Brian Ford April 22nd, 2008 @ 12:55 AM
I understand your points. It makes sense to add a helper for this to make it easier for an implementation to override if necessary. Since we have the guards in mspec, I'm going to add a directory for helpers there as well. So far, we have bignum_value helper and this one. I like the
tmp("file.txt")syntax; what do you think?Regarding the binary mode for Windows, I would put separate
beforeblocks wrapped inplatform_isguards. If a whole set of behaviors is involved, you could even do a differentdescribeblock; something like:platform_is :mswin do describe "IO#foo on Windows" do # ... end endBTW, it would be simple to extend the
platform_isguard to accept something like:windowsto stand for a whole family of implementations on Windows, Linux/UNIX, etc.I'll commit the
tmp()helper and related stuff sometime today if there are no objections. -
Luis Lavena April 22nd, 2008 @ 11:24 AM
+1 for
tmp(name)helper. No objections and that will make our life (anyone providing fixes for Rubyspecs) more easy.platform_issounds good too, since we are pushing a new One-Click Installer based completely in MinGW (GCC) and that simple change will break lot of specs.Regarding the IO behaviors, when this get's updated, I'll look into the specs and see to add a few ones that describe the binary mode behavior.
Linux/*nix doesn't care of 'b' mode was supplied for read/write operations, so the same must go for rubinius.
Thank you for your time and positve look at this stuff.
-
Ryan Davis April 29th, 2008 @ 04:45 PM
- → Assigned user changed from to Brian Ford
-
Brian Ford April 29th, 2008 @ 05:59 PM
- → State changed from new to resolved
The #tmp helper was added to MSpec in 7243309. It's been modified since then but seems to be working well. Closing this ticket. Please reopen if necessary.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
