From cce66576cd6bffb29a17a410ee63cd774e338293 Mon Sep 17 00:00:00 2001 From: Johan Holmberg Date: Thu, 6 Sep 2012 15:21:19 +0200 Subject: [PATCH] get 'import_file' argument relative to CMDTEST file (not current directory) --- bin/cmdtest.rb | 10 ++++++++-- lib/cmdtest/testcase.rb | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/cmdtest.rb b/bin/cmdtest.rb index cfd0f47..6c1bb2e 100755 --- a/bin/cmdtest.rb +++ b/bin/cmdtest.rb @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#! /usr/bin/ruby1.8 #---------------------------------------------------------------------- # cmdtest.rb #---------------------------------------------------------------------- @@ -282,6 +282,10 @@ module Cmdtest @orig_env_path.dup end + def test_files_dir + @project_dir.test_files_dir + end + def run(clog) @orig_cwd = Dir.pwd ENV["PATH"] = Dir.pwd + _path_separator + ENV["PATH"] @@ -322,6 +326,8 @@ module Cmdtest class ProjectDir + ORIG_CWD = Dir.pwd + def initialize(argv) @argv = argv @test_filenames = nil @@ -332,7 +338,7 @@ module Cmdtest end def test_files_dir - File.dirname(test_filenames[0]) + File.expand_path(File.dirname(test_filenames[0]), ORIG_CWD) end private diff --git a/lib/cmdtest/testcase.rb b/lib/cmdtest/testcase.rb index 509f2e4..e506105 100644 --- a/lib/cmdtest/testcase.rb +++ b/lib/cmdtest/testcase.rb @@ -103,7 +103,7 @@ module Cmdtest # the current directory at the time of the call. def import_file(src, tgt) - src_path = File.expand_path(src, ORIG_CWD) + src_path = File.expand_path(src, @_runner.test_files_dir) tgt_path = _cwd_path(tgt) FileUtils.mkdir_p(File.dirname(tgt_path)) FileUtils.cp(src_path, tgt_path)