Wrong 0.4.1 released

2 views
Skip to first unread message

Alex Chaffee

unread,
Oct 6, 2010, 5:27:59 PM10/6/10
to wrong
Only real feature is support for a .wrong settings file. Check the
README for details.

Joel VanderWerf

unread,
Oct 7, 2010, 7:08:11 PM10/7/10
to wron...@googlegroups.com
On 10/06/2010 02:27 PM, Alex Chaffee wrote:
> Only real feature is support for a .wrong settings file. Check the
> README for details.

Something is broken, for me at least, in 0.4.1 (and going back to 0.4.0
fixes it):

pegasus:~/src/gems/wrong-0.4.1> ruby test/assert_test.rb
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
Test run options: --seed 47286

Loaded suite test/assert_test
Started
E.FF.FF
Finished in 0.007350 seconds.

1) Error:
test_0001_passes_when_the_result_is_true_deny_does_the_reverse(BasicAssertFeaturesSpec::PassFailBasicsSpec):
NoMethodError: private method `gsub' called for
#<Errno::ENOENT:0x7f9c77983800>
./test/../lib/wrong/config.rb:24:in `initialize'
./test/../lib/wrong/config.rb:10:in `new'
./test/../lib/wrong/config.rb:10:in `load_config'
./test/../lib/wrong/config.rb:14:in `config'
./test/../lib/wrong/assert.rb:91:in `aver'
./test/../lib/wrong/assert.rb:34:in `assert'
test/assert_test.rb:14:in
`test_0001_passes_when_the_result_is_true_deny_does_the_reverse'

Joel VanderWerf

unread,
Oct 7, 2010, 7:42:45 PM10/7/10
to wron...@googlegroups.com
On 10/06/2010 02:27 PM, Alex Chaffee wrote:
> Only real feature is support for a .wrong settings file. Check the
> README for details.

This looks like the problem. I have no .wrong file, so settings is
assigned an instance of Errno::ENOENT.

$ diff -u wrong-0.4.0/lib/wrong/config.rb wrong-0.4.1/lib/wrong/config.rb
--- wrong-0.4.0/lib/wrong/config.rb 2010-10-04 11:42:19.543965812 -0700
+++ wrong-0.4.1/lib/wrong/config.rb 2010-10-07 16:35:52.512289503 -0700
@@ -1,9 +1,38 @@
+require "wrong/chunk"
+
module Wrong
+ def self.load_config
+ settings = begin
+ Chunk.read_here_or_higher(".wrong")
+ rescue Errno::ENOENT => e
+ # couldn't find it
+ end
+ Config.new settings
+ end
+

Phlip

unread,
Oct 7, 2010, 8:06:03 PM10/7/10
to wron...@googlegroups.com
> +  def self.load_config
> +    settings = begin
> +      Chunk.read_here_or_higher(".wrong")
> +    rescue Errno::ENOENT => e
> +      # couldn't find it
> +    end

Nothing personal, but that code style reminds me of Python.

Throw first and ask questions later! C-:

Alex Chaffee

unread,
Oct 8, 2010, 12:08:39 PM10/8/10
to wron...@googlegroups.com
Sorry, I'll fix that right away. Thanks for tracking it down.

Alex Chaffee

unread,
Oct 8, 2010, 12:11:21 PM10/8/10
to wron...@googlegroups.com

I don't see what you mean. I see "foo = begin...end" all the time in Ruby. And this code is basically saying that the exception is not an error, but more like a return value ("no file"). Would you be happier if #read_here_or_higher caught the exception and returned nil?

Phlip

unread,
Oct 8, 2010, 12:16:18 PM10/8/10
to wron...@googlegroups.com
On Fri, Oct 8, 2010 at 9:11 AM, Alex Chaffee <ale...@gmail.com> wrote:

>>> +      Chunk.read_here_or_higher(".wrong")
>>> +    rescue Errno::ENOENT => e

>> Nothing personal, but that code style reminds me of Python.

> I don't see what you mean. I see "foo = begin...end" all the time in Ruby. And this code is basically saying that the exception is not an error, but more like a return value ("no file"). Would you be happier if #read_here_or_higher caught the exception and returned nil?

Sorry - I'm just still chafing from my last job.

The Python community insists on - takes pride in - breaking the rule
"don't use exceptions for normal control flow". They would rather say
try-except than just 'if'.

In the case of file handling, if you said 'if file.exists?', then the
file could disappear in the split second between testing it and using
it (or it could have broken permissions). But still I always tried,
even in Python, to return None or [].

Don't mind me!

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

Steve Conover

unread,
Oct 8, 2010, 12:31:15 PM10/8/10
to wron...@googlegroups.com
>But still I always tried,
> even in Python, to return None or [].

fwiw I endorse this general sentiment!

Alex Chaffee

unread,
Oct 8, 2010, 1:18:47 PM10/8/10
to wron...@googlegroups.com

Me too, in general. In this case it was actually the right thing to do
since we really tried to load a file; the contents were not "nil" but
there was actually an error so it's right for the lower-level function
to fail hard; and in this case (but not the other) we wanted to carry
on.

I would have done

load(file) if file.exists?

except there is no file.exists_here_or_in_some_ancestor? and it would
be silly to write it. Also the atomicity thing Phlip mentions.

--
Alex Chaffee - al...@stinky.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com

Alex Chaffee

unread,
Oct 8, 2010, 1:41:22 PM10/8/10
to wron...@googlegroups.com
Fixed & released 0.4.2.

--

Alex Chaffee - al...@cohuman.com - http://alexch.github.com

Reply all
Reply to author
Forward
0 new messages