summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-23 15:27:45 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-23 15:27:45 +0000
commitcaaa448c8826e4409d5db5398943e8c1ef54818d (patch)
tree835a09f626e1a84bacd8075a224f65b585d35034
parent92966002e8da92882b53fb5663e4066eff13f1a5 (diff)
Updated to allow the tests to be inverted via "must *not* run ..."
-rw-r--r--lib/custodian/testfactory.rb7
-rwxr-xr-xt/test-custodian-testfactory.rb13
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb
index ac2904a..934d6a7 100644
--- a/lib/custodian/testfactory.rb
+++ b/lib/custodian/testfactory.rb
@@ -34,10 +34,9 @@ module Custodian
#
# If this is an obvious protocol test.
#
- if ( line =~ /must\s+run\s+(\S+)(\s+|\.|$)/ )
- test_type = $1.dup
+ if ( line =~ /must\s+(not\s+)?run\s+(\S+)(\s+|\.|$)/ )
+ test_type = $2.dup
test_type.chomp!( "." )
-
c = @@subclasses[test_type]
if c
c.new( line )
@@ -45,7 +44,7 @@ module Custodian
raise ArgumentError, "Bad test type: #{test_type}"
end
else
- raise "Unknown line given - Failed to instantiate a suitable protocol-test."
+ raise "Unknown line given - Failed to instantiate a suitable protocol-test: '#{line}'"
end
end
diff --git a/t/test-custodian-testfactory.rb b/t/test-custodian-testfactory.rb
index 383b0f0..9aeb6e1 100755
--- a/t/test-custodian-testfactory.rb
+++ b/t/test-custodian-testfactory.rb
@@ -125,5 +125,18 @@ class TestTestFactory < Test::Unit::TestCase
end
+
+ #
+ # Test the creation of inverted tests.
+ #
+ def test_inverted_tests
+
+
+ assert_nothing_raised do
+ assert( Custodian::TestFactory.create( "example.com must not run rsync." ) )
+ assert( Custodian::TestFactory.create( "ftp://example.com/ must not run rsync." ) )
+ assert( Custodian::TestFactory.create( "ftp://example.com/ must not run rsync on 333." ) )
+ end
+ end
end