Skip to content

Commit 65c64ee

Browse files
committed
debug exec
1 parent 237708d commit 65c64ee

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

test/test_ocra.rb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,45 @@ def with_tmpdir(files = [], path = nil)
102102
end
103103
end
104104

105+
def relative_or_absolute_path(from_path, to_path)
106+
begin
107+
# Attempt to generate a relative path
108+
Pathname.new(to_path).relative_path_from(Pathname.new(from_path)).to_s
109+
rescue ArgumentError
110+
# If a relative path cannot be computed, return the absolute path
111+
Pathname.new(to_path).realpath.to_s
112+
end
113+
end
114+
115+
def each_path_combo(*files)
116+
# In same directory as first file
117+
basedir = Pathname.new(files[0]).realpath.parent
118+
args = files.map{|p| relative_or_absolute_path(basedir, p) }
119+
cd basedir do
120+
yield(*args)
121+
end
122+
123+
# In parent directory of first file
124+
basedir = basedir.parent
125+
args = files.map{|p| relative_or_absolute_path(basedir, p) }
126+
cd basedir do
127+
yield(*args)
128+
end
129+
130+
# In a completely different directory
131+
args = files.map{|p|Pathname.new(p).realpath.to_s}
132+
with_tmpdir do
133+
yield(*args)
134+
end
135+
end
136+
105137
# Should be able to build executable when specifying absolute path
106138
# to the script from somewhere else.
107139
def test_abspath
108140
with_fixture "helloworld" do
109141
script_path = File.expand_path("helloworld.rb")
110142
with_tmpdir do
111-
assert system("ruby", ocran, script_path, "--rubyopt", "--debug", *DefaultArgs)
143+
assert system("ruby", ocran, script_path, *(DefaultArgs + ["--debug"]))
112144
assert File.exist?("helloworld.exe")
113145
pristine_env "helloworld.exe" do
114146
assert system("helloworld.exe")

0 commit comments

Comments
 (0)