albacore 2.0.0.rc.11 → 2.0.0.rc.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,12 +49,16 @@ module Albacore
49
49
 
50
50
  class Cmd
51
51
  include CrossPlatformCmd
52
+
53
+ # expects both parameters and executable to be relative to the
54
+ # work_dir parameter
52
55
  def initialize work_dir, executable, parameters, file
53
56
  @work_dir, @executable = work_dir, executable
54
57
  @parameters = parameters.to_a.unshift(file)
55
58
  end
56
59
 
57
60
  def execute
61
+ info { "executing in directory './#{@work_dir}'" }
58
62
  system @executable,
59
63
  @parameters,
60
64
  :work_dir => @work_dir,
@@ -62,7 +66,6 @@ module Albacore
62
66
  end
63
67
  end
64
68
 
65
-
66
69
  class Task
67
70
  include Logging
68
71
 
@@ -103,11 +106,22 @@ module Albacore
103
106
  debug { "copying the runners form #{runners_glob} [test_runner #handle_directory]" }
104
107
  FileUtils.cp_r(Dir.glob(runners_glob), runners, :verbose => true)
105
108
 
106
- # call back with the new paths
109
+ # call back with the new paths, easy because we have copied everything
107
110
  yield [sut, Paths.join(runners, File.basename(exe)).to_s]
108
111
  end
109
112
  else
110
- yield [File.dirname(dll), exe]
113
+ dir, exe =
114
+ case File.dirname dll
115
+ when /^\.\./
116
+ # if the dll is negative to this Rakefile, use absolute paths
117
+ [Pathname.new(File.absolute_path(dll)), Pathname.new(File.absolute_path(exe))]
118
+ else
119
+ # otherwise, please continue with the basics
120
+ [Pathname.new(File.dirname(dll)), Pathname.new(exe)]
121
+ end
122
+
123
+ exe_rel = exe.relative_path_from dir
124
+ yield [File.dirname(dll), exe_rel.to_s]
111
125
  end
112
126
  end
113
127
  end
@@ -1,3 +1,3 @@
1
1
  module Albacore
2
- VERSION = "2.0.0.rc.11"
2
+ VERSION = "2.0.0.rc.12"
3
3
  end
@@ -19,7 +19,7 @@ describe Albacore::CrossPlatformCmd.method(:prepare_command) do
19
19
  it 'should be callable' do
20
20
  subject.should respond_to(:call)
21
21
  end
22
- before :all do
22
+ before :each do
23
23
  # noteworthy: escape spaces with backslash!
24
24
  @exe, @pars, @printable, @handler = subject.call %w[echo Hello World Goodbye\ World], true
25
25
  end
@@ -35,11 +35,11 @@ end
35
35
 
36
36
  describe 'the order of which parameters are passed', ::Albacore::TestRunner::Config do
37
37
  subject do
38
- cmd = ::Albacore::TestRunner::Config.new
39
- cmd.files = 'file.dll'
40
- cmd.exe = 'test-runner.exe'
41
- cmd.add_parameter '/TestResults=abc.xml'
42
- cmd
38
+ config = ::Albacore::TestRunner::Config.new
39
+ config.files = 'a/b/c/file.dll'
40
+ config.exe = 'test-runner.exe'
41
+ config.add_parameter '/TestResults=abc.xml'
42
+ config
43
43
  end
44
44
 
45
45
  let :params do
@@ -51,35 +51,69 @@ describe 'the order of which parameters are passed', ::Albacore::TestRunner::Con
51
51
  end
52
52
 
53
53
  it 'should pass the file as a :files' do
54
- subject.opts.get(:files).should eq(['file.dll'])
54
+ subject.opts.get(:files).should eq(['a/b/c/file.dll'])
55
55
  end
56
56
  end
57
57
 
58
58
  describe ::Albacore::TestRunner::Cmd do
59
59
  subject do
60
- cmd = ::Albacore::TestRunner::Cmd.new 'work_dir', 'run-tests.exe', %w[params go here], 'lib.tests.dll'
60
+ cmd = ::Albacore::TestRunner::Cmd.new 'work_dir', 'run-tests.exe', %w[params go here], 'a/b/c/lib.tests.dll'
61
61
  cmd.extend ShInterceptor
62
+ cmd.execute
62
63
  cmd
63
64
  end
64
65
 
65
- it do
66
- should respond_to :execute
67
- end
68
-
69
66
  it 'should include the parameters when executing' do
70
- subject.execute
71
-
72
67
  # the intersection of actual parameters with expected should eq expected
73
68
  (subject.parameters - (subject.parameters - %w|params go here|)).
74
69
  should eq(%w|params go here|)
75
70
  end
71
+
72
+ it 'should give the full path when executing' do
73
+ (subject.parameters - %w|params go here|).should eq(%w|a/b/c/lib.tests.dll|)
74
+ end
76
75
  end
77
76
 
78
77
  describe ::Albacore::TestRunner::Task do
78
+ let :config do
79
+ config = ::Albacore::TestRunner::Config.new
80
+ config.files = 'a/b/c/file.dll'
81
+ config.exe = 'test-runner.exe'
82
+ config.add_parameter '/TestResults=abc.xml'
83
+ config
84
+ end
85
+
79
86
  subject do
80
- ::Albacore::TestRunner::Task.new Map.new
87
+ ::Albacore::TestRunner::Task.new(config.opts)
81
88
  end
89
+
82
90
  it do
83
91
  should respond_to :execute
84
92
  end
93
+
94
+ def test_dir_exe hash
95
+ given = hash.first[0]
96
+ expected = hash.first[1]
97
+ subject.send(:handle_directory, given[0], given[1]) do |dir, exe|
98
+ dir.should eq(expected[0])
99
+ exe.should eq(expected[1])
100
+ end
101
+
102
+ end
103
+
104
+ it 'should handle relative handle_directory' do
105
+ test_dir_exe ['d.dll', 'e.exe'] => ['.', 'e.exe']
106
+ end
107
+
108
+ it 'should handle actual relative directories correctly' do
109
+ test_dir_exe ['a/d.dll', 'e.exe'] => ['a', '../e.exe']
110
+ end
111
+
112
+ it 'should handle negative dirs by getting current dir name' do
113
+ subject.send(:handle_directory, '../d.dll', 'e.exe') do |dir, exe|
114
+ dir.should eq('..')
115
+ # at this point, the exe file is just a dir in
116
+ exe.should =~ /\w+\/e\.exe/
117
+ end
118
+ end
85
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: albacore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc.11
4
+ version: 2.0.0.rc.12
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-04-06 00:00:00.000000000 Z
13
+ date: 2014-04-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -317,7 +317,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
317
317
  version: '0'
318
318
  segments:
319
319
  - 0
320
- hash: 2914469606549085872
320
+ hash: 238623882763255620
321
321
  required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  none: false
323
323
  requirements: