seattlerb / zentest

144 stars 72 forks source link

`-w` doesn't turn on warnings #55

Closed teoljungberg closed 10 years ago

teoljungberg commented 10 years ago

autotest -w doesn't throw ruby warnings

My test case:

require 'minitest/autorun'

class OmgTest < Minitest::Test
  def test_throw_warnings
    never_used = 1
    assert_equal 2, 2
  end
end

Running it with plain 'ol ruby

test % ruby -w test/omg_test.rb | grep -i warning
RUBY_GC_HEAP_INIT_SLOTS=1000000 (default value: 4096)
RUBY_GC_MALLOC_LIMIT=1000000000 (default value: 16777216)
test/omg_test.rb:5: warning: assigned but unused variable - never_used

With autotest

test % autotest -w | grep -i warning

Not a single warning was thrown

zenspider commented 10 years ago

That's not what the -w flag is intended for. It is intended for autotest itself.

When I add x = 42 to a .autotest file (or any file loaded by it) I see:

% ruby -Ilib:../../../minitest/dev/lib -S autotest
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I.:lib:test -rubygems -e "%w[minitest/autorun test/test_blah.rb].each { |f| require f }"
Run options: --seed 3001

# Running:

.

Finished in 0.001164s, 859.1065 runs/s, 859.1065 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

versus:

% ruby -Ilib:../../../minitest/dev/lib -S autotest -w
/Users/ryan/Work/p4/zss/src/ZenTest/dev/blah/.autotest:9: warning: assigned but unused variable - x
Run options: --seed 12813

# Running:

.

Finished in 0.001970s, 507.6142 runs/s, 507.6142 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

You can override ruby_cmd if you want to tack on a -w to your tests or just turn them on in your tests.

teoljungberg commented 10 years ago

I figured as much, but was not entierely sure.

I solved my predicament by adding RUBYOPT=-w before running autotest — Sent from Mailbox for iPhone

On Tue, Mar 25, 2014 at 11:23 PM, Ryan Davis notifications@github.com wrote:

That's not what the -w flag is intended for. It is intended for autotest itself. When I add x = 42 to a .autotest file (or any file loaded by it) I see:

% ruby -Ilib:../../../minitest/dev/lib -S autotest
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I.:lib:test -rubygems -e "%w[minitest/autorun test/test_blah.rb].each { |f| require f }"
Run options: --seed 3001
# Running:
.
Finished in 0.001164s, 859.1065 runs/s, 859.1065 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

versus:

% ruby -Ilib:../../../minitest/dev/lib -S autotest -w
/Users/ryan/Work/p4/zss/src/ZenTest/dev/blah/.autotest:9: warning: assigned but unused variable - x
Run options: --seed 12813
# Running:
.
Finished in 0.001970s, 507.6142 runs/s, 507.6142 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

You can override ruby_cmd if you want to tack on a -w to your tests or just turn them on in your tests.

Reply to this email directly or view it on GitHub: https://github.com/seattlerb/zentest/issues/55#issuecomment-38628905