null+****@clear*****
null+****@clear*****
2011年 5月 30日 (月) 21:43:30 JST
Kouhei Sutou 2011-05-30 12:43:30 +0000 (Mon, 30 May 2011) New Revision: 770eefb4f2a60ff4fe6f05c6e8ca0ceecc72041e Log: [groonga] don't show deprecated options in --show-config. Modified files: src/groonga.c test/unit/command/test-option.rb test/unit/lib/ruby/groonga-test-utils.rb Modified: src/groonga.c (+4 -1) =================================================================== --- src/groonga.c 2011-05-30 12:20:25 +0000 (1cbec09) +++ src/groonga.c 2011-05-30 12:43:30 +0000 (79c9f11) @@ -2035,7 +2035,10 @@ show_config(FILE *out, const grn_str_getopt_opt *opts, int flags) switch (o->op) { case getopt_op_none: if (o->arg && *o->arg) { - if (o->longopt && strcmp(o->longopt, "config-path")) { + if (o->longopt && + strcmp(o->longopt, "config-path") != 0 && + strcmp(o->longopt, "address") != 0 && + strcmp(o->longopt, "admin-html-path") != 0) { fprintf(out, "%s=%s\n", o->longopt, *o->arg); } } Modified: test/unit/command/test-option.rb (+12 -6) =================================================================== --- test/unit/command/test-option.rb 2011-05-30 12:20:25 +0000 (446d513) +++ test/unit/command/test-option.rb 2011-05-30 12:43:30 +0000 (137a370) @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2010 Nobuyoshi Nakada <nakad****@clear*****> +# Copyright (C) 2011 Kouhei Sutou <kou****@clear*****> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -63,10 +64,11 @@ class OptionTest < Test::Unit::TestCase end end + # FIXME: This test is too dirty. It should be split. def test_config_path test_options = %W[ port=1.1.1.1 encoding=none encoding=euc-jp - max-threads=12345 address=localhost + max-threads=12345 bind-address=localhost log-level=1 server=localhost ] config_file = File.join(@tmp_dir, "test-option.config") @@ -81,25 +83,29 @@ class OptionTest < Test::Unit::TestCase [CONFIG_ENV, "--config-path=#{config_file}"]) assert_predicate(status, :success?) - default_config = run_groonga("--show-config") + default_config = run_groonga("--show-config").split(/\n/) test_options.each do |opt| - status = assert_run_groonga([opt, default_config].join("\n"), + status = assert_run_groonga(([opt] + default_config).sort.join("\n"), "", [CONFIG_ENV, "--#{opt}", "--config-path=#{config_file}", - "--show-config"]) + "--show-config"]) do |stdout, stderr| + [stdout.split(/\n/).sort.join("\n"), stderr] + end assert_predicate(status, :success?) end test_options.each do |opt| open(config_file, "w") {|f| f.puts opt} - status = assert_run_groonga([opt, default_config].join("\n"), + status = assert_run_groonga(([opt] + default_config).sort.join("\n"), "", [CONFIG_ENV, "--config-path=#{config_file}", - "--show-config"]) + "--show-config"]) do |stdout, stderr| + [stdout.split(/\n/).sort.join("\n"), stderr] + end assert_predicate(status, :success?) end ensure Modified: test/unit/lib/ruby/groonga-test-utils.rb (+10 -13) =================================================================== --- test/unit/lib/ruby/groonga-test-utils.rb 2011-05-30 12:20:25 +0000 (4505987) +++ test/unit/lib/ruby/groonga-test-utils.rb 2011-05-30 12:43:30 +0000 (53a337c) @@ -248,20 +248,17 @@ module GroongaTestUtils :capture_error => true) stdout, stderr, status = invoke_groonga(*args) assert_not_predicate(status, :signaled?) - if block_given? - yield(stdout, stderr) + stdout, stderr = yield(stdout, stderr) if block_given? + if test_stderr.is_a?(Regexp) + assert_match(test_stderr, stderr, message) else - if test_stderr.is_a?(Regexp) - assert_match(test_stderr, stderr, message) - else - assert_equal(test_stderr, stderr, message) - end - if test_stdout.is_a?(Regexp) - assert_match(test_stdout, stdout, message) - else - assert_equal(test_stdout, stdout, message) - end - status + assert_equal(test_stderr, stderr, message) + end + if test_stdout.is_a?(Regexp) + assert_match(test_stdout, stdout, message) + else + assert_equal(test_stdout, stdout, message) end + status end end