]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed glob unit test in test_biopieces.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 23 Nov 2011 13:48:06 +0000 (13:48 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 23 Nov 2011 13:48:06 +0000 (13:48 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1680 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/biopieces.rb
code_ruby/test/maasha/test_biopieces.rb

index 7b42b548d333b619bbe8301e0ee962bfeaa8d1b3..ee713098cb2775f7b3485a6ee895b2dfe545cb62 100644 (file)
@@ -334,14 +334,13 @@ class OptionHandler
     @argv        = argv
     @casts       = casts
     @script_path = script_path
+    @options     = {}
   end
 
   # Parse options from argv using OptionParser and casts denoting long and
   # short option names. Usage information is printed and exit called.
   # A hash with options is returned.
   def options_parse
-    @options = {}
-
     option_parser = OptionParser.new do |option|
       @casts.each do |cast|
         case cast[:type]
index cc77410a8c4c788a72342612b6067ddd0bd28c46..1851c5cedfe30d53ea3f7f59885cd051b2dc7cd7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-# Copyright (C) 2007-2010 Martin A. Hansen.
+# Copyright (C) 2007-2011 Martin A. Hansen.
 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -298,14 +298,13 @@ class BiopiecesTest < Test::Unit::TestCase
      assert_nothing_raised(ArgumentError) { Biopieces.options_parse(argv, casts, SCRIPT_PATH) }
    end
  
-#   # TODO replace the absolute part below the file location with File.dirname(__FILE__)
-#   def test_Biopieces_options_parse_with_glob_argument_expands_correctly
-#     flunk("This test is flawed and need fixing")
-#     argv    = ["--foo", "/Users/maasha/unit_test/foo*,/Users/maasha/unit_test/my_dir/*.fna", "-I", DUMMY_FILE]
-#     casts   = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
-#     options = Biopieces.options_parse(argv, casts, SCRIPT_PATH)
-#     assert_equal(["/Users/maasha/unit_test/foo.fna", "/Users/maasha/unit_test/my_dir/bar.fna"], options[:foo])
-#   end
+   def test_Biopieces_options_parse_with_glob_argument_expands_correctly
+     path = File.join(ENV['BP_DIR'], "bp_test")
+     argv    = ["--foo", "#{path}/te*,#{path}/lib/*.sh", "-I", DUMMY_FILE]
+     casts   = [{:long=>"foo", :short=>"f", :type=>"files!", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}]
+     options = Biopieces.options_parse(argv, casts, SCRIPT_PATH)
+     assert_equal(["#{path}/test_all", "#{path}/lib/test.sh"], options[:foo])
+   end
  
    def test_Biopieces_options_parse_with_dir_cast_and_dir_dont_exists_raises
      argv  = ["--foo", "bleh", "-I", DUMMY_FILE]