Run subsidiary rscons binary from rscons() method if found - close #129
This commit is contained in:
parent
69f5bea2b2
commit
19dbab3426
@ -55,15 +55,19 @@ module Rscons
|
|||||||
# @param args[Array<String>]
|
# @param args[Array<String>]
|
||||||
# Arguments to pass to rscons subprocess.
|
# Arguments to pass to rscons subprocess.
|
||||||
def rscons(path, *args)
|
def rscons(path, *args)
|
||||||
me = File.expand_path($0)
|
rscons_path = File.expand_path($0)
|
||||||
path = File.expand_path(path)
|
path = File.expand_path(path)
|
||||||
if File.directory?(path)
|
if File.directory?(path)
|
||||||
command = [me, *args]
|
command = [*args]
|
||||||
dir = path
|
dir = path
|
||||||
else
|
else
|
||||||
command = [me, "-f", path, *args]
|
command = ["-f", path, *args]
|
||||||
dir = File.dirname(path)
|
dir = File.dirname(path)
|
||||||
end
|
end
|
||||||
|
if File.exist?("#{dir}/rscons")
|
||||||
|
rscons_path = "#{dir}/rscons"
|
||||||
|
end
|
||||||
|
command = [rscons_path] + command
|
||||||
print_dir = dir != "." && dir != File.expand_path(Dir.pwd)
|
print_dir = dir != "." && dir != File.expand_path(Dir.pwd)
|
||||||
if ENV["specs"] and not ENV["dist_specs"] # specs
|
if ENV["specs"] and not ENV["dist_specs"] # specs
|
||||||
command = ["ruby", $LOAD_PATH.map {|p| ["-I", p]}, command].flatten # specs
|
command = ["ruby", $LOAD_PATH.map {|p| ["-I", p]}, command].flatten # specs
|
||||||
|
@ -2694,6 +2694,32 @@ EOF
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a rscons binary in the subsidiary script directory" do
|
||||||
|
it "executes rscons from the subsidiary script directory" do
|
||||||
|
test_dir "subsidiary"
|
||||||
|
|
||||||
|
File.binwrite("sub/rscons", <<EOF)
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
puts "sub rscons"
|
||||||
|
EOF
|
||||||
|
FileUtils.chmod(0755, "sub/rscons")
|
||||||
|
result = run_rscons(op: %W[configure])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
verify_lines(lines(result.stdout), [
|
||||||
|
%r{Entering directory '.*/sub'},
|
||||||
|
%r{sub rscons},
|
||||||
|
%r{Leaving directory '.*/sub'},
|
||||||
|
%r{Entering directory '.*/sub'},
|
||||||
|
%r{sub rscons},
|
||||||
|
%r{Leaving directory '.*/sub'},
|
||||||
|
%r{Entering directory '.*/sub'},
|
||||||
|
%r{sub rscons},
|
||||||
|
%r{Leaving directory '.*/sub'},
|
||||||
|
%r{top configure},
|
||||||
|
])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "does not print entering/leaving directory messages when the subsidiary script is in the same directory" do
|
it "does not print entering/leaving directory messages when the subsidiary script is in the same directory" do
|
||||||
test_dir "subsidiary"
|
test_dir "subsidiary"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user