From 50dc34636b3e762a32198509c49b69d2e973c013 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Wed, 23 Nov 2011 13:48:06 +0000 Subject: [PATCH] fixed glob unit test in test_biopieces.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1680 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/lib/maasha/biopieces.rb | 3 +-- code_ruby/test/maasha/test_biopieces.rb | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/code_ruby/lib/maasha/biopieces.rb b/code_ruby/lib/maasha/biopieces.rb index 7b42b54..ee71309 100644 --- a/code_ruby/lib/maasha/biopieces.rb +++ b/code_ruby/lib/maasha/biopieces.rb @@ -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] diff --git a/code_ruby/test/maasha/test_biopieces.rb b/code_ruby/test/maasha/test_biopieces.rb index cc77410..1851c5c 100755 --- a/code_ruby/test/maasha/test_biopieces.rb +++ b/code_ruby/test/maasha/test_biopieces.rb @@ -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] -- 2.39.2