lib/grntest/tester.rb in grntest-1.1.3 vs lib/grntest/tester.rb in grntest-1.1.4
- old
+ new
@@ -11,10 +11,11 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+require "rbconfig"
require "optparse"
require "pathname"
require "grntest/version"
require "grntest/test-suites-runner"
@@ -38,29 +39,29 @@
parser.banner += " TEST_FILE_OR_DIRECTORY..."
parser.on("--groonga=COMMAND",
"Use COMMAND as groonga command",
"(#{tester.groonga})") do |command|
- tester.groonga = command
+ tester.groonga = normalize_command(command)
end
parser.on("--groonga-httpd=COMMAND",
"Use COMMAND as groonga-httpd command for groonga-httpd tests",
"(#{tester.groonga_httpd})") do |command|
- tester.groonga_httpd = command
+ tester.groonga_httpd = normalize_command(command)
end
parser.on("--groonga-suggest-create-dataset=COMMAND",
"Use COMMAND as groonga_suggest_create_dataset command",
"(#{tester.groonga_suggest_create_dataset})") do |command|
- tester.groonga_suggest_create_dataset = command
+ tester.groonga_suggest_create_dataset = normalize_command(command)
end
available_interfaces = [:stdio, :http]
available_interface_labels = available_interfaces.join(", ")
parser.on("--interface=INTERFACE", available_interfaces,
- "Use INTERFACE for communicating groonga",
+ "Use INTERFACE for communicating Groonga",
"[#{available_interface_labels}]",
"(#{tester.interface})") do |interface|
tester.interface = interface
end
@@ -98,10 +99,11 @@
tester.database_path = path
end
parser.on("--diff=DIFF",
"Use DIFF as diff command",
+ "Use --diff=internal to use internal differ",
"(#{tester.diff})") do |diff|
tester.diff = diff
tester.diff_options.clear
end
@@ -155,17 +157,17 @@
"Use N workers to run tests") do |n|
tester.n_workers = n
end
parser.on("--gdb[=COMMAND]",
- "Run groonga on gdb and use COMMAND as gdb",
+ "Run Groonga on gdb and use COMMAND as gdb",
"(#{tester.default_gdb})") do |command|
tester.gdb = command || tester.default_gdb
end
parser.on("--valgrind[=COMMAND]",
- "Run groonga on valgrind and use COMMAND as valgrind",
+ "Run Groonga on valgrind and use COMMAND as valgrind",
"(#{tester.default_valgrind})") do |command|
tester.valgrind = command || tester.default_valgrind
end
parser.on("--[no-]valgrind-gen-suppressions",
@@ -211,10 +213,26 @@
end
parser
end
+ def normalize_command(command)
+ if File.executable?(command)
+ return File.expand_path(command)
+ end
+
+ exeext = RbConfig::CONFIG["EXEEXT"]
+ unless exeext.empty?
+ command_exe = "#{command}#{exeext}"
+ if File.executable?(command_exe)
+ return File.expand_path(command_exe)
+ end
+ end
+
+ command
+ end
+
def parse_name_or_pattern(name)
if /\A\/(.+)\/\z/ =~ name
Regexp.new($1, Regexp::IGNORECASE)
else
name
@@ -237,10 +255,13 @@
attr_reader :exclude_test_patterns, :exclude_test_suite_patterns
def initialize
@groonga = "groonga"
@groonga_httpd = "groonga-httpd"
@groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
+ unless command_exist?(@groonga_suggest_create_dataset)
+ @groonga_suggest_create_dataset = nil
+ end
@interface = :stdio
@output_type = "json"
@testee = "groonga"
@base_directory = Pathname(".")
@database_path = nil
@@ -343,10 +364,11 @@
default_group_name = "."
tests = {default_group_name => []}
targets.each do |target|
target_path = Pathname(target)
next unless target_path.exist?
+ target_path = target_path.cleanpath
if target_path.directory?
load_tests_under_directory(tests, target_path)
else
tests[default_group_name] << target_path
end
@@ -371,13 +393,16 @@
def detect_suitable_diff
if command_exist?("cut-diff")
@diff = "cut-diff"
@diff_options = ["--context-lines", "10"]
- else
+ elsif command_exist?("diff")
@diff = "diff"
@diff_options = ["-u"]
+ else
+ @diff = "internal"
+ @diff_options = []
end
end
def initialize_debuggers
@gdb = nil
@@ -389,12 +414,19 @@
@default_valgrind = "valgrind"
@vagrind_gen_suppressions = false
end
def command_exist?(name)
+ exeext = RbConfig::CONFIG["EXEEXT"]
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
- absolute_path = File.join(path, name)
- return true if File.executable?(absolute_path)
+ raw_candidate = File.join(path, name)
+ candidates = [
+ raw_candidate,
+ "#{raw_candidate}#{exeext}",
+ ]
+ candidates.each do |candidate|
+ return true if File.executable?(candidate)
+ end
end
false
end
def guess_color_availability