diff options
-rwxr-xr-x | lib/custodian/parser.rb | 3 | ||||
-rwxr-xr-x | t/test-parser.rb | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/custodian/parser.rb b/lib/custodian/parser.rb index 77d9c98..5556da0 100755 --- a/lib/custodian/parser.rb +++ b/lib/custodian/parser.rb @@ -439,8 +439,7 @@ class MonitorConfig ret else - puts "Unknown line: '#{line}'" - exit( 0 ) + raise ArgumentError, "Unknown line: '#{line}'" end end diff --git a/t/test-parser.rb b/t/test-parser.rb index f405433..8de513b 100755 --- a/t/test-parser.rb +++ b/t/test-parser.rb @@ -510,6 +510,32 @@ class TestParser < Test::Unit::TestCase + + # + # Test that an exception is raised on a malformed line. + # + def test_bogus + + parser = MonitorConfig.new("/dev/null" ) + + + assert_nothing_raised do + parser.parse_line( "# This is a test" ) + parser.parse_line( "foo must run ssh." ) + end + + assert_raise ArgumentError do + parser.parse_line( "steve is bored." ) + end + + assert_raise ArgumentError do + parser.parse_line( "steve.com must ." ) + end + + end + + + # # Test we can add tests which don't contain a trailing period. # |