rake-funnel 0.1.0.pre → 0.2.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +3 -7
- data/lib/rake/funnel/support/binary_version_reader.rb +32 -0
- data/lib/rake/funnel/support/copier.rb +27 -0
- data/lib/rake/funnel/support/msbuild/build_tool.rb +13 -17
- data/lib/rake/funnel/support/{side_by_side_specs/remover.rb → specs_remover.rb} +2 -2
- data/lib/rake/funnel/support/zipper.rb +49 -0
- data/lib/rake/funnel/tasks/assembly_version.rb +17 -11
- data/lib/rake/funnel/tasks/bin_path.rb +17 -10
- data/lib/rake/funnel/tasks/copy.rb +13 -30
- data/lib/rake/funnel/tasks/environments.rb +36 -23
- data/lib/rake/funnel/tasks/msbuild.rb +21 -21
- data/lib/rake/funnel/tasks/msdeploy.rb +17 -24
- data/lib/rake/funnel/tasks/nunit.rb +17 -17
- data/lib/rake/funnel/tasks/paket.rb +15 -9
- data/lib/rake/funnel/tasks/quick_template.rb +14 -12
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +16 -10
- data/lib/rake/funnel/tasks/timing.rb +16 -9
- data/lib/rake/funnel/tasks/zip.rb +14 -48
- data/lib/rake/funnel/version.rb +1 -1
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +16 -18
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +29 -0
- data/spec/rake/funnel/support/copier_spec.rb +58 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/FooCode.cs +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/FooSpecs.cs +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/Sample.csproj +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/Specs.cs +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/subdir/BarCode.cs +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/subdir/BarSpecs.cs +0 -0
- data/spec/rake/funnel/support/{side_by_side_specs/remover_spec.rb → specs_remover_spec.rb} +2 -2
- data/spec/rake/funnel/support/zipper_spec.rb +77 -0
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +10 -19
- data/spec/rake/funnel/tasks/bin_path_spec.rb +19 -7
- data/spec/rake/funnel/tasks/copy_spec.rb +18 -73
- data/spec/rake/funnel/tasks/environments_spec.rb +59 -105
- data/spec/rake/funnel/tasks/msbuild_spec.rb +30 -30
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +0 -23
- data/spec/rake/funnel/tasks/nunit_spec.rb +11 -13
- data/spec/rake/funnel/tasks/paket_spec.rb +3 -45
- data/spec/rake/funnel/tasks/quick_template_spec.rb +0 -27
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +3 -4
- data/spec/rake/funnel/tasks/zip_spec.rb +21 -101
- metadata +26 -17
@@ -7,28 +7,30 @@ module Rake::Funnel::Tasks
|
|
7
7
|
|
8
8
|
attr_accessor :name, :search_pattern, :context
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
|
10
|
+
def initialize(*args, &task_block)
|
11
|
+
setup_ivars(args)
|
12
|
+
|
13
|
+
define(args, &task_block)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def setup_ivars(args)
|
18
|
+
@name = args.shift || :template
|
12
19
|
|
13
20
|
@search_pattern = %w(**/*.erb)
|
14
21
|
@context = binding
|
15
|
-
|
16
|
-
yield self if block_given?
|
17
|
-
define
|
18
22
|
end
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
def define(args, &task_block)
|
25
|
+
desc 'Generate templates' unless Rake.application.last_description
|
26
|
+
task(name, *args) do |_, task_args|
|
27
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
24
28
|
|
25
|
-
desc "Generate #{templates.all_or_default.join(', ')}"
|
26
|
-
task name do
|
27
29
|
templates.all_or_default.each do |template|
|
28
30
|
target = result_filename(template)
|
29
31
|
Rake.rake_output_message "Creating file #{target}"
|
30
32
|
|
31
|
-
content =
|
33
|
+
content = TemplateEngine.render(File.read(template), template, context)
|
32
34
|
File.write(target, content)
|
33
35
|
end
|
34
36
|
end
|
@@ -2,27 +2,33 @@ require 'rake/tasklib'
|
|
2
2
|
|
3
3
|
module Rake::Funnel::Tasks
|
4
4
|
class SideBySideSpecs < Rake::TaskLib
|
5
|
-
include Rake::Funnel::Support
|
5
|
+
include Rake::Funnel::Support
|
6
6
|
|
7
7
|
attr_accessor :name, :projects, :references, :specs, :enabled
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
9
|
+
def initialize(*args, &task_block)
|
10
|
+
setup_ivars(args)
|
11
|
+
|
12
|
+
define(args, &task_block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def setup_ivars(args)
|
17
|
+
@name = args.shift || :compile
|
11
18
|
|
12
19
|
@projects = %w(**/*.csproj **/*.vbproj **/*.fsproj)
|
13
20
|
@references = []
|
14
21
|
@specs = %w(*Specs.cs **/*Specs.cs *Tests.cs **/*Tests.cs)
|
15
22
|
@enabled = false
|
16
|
-
|
17
|
-
yield self if block_given?
|
18
|
-
define
|
19
23
|
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
task
|
25
|
+
def define(args, &task_block)
|
26
|
+
desc 'Remove tests from projects' unless Rake.application.last_description
|
27
|
+
task(name, *args) do |_, task_args|
|
28
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
29
|
+
|
24
30
|
next unless enabled
|
25
|
-
|
31
|
+
SpecsRemover.remove({ projects: projects, references: references, specs: specs })
|
26
32
|
end
|
27
33
|
|
28
34
|
self
|
@@ -7,13 +7,10 @@ module Rake::Funnel::Tasks
|
|
7
7
|
attr_accessor :name
|
8
8
|
attr_reader :stats
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
@stats = Statistics.new
|
13
|
-
|
14
|
-
yield self if block_given?
|
10
|
+
def initialize(*args, &task_block)
|
11
|
+
setup_ivars(args)
|
15
12
|
|
16
|
-
define
|
13
|
+
define(args, &task_block)
|
17
14
|
end
|
18
15
|
|
19
16
|
def reset!
|
@@ -21,11 +18,21 @@ module Rake::Funnel::Tasks
|
|
21
18
|
end
|
22
19
|
|
23
20
|
private
|
24
|
-
def
|
21
|
+
def setup_ivars(args)
|
22
|
+
@name = args.shift || :timing
|
23
|
+
|
24
|
+
@stats = Statistics.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def define(args, &task_block)
|
25
28
|
patches.each { |p| p.apply! }
|
26
29
|
|
27
|
-
task
|
28
|
-
|
30
|
+
desc 'Output task timing information' unless Rake.application.last_description
|
31
|
+
|
32
|
+
task name, :failed do |_, task_args|
|
33
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
34
|
+
|
35
|
+
Report.new(@stats, task_args).render
|
29
36
|
end
|
30
37
|
|
31
38
|
timing_task = Rake.application.current_scope.path_with_task_name(@name)
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require 'pathname'
|
2
1
|
require 'rake/tasklib'
|
3
|
-
require 'zip'
|
4
2
|
|
5
3
|
module Rake::Funnel::Tasks
|
6
4
|
class Zip < Rake::TaskLib
|
@@ -8,30 +6,28 @@ module Rake::Funnel::Tasks
|
|
8
6
|
|
9
7
|
attr_accessor :name, :source, :target, :zip_root
|
10
8
|
|
11
|
-
def initialize(
|
12
|
-
|
9
|
+
def initialize(*args, &task_block)
|
10
|
+
setup_ivars(args)
|
11
|
+
|
12
|
+
define(args, &task_block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def setup_ivars(args)
|
17
|
+
@name = args.shift || :package
|
13
18
|
|
14
19
|
@source = []
|
15
20
|
@target = nil
|
16
21
|
@zip_root = nil
|
17
|
-
|
18
|
-
yield self if block_given?
|
19
|
-
define
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
target && CLEAN.include(target)
|
25
|
-
|
26
|
-
desc "Zip #{files.join(', ')} to #{target}"
|
27
|
-
task name do
|
28
|
-
raise 'Target not defined' unless target
|
24
|
+
def define(args, &task_block)
|
25
|
+
desc 'Zip files' unless Rake.application.last_description
|
29
26
|
|
30
|
-
|
31
|
-
|
27
|
+
task(name, *args) do |_, task_args|
|
28
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block
|
32
29
|
|
33
|
-
|
34
|
-
create_zip(files, target)
|
30
|
+
Zipper.zip(files, target, zip_root)
|
35
31
|
|
36
32
|
Rake.rake_output_message("Created #{target}")
|
37
33
|
end
|
@@ -42,35 +38,5 @@ module Rake::Funnel::Tasks
|
|
42
38
|
def files
|
43
39
|
Finder.new(source, self, 'No files to zip.').all_or_default
|
44
40
|
end
|
45
|
-
|
46
|
-
def configure_zip
|
47
|
-
::Zip.unicode_names = true
|
48
|
-
::Zip.default_compression = Zlib::BEST_COMPRESSION
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_zip(files, target)
|
52
|
-
::Zip::File.open(target, ::Zip::File::CREATE) do |zip|
|
53
|
-
common_path = files.common_path
|
54
|
-
|
55
|
-
files.each do |file|
|
56
|
-
zipped_file = get_zipped_path(common_path, file)
|
57
|
-
|
58
|
-
entry = zip.add(zipped_file, file)
|
59
|
-
set_mtime(entry, file)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# To work around this bug: https://github.com/rubyzip/rubyzip/issues/176
|
65
|
-
def set_mtime(entry, file)
|
66
|
-
entry.time = ::Zip::DOSTime.at(File.mtime(file))
|
67
|
-
entry.extra.delete('UniversalTime')
|
68
|
-
end
|
69
|
-
|
70
|
-
def get_zipped_path(common_path, file)
|
71
|
-
file = Pathname.new(file).relative_path_from(Pathname.new(common_path)).to_s unless common_path.nil?
|
72
|
-
file = File.join(zip_root, file) unless zip_root.nil? || zip_root.empty?
|
73
|
-
file
|
74
|
-
end
|
75
41
|
end
|
76
42
|
end
|
data/lib/rake/funnel/version.rb
CHANGED
@@ -1,29 +1,24 @@
|
|
1
1
|
include Rake::Funnel::Support
|
2
2
|
|
3
3
|
describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
4
|
-
let(:env_var) { nil }
|
5
|
-
let(:which) { nil }
|
6
|
-
let(:nunit_exe_contents) { nil }
|
7
|
-
|
8
4
|
before {
|
9
5
|
allow(ENV).to receive(:[]).with(described_class::ENV_VAR).and_return(env_var)
|
10
6
|
allow(Which).to receive(:which).and_return(which)
|
11
|
-
allow(File).to receive(:read).with(which).and_return(nunit_exe_contents)
|
12
7
|
allow(Dir).to receive(:glob).and_return([])
|
13
8
|
allow(RakeFileUtils).to receive(:mkdir_p)
|
14
9
|
allow(Rake).to receive(:rake_output_message)
|
15
10
|
}
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
12
|
+
before {
|
13
|
+
allow(BinaryVersionReader).to receive(:read_from).with(which).and_return(nunit_version)
|
14
|
+
}
|
21
15
|
|
22
16
|
describe 'success' do
|
23
17
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
24
18
|
let(:addin_dlls) { [env_var + 'addin.dll'] }
|
25
19
|
let(:which) { 'path/to/nunit-console.exe' }
|
26
|
-
let(:
|
20
|
+
let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
|
21
|
+
let(:plugin_version) { nunit_version.file_version.split('.').take(3).join('.') }
|
27
22
|
|
28
23
|
before {
|
29
24
|
allow(Dir).to receive(:glob).and_return(addin_dlls)
|
@@ -39,7 +34,7 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
39
34
|
end
|
40
35
|
|
41
36
|
it 'should enumerate addin files' do
|
42
|
-
expect(Dir).to have_received(:glob).with(/#{Regexp.escape(env_var
|
37
|
+
expect(Dir).to have_received(:glob).with(/#{Regexp.escape("#{env_var}-#{plugin_version}\.*")}$/)
|
43
38
|
end
|
44
39
|
|
45
40
|
it 'should copy the addin from TeamCity to NUnit' do
|
@@ -47,7 +42,7 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
47
42
|
end
|
48
43
|
|
49
44
|
it 'should report that the addin is installed' do
|
50
|
-
expect(Rake).to have_received(:rake_output_message).with("Installing TeamCity NUnit addin for version
|
45
|
+
expect(Rake).to have_received(:rake_output_message).with("Installing TeamCity NUnit addin for version #{plugin_version} in #{which}")
|
51
46
|
end
|
52
47
|
|
53
48
|
context 'Windows-style path in environment variable', platform: :win32 do
|
@@ -60,6 +55,10 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
60
55
|
end
|
61
56
|
|
62
57
|
describe 'failures' do
|
58
|
+
let(:env_var) { nil }
|
59
|
+
let(:which) { nil }
|
60
|
+
let(:nunit_version) { VersionInfo.new }
|
61
|
+
|
63
62
|
before {
|
64
63
|
described_class.setup('nunit-console.exe')
|
65
64
|
}
|
@@ -67,8 +66,8 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
67
66
|
context 'TeamCity plugin path not in environment' do
|
68
67
|
let(:env_var) { nil }
|
69
68
|
|
70
|
-
it 'should skip' do
|
71
|
-
expect(
|
69
|
+
it 'should skip reading the version' do
|
70
|
+
expect(BinaryVersionReader).to_not have_received(:read_from)
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
@@ -76,15 +75,14 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
76
75
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
77
76
|
let(:which) { nil }
|
78
77
|
|
79
|
-
it 'should skip' do
|
80
|
-
expect(
|
78
|
+
it 'should skip reading the version' do
|
79
|
+
expect(BinaryVersionReader).to_not have_received(:read_from)
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
83
|
context 'NUnit executable without version' do
|
85
84
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
86
85
|
let(:which) { 'path/to/nunit-console.exe' }
|
87
|
-
let(:nunit_exe_contents) { 'version number not available ' }
|
88
86
|
|
89
87
|
it 'should report that the version could not be read' do
|
90
88
|
expect(Rake).to have_received(:rake_output_message).with("Could read version from NUnit executable in #{which}")
|
@@ -98,7 +96,7 @@ describe Rake::Funnel::Integration::TeamCity::NUnitPlugin do
|
|
98
96
|
context 'plugin for NUnit version not available' do
|
99
97
|
let(:env_var) { '/path/to/nunit plugins/nunit' }
|
100
98
|
let(:which) { 'path/to/nunit-console.exe' }
|
101
|
-
let(:
|
99
|
+
let(:nunit_version) { VersionInfo.new({ file_version: '1.2.3.4' }) }
|
102
100
|
|
103
101
|
it 'should report that the addin version is not available' do
|
104
102
|
expect(Rake).to have_received(:rake_output_message).with(/Could not find TeamCity NUnit addin for version 1\.2\.3 in .*#{env_var}$/)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe Rake::Funnel::Support::BinaryVersionReader do
|
2
|
+
def binary_version(*version_parts)
|
3
|
+
version = version_parts.map { |p| p.to_s + "\0" }.join(".\0")
|
4
|
+
"F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n" + "\0" * 3 + version + "\0" * 3
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:file) { 'some assembly' }
|
8
|
+
|
9
|
+
before {
|
10
|
+
allow(File).to receive(:binread).with(file).and_return(contents)
|
11
|
+
}
|
12
|
+
|
13
|
+
describe 'version can be read' do
|
14
|
+
let(:version) { %w(1 2 3 4) }
|
15
|
+
let(:contents) { "binary #{binary_version(*version)} binary" }
|
16
|
+
|
17
|
+
it 'should yield all parts' do
|
18
|
+
expect(described_class.read_from(file).file_version).to eq(version.join('.'))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'version cannot be read' do
|
23
|
+
let(:contents) { 'this does not contain a version number' }
|
24
|
+
|
25
|
+
it 'should yield empty VersionInfo' do
|
26
|
+
expect(described_class.read_from(file).to_h).to be_empty
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
describe Rake::Funnel::Support::Copier do
|
2
|
+
let(:source) { files + directories }
|
3
|
+
let(:files) { %w(bin/1 bin/2 bin/3/4 bin/directory/file) }
|
4
|
+
let(:directories) { %w(bin/directory bin/directory-no-content) }
|
5
|
+
let(:target) { 'target path' }
|
6
|
+
|
7
|
+
context 'failure' do
|
8
|
+
context 'target not defined' do
|
9
|
+
let(:target) { nil }
|
10
|
+
|
11
|
+
it 'should fail' do
|
12
|
+
expect { described_class.copy([], nil) }.to raise_error(/Target not defined/)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'recursive copy' do
|
18
|
+
before {
|
19
|
+
allow(File).to receive(:directory?).and_return(false)
|
20
|
+
directories.each do |dir|
|
21
|
+
allow(File).to receive(:directory?).with(dir).and_return(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
allow(RakeFileUtils).to receive(:mkdir_p)
|
25
|
+
allow(RakeFileUtils).to receive(:cp)
|
26
|
+
}
|
27
|
+
|
28
|
+
before {
|
29
|
+
described_class.copy(source, target)
|
30
|
+
}
|
31
|
+
|
32
|
+
def no_prefix(file)
|
33
|
+
file.sub(%r|bin/|, '')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should create target directories' do
|
37
|
+
expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(target, '3'))
|
38
|
+
expect(RakeFileUtils).to have_received(:mkdir_p).with(File.join(target, 'directory'))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should skip source directories' do
|
42
|
+
directories.each do |dir|
|
43
|
+
expect(RakeFileUtils).not_to have_received(:cp).with(dir, anything)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should copy files with common path removed' do
|
48
|
+
files.each do |file|
|
49
|
+
target_path = File.join(target, no_prefix(file))
|
50
|
+
expect(RakeFileUtils).to have_received(:cp).with(file, target_path, anything)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should preserve metdata' do
|
55
|
+
expect(RakeFileUtils).to have_received(:cp).with(anything, anything, { preserve: true }).exactly(files.length).times
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/subdir/BarCode.cs
RENAMED
File without changes
|
data/spec/rake/funnel/support/{side_by_side_specs/example → specs_remover}/subdir/BarSpecs.cs
RENAMED
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Rake::Funnel::Support::
|
1
|
+
describe Rake::Funnel::Support::SpecsRemover do
|
2
2
|
describe 'removal' do
|
3
3
|
let(:projects) { [] }
|
4
4
|
let(:references) { [] }
|
@@ -66,7 +66,7 @@ describe Rake::Funnel::Support::SideBySideSpecs::Remover do
|
|
66
66
|
let(:temp_dir) { Dir.mktmpdir }
|
67
67
|
|
68
68
|
before {
|
69
|
-
FileUtils.cp_r(File.join(File.dirname(__FILE__), '
|
69
|
+
FileUtils.cp_r(File.join(File.dirname(__FILE__), 'specs_remover/.'), temp_dir)
|
70
70
|
}
|
71
71
|
|
72
72
|
before {
|
@@ -0,0 +1,77 @@
|
|
1
|
+
include Rake::Funnel::Support
|
2
|
+
|
3
|
+
describe Rake::Funnel::Support::Zipper do
|
4
|
+
describe '#zip' do
|
5
|
+
let(:source) { %w(bin/1 bin/2 bin/3/4) }
|
6
|
+
|
7
|
+
context 'failure' do
|
8
|
+
context 'target not defined' do
|
9
|
+
let(:target) { nil }
|
10
|
+
|
11
|
+
it 'should fail' do
|
12
|
+
expect { described_class.zip(source, target) }.to raise_error(/Target not defined/)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'success' do
|
18
|
+
let(:target) { 'some path/file.zip' }
|
19
|
+
let(:zip_root) { nil }
|
20
|
+
let(:zip) { instance_double(::Zip::File).as_null_object }
|
21
|
+
let(:mtime) { Time.new(2015, 3, 9) }
|
22
|
+
let(:zip_entry) { double(::Zip::Entry).as_null_object }
|
23
|
+
|
24
|
+
before {
|
25
|
+
allow(RakeFileUtils).to receive(:mkdir_p)
|
26
|
+
}
|
27
|
+
|
28
|
+
before {
|
29
|
+
allow(::Zip::File).to receive(:open).with(target, ::Zip::File::CREATE).and_yield(zip)
|
30
|
+
allow(zip).to receive(:add).and_return(zip_entry)
|
31
|
+
allow(File).to receive(:mtime).and_return(mtime)
|
32
|
+
}
|
33
|
+
|
34
|
+
before {
|
35
|
+
described_class.zip(source, target, zip_root)
|
36
|
+
}
|
37
|
+
|
38
|
+
it 'should create the target directory' do
|
39
|
+
expect(RakeFileUtils).to have_received(:mkdir_p).with(File.dirname(target))
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'configuration' do
|
43
|
+
it 'should allow unicode names' do
|
44
|
+
expect(::Zip.unicode_names).to eq(true)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should use best compression' do
|
48
|
+
expect(::Zip.default_compression).to eq(Zlib::BEST_COMPRESSION)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'work-around for https://github.com/rubyzip/rubyzip/issues/176' do
|
53
|
+
it 'should explicitly set the file mtime' do
|
54
|
+
expect(zip_entry).to have_received(:time=).with(mtime).exactly(source.length).times
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'common path' do
|
59
|
+
it 'should remove the common path from the source' do
|
60
|
+
expect(zip).not_to have_received(:add).with(/#{source.common_path}/, anything)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'zip root' do
|
65
|
+
[nil, '', 'some path/inside the zip file'].each do |root|
|
66
|
+
context "with '#{root || 'nil'}'" do
|
67
|
+
let(:zip_root) { root }
|
68
|
+
|
69
|
+
it "should put files below #{(root.nil? || root.empty?) ? 'the root' : "'#{root}'"}" do
|
70
|
+
expect(zip).to have_received(:add).with(/^#{root}/, anything).exactly(source.length).times
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -3,7 +3,6 @@ include Rake::Funnel::Support
|
|
3
3
|
|
4
4
|
describe Rake::Funnel::Tasks::AssemblyVersion do
|
5
5
|
before {
|
6
|
-
CLEAN.clear
|
7
6
|
Task.clear
|
8
7
|
}
|
9
8
|
|
@@ -13,32 +12,24 @@ describe Rake::Funnel::Tasks::AssemblyVersion do
|
|
13
12
|
its(:source) { should == :FromVersionFiles }
|
14
13
|
its(:source_args) { should == {} }
|
15
14
|
its(:target_path) { should be_an_instance_of(Proc) }
|
16
|
-
|
17
|
-
describe 'overriding defaults' do
|
18
|
-
subject {
|
19
|
-
described_class.new(:name) do |t|
|
20
|
-
t.language = [:cs, :vb]
|
21
|
-
t.source = []
|
22
|
-
t.source_args = { foo: 42 }
|
23
|
-
t.target_path = 'will not work'
|
24
|
-
end
|
25
|
-
}
|
26
|
-
|
27
|
-
its(:name) { should == :name }
|
28
|
-
its(:language) { should == [:cs, :vb] }
|
29
|
-
its(:source) { should == [] }
|
30
|
-
its(:source_args) { should == { foo: 42 } }
|
31
|
-
its(:target_path) { should == 'will not work' }
|
32
|
-
end
|
33
15
|
end
|
34
16
|
|
35
17
|
describe 'execution' do
|
36
|
-
let(:writer) {
|
18
|
+
let(:writer) { instance_double(AssemblyVersionWriter).as_null_object }
|
37
19
|
|
38
20
|
before {
|
39
21
|
allow(AssemblyVersionWriter).to receive(:new).and_return(writer)
|
40
22
|
}
|
41
23
|
|
24
|
+
subject {
|
25
|
+
described_class.new(:name) do |t|
|
26
|
+
t.language = [:cs, :vb]
|
27
|
+
t.source = %w(one two)
|
28
|
+
t.source_args = { foo: 42 }
|
29
|
+
t.target_path = 'will not work'
|
30
|
+
end
|
31
|
+
}
|
32
|
+
|
42
33
|
before {
|
43
34
|
Task[subject.name].invoke
|
44
35
|
}
|
@@ -3,7 +3,6 @@ include Rake
|
|
3
3
|
describe Rake::Funnel::Tasks::BinPath do
|
4
4
|
before {
|
5
5
|
Task.clear
|
6
|
-
expect(subject).to be
|
7
6
|
}
|
8
7
|
|
9
8
|
describe 'defaults' do
|
@@ -12,24 +11,37 @@ describe Rake::Funnel::Tasks::BinPath do
|
|
12
11
|
end
|
13
12
|
|
14
13
|
describe 'execution' do
|
14
|
+
let(:default_path) { 'default PATH contents' }
|
15
|
+
let(:search_pattern) { %w(foo bar) }
|
16
|
+
|
15
17
|
before {
|
16
|
-
allow(ENV).to receive(:[]).with('PATH').and_return(
|
18
|
+
allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
|
17
19
|
allow(ENV).to receive(:[]=)
|
18
20
|
allow(Rake).to receive(:rake_output_message)
|
19
21
|
}
|
20
22
|
|
21
23
|
before {
|
22
|
-
|
24
|
+
allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
|
25
|
+
}
|
23
26
|
|
24
|
-
|
27
|
+
subject {
|
28
|
+
described_class.new do |t|
|
29
|
+
t.search_pattern = search_pattern
|
30
|
+
end
|
31
|
+
}
|
25
32
|
|
26
|
-
|
33
|
+
before {
|
34
|
+
Task[subject.name].invoke
|
27
35
|
}
|
28
36
|
|
29
37
|
it 'should prepend sorted matching folders to the PATH environment variable' do
|
30
|
-
paths =
|
38
|
+
paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)
|
39
|
+
|
40
|
+
expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
|
41
|
+
end
|
31
42
|
|
32
|
-
|
43
|
+
it 'should append original PATH environment variable' do
|
44
|
+
expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
|
33
45
|
end
|
34
46
|
|
35
47
|
it 'should report added paths' do
|