rake-funnel 0.3.2.pre → 0.4.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/.rspec +2 -2
- data/Gemfile +4 -0
- data/README.md +2 -2
- data/lib/rake/funnel/ambiguous_file_error.rb +31 -29
- data/lib/rake/funnel/execution_error.rb +28 -26
- data/lib/rake/funnel/extensions/case/camel_case.rb +24 -19
- data/lib/rake/funnel/extensions/case/pascal_case.rb +24 -19
- data/lib/rake/funnel/extensions/case.rb +3 -3
- data/lib/rake/funnel/extensions/common_path.rb +60 -52
- data/lib/rake/funnel/extensions/disable_colors.rb +33 -27
- data/lib/rake/funnel/extensions/rexml.rb +27 -23
- data/lib/rake/funnel/extensions/shell.rb +92 -56
- data/lib/rake/funnel/extensions/windows_path.rb +15 -11
- data/lib/rake/funnel/framework.rb +11 -16
- data/lib/rake/funnel/integration/progress_report.rb +72 -70
- data/lib/rake/funnel/integration/sync_output.rb +12 -8
- data/lib/rake/funnel/integration/teamcity/nunit_plugin.rb +61 -55
- data/lib/rake/funnel/integration/teamcity/progress_report.rb +39 -33
- data/lib/rake/funnel/integration/teamcity/service_messages.rb +46 -40
- data/lib/rake/funnel/integration/teamcity/teamcity.rb +19 -15
- data/lib/rake/funnel/integration/teamcity.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/key_value_pair.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/styles/default.rb +39 -31
- data/lib/rake/funnel/support/argument_mapper/styles/msbuild.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles/msdeploy.rb +55 -47
- data/lib/rake/funnel/support/argument_mapper/styles/nunit.rb +41 -33
- data/lib/rake/funnel/support/argument_mapper/styles.rb +3 -5
- data/lib/rake/funnel/support/argument_mapper/switch.rb +16 -10
- data/lib/rake/funnel/support/argument_mapper/value.rb +16 -10
- data/lib/rake/funnel/support/assembly_version/from_version_files.rb +39 -35
- data/lib/rake/funnel/support/assembly_version/languages/cs +5 -5
- data/lib/rake/funnel/support/assembly_version/languages/fs +12 -12
- data/lib/rake/funnel/support/assembly_version/languages/vb +5 -5
- data/lib/rake/funnel/support/assembly_version_writer.rb +56 -52
- data/lib/rake/funnel/support/binary_version_reader.rb +37 -32
- data/lib/rake/funnel/support/copier.rb +31 -27
- data/lib/rake/funnel/support/environments/loader.rb +46 -40
- data/lib/rake/funnel/support/environments.rb +3 -3
- data/lib/rake/funnel/support/internal/finder.rb +55 -51
- data/lib/rake/funnel/support/internal/instantiate_symbol.rb +38 -34
- data/lib/rake/funnel/support/mapper.rb +57 -53
- data/lib/rake/funnel/support/mono.rb +21 -17
- data/lib/rake/funnel/support/msbuild/build_tool.rb +30 -24
- data/lib/rake/funnel/support/msbuild.rb +3 -3
- data/lib/rake/funnel/support/msdeploy/registry_patch.rb +90 -84
- data/lib/rake/funnel/support/msdeploy.rb +3 -3
- data/lib/rake/funnel/support/patch.rb +41 -37
- data/lib/rake/funnel/support/specs_remover.rb +66 -62
- data/lib/rake/funnel/support/template_engine.rb +30 -26
- data/lib/rake/funnel/support/timing/report.rb +95 -89
- data/lib/rake/funnel/support/timing/statistics.rb +32 -26
- data/lib/rake/funnel/support/timing.rb +3 -3
- data/lib/rake/funnel/support/version_info.rb +103 -72
- data/lib/rake/funnel/support/which.rb +19 -15
- data/lib/rake/funnel/support/zipper.rb +53 -49
- data/lib/rake/funnel/tasks/assembly_version.rb +44 -40
- data/lib/rake/funnel/tasks/bin_path.rb +45 -41
- data/lib/rake/funnel/tasks/copy.rb +43 -39
- data/lib/rake/funnel/tasks/environments.rb +89 -89
- data/lib/rake/funnel/tasks/msbuild.rb +55 -51
- data/lib/rake/funnel/tasks/msdeploy.rb +54 -50
- data/lib/rake/funnel/tasks/nunit.rb +52 -48
- data/lib/rake/funnel/tasks/paket.rb +51 -47
- data/lib/rake/funnel/tasks/quick_template.rb +53 -49
- data/lib/rake/funnel/tasks/side_by_side_specs.rb +41 -37
- data/lib/rake/funnel/tasks/timing.rb +108 -104
- data/lib/rake/funnel/tasks/zip.rb +46 -42
- data/lib/rake/funnel/version.rb +1 -1
- data/lib/rake/funnel.rb +7 -7
- data/rake-funnel.gemspec +12 -3
- data/spec/rake/funnel/execution_error_spec.rb +67 -67
- data/spec/rake/funnel/extensions/case/camel_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/case/pascal_case_spec.rb +17 -17
- data/spec/rake/funnel/extensions/common_path_spec.rb +56 -56
- data/spec/rake/funnel/extensions/disable_colors_spec.rb +33 -33
- data/spec/rake/funnel/extensions/rexml_spec.rb +20 -20
- data/spec/rake/funnel/extensions/shell_spec.rb +237 -237
- data/spec/rake/funnel/extensions/windows_path_spec.rb +5 -5
- data/spec/rake/funnel/integration/progress_report_spec.rb +149 -149
- data/spec/rake/funnel/integration/sync_output_spec.rb +16 -16
- data/spec/rake/funnel/integration/teamcity/nunit_plugin_spec.rb +110 -110
- data/spec/rake/funnel/integration/teamcity/progress_report_spec.rb +174 -174
- data/spec/rake/funnel/integration/teamcity/service_messages_spec.rb +136 -136
- data/spec/rake/funnel/integration/teamcity/teamcity_spec.rb +34 -34
- data/spec/rake/funnel/support/argument_mapper/styles/msdeploy_spec.rb +222 -222
- data/spec/rake/funnel/support/argument_mapper/styles/nunit_spec.rb +25 -25
- data/spec/rake/funnel/support/argument_mapper/styles/styles_spec.rb +214 -214
- data/spec/rake/funnel/support/assembly_version/from_version_files_spec.rb +66 -61
- data/spec/rake/funnel/support/assembly_version_writer_spec.rb +140 -140
- data/spec/rake/funnel/support/binary_version_reader_spec.rb +29 -29
- data/spec/rake/funnel/support/copier_spec.rb +58 -58
- data/spec/rake/funnel/support/environments/loader_spec.rb +143 -143
- data/spec/rake/funnel/support/internal/finder_spec.rb +229 -229
- data/spec/rake/funnel/support/internal/instantiate_symbol_spec.rb +182 -183
- data/spec/rake/funnel/support/mapper_spec.rb +87 -87
- data/spec/rake/funnel/support/mono_spec.rb +57 -57
- data/spec/rake/funnel/support/msbuild/build_tool_spec.rb +21 -21
- data/spec/rake/funnel/support/msdeploy/registry_patch_spec.rb +139 -139
- data/spec/rake/funnel/support/patch_spec.rb +108 -108
- data/spec/rake/funnel/support/specs_remover/Sample.csproj +28 -28
- data/spec/rake/funnel/support/specs_remover_spec.rb +116 -116
- data/spec/rake/funnel/support/template_engine_spec.rb +65 -65
- data/spec/rake/funnel/support/timing/report_spec.rb +129 -129
- data/spec/rake/funnel/support/version_info_spec.rb +333 -228
- data/spec/rake/funnel/support/which_spec.rb +65 -65
- data/spec/rake/funnel/support/zipper_spec.rb +77 -77
- data/spec/rake/funnel/tasks/assembly_version_spec.rb +45 -45
- data/spec/rake/funnel/tasks/bin_path_spec.rb +52 -52
- data/spec/rake/funnel/tasks/copy_spec.rb +44 -44
- data/spec/rake/funnel/tasks/environments_spec.rb +249 -247
- data/spec/rake/funnel/tasks/msbuild_spec.rb +91 -91
- data/spec/rake/funnel/tasks/msdeploy_spec.rb +220 -220
- data/spec/rake/funnel/tasks/nunit_spec.rb +74 -74
- data/spec/rake/funnel/tasks/paket_spec.rb +140 -142
- data/spec/rake/funnel/tasks/quick_template_spec.rb +62 -62
- data/spec/rake/funnel/tasks/side_by_side_specs_spec.rb +58 -58
- data/spec/rake/funnel/tasks/timing_spec.rb +133 -133
- data/spec/rake/funnel/tasks/zip_spec.rb +50 -50
- data/spec/spec_helper.rb +43 -33
- metadata +2 -3
- data/lib/rake/funnel/support/side_by_side_specs.rb +0 -3
@@ -1,116 +1,116 @@
|
|
1
|
-
describe Rake::Funnel::Support::SpecsRemover do
|
2
|
-
describe 'removal' do
|
3
|
-
let(:projects) { [] }
|
4
|
-
let(:references) { [] }
|
5
|
-
let(:specs) { [] }
|
6
|
-
|
7
|
-
before {
|
8
|
-
allow(Dir).to receive(:[]).and_return(%w(project.proj))
|
9
|
-
allow(File).to receive(:read).and_return('<root></root>')
|
10
|
-
allow(File).to receive(:open)
|
11
|
-
allow(RakeFileUtils).to receive(:rm)
|
12
|
-
}
|
13
|
-
|
14
|
-
before {
|
15
|
-
described_class.remove({
|
16
|
-
projects: projects,
|
17
|
-
references: references,
|
18
|
-
specs: specs
|
19
|
-
})
|
20
|
-
}
|
21
|
-
|
22
|
-
describe 'arguments' do
|
23
|
-
context 'string projects' do
|
24
|
-
let(:projects) { '**/*.??proj' }
|
25
|
-
|
26
|
-
it 'should succeed' do
|
27
|
-
expect(true).to be(true)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'string references' do
|
32
|
-
let(:projects) { '**/*.??proj' }
|
33
|
-
let(:references) { 'Reference' }
|
34
|
-
|
35
|
-
it 'should succeed' do
|
36
|
-
expect(true).to be(true)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'string specs' do
|
41
|
-
let(:projects) { '**/*.??proj' }
|
42
|
-
let(:specs) { '*Specs.cs' }
|
43
|
-
|
44
|
-
it 'should succeed' do
|
45
|
-
expect(true).to be(true)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'project unchanged' do
|
51
|
-
let(:projects) { '**/*.??proj' }
|
52
|
-
let(:references) { 'Reference' }
|
53
|
-
let(:specs) { '*Specs.cs' }
|
54
|
-
|
55
|
-
it 'should not write XML' do
|
56
|
-
expect(File).not_to have_received(:open)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'example' do
|
62
|
-
let(:projects) { %w(**/*.??proj) }
|
63
|
-
let(:references) { %w(Sample-Ref-1 Sample-Ref-2 Sample-Ref-3) }
|
64
|
-
let(:specs) { %w(*Specs.cs **/*Specs.cs) }
|
65
|
-
|
66
|
-
let(:temp_dir) { Dir.mktmpdir }
|
67
|
-
|
68
|
-
before {
|
69
|
-
FileUtils.cp_r(File.join(File.dirname(__FILE__), 'specs_remover/.'), temp_dir)
|
70
|
-
}
|
71
|
-
|
72
|
-
before {
|
73
|
-
allow(RakeFileUtils).to receive(:rm)
|
74
|
-
}
|
75
|
-
|
76
|
-
before {
|
77
|
-
Dir.chdir(temp_dir) do
|
78
|
-
described_class.remove({
|
79
|
-
projects: projects,
|
80
|
-
references: references,
|
81
|
-
specs: specs
|
82
|
-
})
|
83
|
-
end
|
84
|
-
}
|
85
|
-
|
86
|
-
after {
|
87
|
-
FileUtils.rm_rf(temp_dir)
|
88
|
-
}
|
89
|
-
|
90
|
-
describe 'code files' do
|
91
|
-
it 'should keep production code' do
|
92
|
-
expect(RakeFileUtils).not_to have_received(:rm).with('Code.cs')
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should delete specs' do
|
96
|
-
expect(RakeFileUtils).to have_received(:rm).with('Specs.cs')
|
97
|
-
expect(RakeFileUtils).to have_received(:rm).with('FooSpecs.cs')
|
98
|
-
expect(RakeFileUtils).to have_received(:rm).with('subdir/BarSpecs.cs')
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe 'projects' do
|
103
|
-
def project_xml
|
104
|
-
File.read(File.join(temp_dir, 'Sample.csproj'))
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should remove references' do
|
108
|
-
expect(project_xml).not_to include('Sample-Ref-1', 'Sample-Ref-2', 'Sample-Ref-3')
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should remove spec files' do
|
112
|
-
expect(project_xml).not_to include('Specs.cs', 'SampleSpecs.cs')
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
1
|
+
describe Rake::Funnel::Support::SpecsRemover do
|
2
|
+
describe 'removal' do
|
3
|
+
let(:projects) { [] }
|
4
|
+
let(:references) { [] }
|
5
|
+
let(:specs) { [] }
|
6
|
+
|
7
|
+
before {
|
8
|
+
allow(Dir).to receive(:[]).and_return(%w(project.proj))
|
9
|
+
allow(File).to receive(:read).and_return('<root></root>')
|
10
|
+
allow(File).to receive(:open)
|
11
|
+
allow(RakeFileUtils).to receive(:rm)
|
12
|
+
}
|
13
|
+
|
14
|
+
before {
|
15
|
+
described_class.remove({
|
16
|
+
projects: projects,
|
17
|
+
references: references,
|
18
|
+
specs: specs
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
describe 'arguments' do
|
23
|
+
context 'string projects' do
|
24
|
+
let(:projects) { '**/*.??proj' }
|
25
|
+
|
26
|
+
it 'should succeed' do
|
27
|
+
expect(true).to be(true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'string references' do
|
32
|
+
let(:projects) { '**/*.??proj' }
|
33
|
+
let(:references) { 'Reference' }
|
34
|
+
|
35
|
+
it 'should succeed' do
|
36
|
+
expect(true).to be(true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'string specs' do
|
41
|
+
let(:projects) { '**/*.??proj' }
|
42
|
+
let(:specs) { '*Specs.cs' }
|
43
|
+
|
44
|
+
it 'should succeed' do
|
45
|
+
expect(true).to be(true)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'project unchanged' do
|
51
|
+
let(:projects) { '**/*.??proj' }
|
52
|
+
let(:references) { 'Reference' }
|
53
|
+
let(:specs) { '*Specs.cs' }
|
54
|
+
|
55
|
+
it 'should not write XML' do
|
56
|
+
expect(File).not_to have_received(:open)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'example' do
|
62
|
+
let(:projects) { %w(**/*.??proj) }
|
63
|
+
let(:references) { %w(Sample-Ref-1 Sample-Ref-2 Sample-Ref-3) }
|
64
|
+
let(:specs) { %w(*Specs.cs **/*Specs.cs) }
|
65
|
+
|
66
|
+
let(:temp_dir) { Dir.mktmpdir }
|
67
|
+
|
68
|
+
before {
|
69
|
+
FileUtils.cp_r(File.join(File.dirname(__FILE__), 'specs_remover/.'), temp_dir)
|
70
|
+
}
|
71
|
+
|
72
|
+
before {
|
73
|
+
allow(RakeFileUtils).to receive(:rm)
|
74
|
+
}
|
75
|
+
|
76
|
+
before {
|
77
|
+
Dir.chdir(temp_dir) do
|
78
|
+
described_class.remove({
|
79
|
+
projects: projects,
|
80
|
+
references: references,
|
81
|
+
specs: specs
|
82
|
+
})
|
83
|
+
end
|
84
|
+
}
|
85
|
+
|
86
|
+
after {
|
87
|
+
FileUtils.rm_rf(temp_dir)
|
88
|
+
}
|
89
|
+
|
90
|
+
describe 'code files' do
|
91
|
+
it 'should keep production code' do
|
92
|
+
expect(RakeFileUtils).not_to have_received(:rm).with('Code.cs')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should delete specs' do
|
96
|
+
expect(RakeFileUtils).to have_received(:rm).with('Specs.cs')
|
97
|
+
expect(RakeFileUtils).to have_received(:rm).with('FooSpecs.cs')
|
98
|
+
expect(RakeFileUtils).to have_received(:rm).with('subdir/BarSpecs.cs')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'projects' do
|
103
|
+
def project_xml
|
104
|
+
File.read(File.join(temp_dir, 'Sample.csproj'))
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should remove references' do
|
108
|
+
expect(project_xml).not_to include('Sample-Ref-1', 'Sample-Ref-2', 'Sample-Ref-3')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should remove spec files' do
|
112
|
+
expect(project_xml).not_to include('Specs.cs', 'SampleSpecs.cs')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -1,65 +1,65 @@
|
|
1
|
-
describe Rake::Funnel::Support::TemplateEngine do
|
2
|
-
it 'should render nil' do
|
3
|
-
expect(described_class.render(nil)).to eq('')
|
4
|
-
end
|
5
|
-
|
6
|
-
it 'should render empty string' do
|
7
|
-
expect(described_class.render('')).to eq('')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should static string' do
|
11
|
-
expect(described_class.render('hello world')).to eq('hello world')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should support ruby' do
|
15
|
-
expect(described_class.render('<%= 42 %>')).to eq('42')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should omit newlines for pure ruby lines' do
|
19
|
-
template = <<-EOF
|
20
|
-
<%= 42 %>
|
21
|
-
EOF
|
22
|
-
|
23
|
-
expect(described_class.render(template)).to eq('42')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should not omit newlines for mixed ruby lines' do
|
27
|
-
template = <<-EOF
|
28
|
-
12 <%= 34 %> 56
|
29
|
-
EOF
|
30
|
-
|
31
|
-
expect(described_class.render(template)).to eq("12 34 56\n")
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should support @ instead of <%= %>' do
|
35
|
-
expect(described_class.render('@String.to_s@')).to eq('String')
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'binding' do
|
39
|
-
context 'without binding' do
|
40
|
-
it 'should not support contextual variables' do
|
41
|
-
var = 42
|
42
|
-
template = '<%= var %>'
|
43
|
-
|
44
|
-
expect { described_class.render(template) }.to raise_error
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with binding' do
|
49
|
-
def get_binding(value)
|
50
|
-
binding
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should support contextual variables with binding' do
|
54
|
-
template = '<%= value %>'
|
55
|
-
|
56
|
-
expect(described_class.render(template, nil, get_binding(42))).to eq('42')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should report errors with file name' do
|
62
|
-
expect { described_class.render('<%= undefined %>', 'file.template') }
|
63
|
-
.to raise_error { |ex| expect(ex.backtrace.join("\n")).to match(/file\.template/) }
|
64
|
-
end
|
65
|
-
end
|
1
|
+
describe Rake::Funnel::Support::TemplateEngine do
|
2
|
+
it 'should render nil' do
|
3
|
+
expect(described_class.render(nil)).to eq('')
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'should render empty string' do
|
7
|
+
expect(described_class.render('')).to eq('')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should static string' do
|
11
|
+
expect(described_class.render('hello world')).to eq('hello world')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should support ruby' do
|
15
|
+
expect(described_class.render('<%= 42 %>')).to eq('42')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should omit newlines for pure ruby lines' do
|
19
|
+
template = <<-EOF
|
20
|
+
<%= 42 %>
|
21
|
+
EOF
|
22
|
+
|
23
|
+
expect(described_class.render(template)).to eq('42')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not omit newlines for mixed ruby lines' do
|
27
|
+
template = <<-EOF
|
28
|
+
12 <%= 34 %> 56
|
29
|
+
EOF
|
30
|
+
|
31
|
+
expect(described_class.render(template)).to eq("12 34 56\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should support @ instead of <%= %>' do
|
35
|
+
expect(described_class.render('@String.to_s@')).to eq('String')
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'binding' do
|
39
|
+
context 'without binding' do
|
40
|
+
it 'should not support contextual variables' do
|
41
|
+
var = 42
|
42
|
+
template = '<%= var %>'
|
43
|
+
|
44
|
+
expect { described_class.render(template) }.to raise_error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with binding' do
|
49
|
+
def get_binding(value)
|
50
|
+
binding
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should support contextual variables with binding' do
|
54
|
+
template = '<%= value %>'
|
55
|
+
|
56
|
+
expect(described_class.render(template, nil, get_binding(42))).to eq('42')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should report errors with file name' do
|
62
|
+
expect { described_class.render('<%= undefined %>', 'file.template') }
|
63
|
+
.to raise_error { |ex| expect(ex.backtrace.join("\n")).to match(/file\.template/) }
|
64
|
+
end
|
65
|
+
end
|
@@ -1,129 +1,129 @@
|
|
1
|
-
include Rake
|
2
|
-
include Rake::Funnel::Support::Timing
|
3
|
-
|
4
|
-
describe Rake::Funnel::Support::Timing::Report do
|
5
|
-
|
6
|
-
include DSL
|
7
|
-
|
8
|
-
subject { described_class.new(stats, opts) }
|
9
|
-
|
10
|
-
let(:opts) { {} }
|
11
|
-
|
12
|
-
before {
|
13
|
-
allow($stdout).to receive(:puts)
|
14
|
-
allow($stderr).to receive(:puts)
|
15
|
-
subject.render
|
16
|
-
}
|
17
|
-
|
18
|
-
shared_examples_for :report do
|
19
|
-
it 'should separator lines' do
|
20
|
-
expect($stdout).to have_received(:puts)
|
21
|
-
.with(Regexp.new('-' * described_class::HEADER_WIDTH)).exactly(4).times
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should print the header' do
|
25
|
-
expect($stdout).to have_received(:puts).with('Build time report')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should print the total time' do
|
29
|
-
expect($stdout).to have_received(:puts).with(/^Total\s+00:00:00/)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should print the build status' do
|
33
|
-
expect($stdout).to have_received(:puts).with(/Status\s+OK/)
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when rake succeeded' do
|
37
|
-
let(:opts) { { failed: false } }
|
38
|
-
|
39
|
-
it 'should print the successful build status' do
|
40
|
-
expect($stdout).to have_received(:puts).with(/Status\s+OK/)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when rake failed' do
|
45
|
-
let(:opts) { { failed: true } }
|
46
|
-
|
47
|
-
it 'should print the failed build status' do
|
48
|
-
expect($stderr).to have_received(:puts).with(/Status\s+Failed/)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'empty report' do
|
54
|
-
let(:stats) { Statistics.new }
|
55
|
-
|
56
|
-
it_should_behave_like :report
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'report for 2 tasks' do
|
60
|
-
let(:stats) {
|
61
|
-
s = Statistics.new
|
62
|
-
s.benchmark(task :foo) { }
|
63
|
-
s.benchmark(task :bar) { }
|
64
|
-
s
|
65
|
-
}
|
66
|
-
|
67
|
-
it_should_behave_like :report
|
68
|
-
|
69
|
-
it 'should print each task' do
|
70
|
-
expect($stdout).to have_received(:puts).with(/^foo/)
|
71
|
-
expect($stdout).to have_received(:puts).with(/^bar/)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should print each task's time" do
|
75
|
-
expect($stdout).to have_received(:puts).with(/00:00:00/).exactly(3).times
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'formatting' do
|
80
|
-
let(:stats) {
|
81
|
-
s = Statistics.new
|
82
|
-
s.benchmark(task task_name) { }
|
83
|
-
s
|
84
|
-
}
|
85
|
-
|
86
|
-
let(:header_space) {
|
87
|
-
diff = task_name.to_s.length - subject.columns[0].header.length
|
88
|
-
diff = 0 if diff < 0
|
89
|
-
diff + described_class::SPACE
|
90
|
-
}
|
91
|
-
|
92
|
-
let(:header_underline) {
|
93
|
-
[subject.columns[0].header.length, task_name.to_s.length].max
|
94
|
-
}
|
95
|
-
|
96
|
-
let(:value_space) {
|
97
|
-
diff = subject.columns.first.header.length - task_name.to_s.length
|
98
|
-
diff = 0 if diff < 0
|
99
|
-
diff + described_class::SPACE
|
100
|
-
}
|
101
|
-
|
102
|
-
shared_examples_for :padding do
|
103
|
-
it 'should pad headers' do
|
104
|
-
expect($stdout).to have_received(:puts)
|
105
|
-
.with(Regexp.new("^#{subject.columns[0].header}\\s{#{header_space}}#{subject.columns[1].header}"))
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should pad header underlines' do
|
109
|
-
expect($stdout).to have_received(:puts).with(Regexp.new("^-{#{header_underline}}\\s+"))
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should pad the task names' do
|
113
|
-
expect($stdout).to have_received(:puts).with(Regexp.new("^#{task_name}\\s{#{value_space}}\\d"))
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'task names are shorter than headers' do
|
118
|
-
let(:task_name) { :a }
|
119
|
-
|
120
|
-
it_should_behave_like :padding
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'task names are longer than headers' do
|
124
|
-
let(:task_name) { :aaaaaaaaaaaa }
|
125
|
-
|
126
|
-
it_should_behave_like :padding
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
1
|
+
include Rake
|
2
|
+
include Rake::Funnel::Support::Timing
|
3
|
+
|
4
|
+
describe Rake::Funnel::Support::Timing::Report do
|
5
|
+
|
6
|
+
include DSL
|
7
|
+
|
8
|
+
subject { described_class.new(stats, opts) }
|
9
|
+
|
10
|
+
let(:opts) { {} }
|
11
|
+
|
12
|
+
before {
|
13
|
+
allow($stdout).to receive(:puts)
|
14
|
+
allow($stderr).to receive(:puts)
|
15
|
+
subject.render
|
16
|
+
}
|
17
|
+
|
18
|
+
shared_examples_for :report do
|
19
|
+
it 'should separator lines' do
|
20
|
+
expect($stdout).to have_received(:puts)
|
21
|
+
.with(Regexp.new('-' * described_class::HEADER_WIDTH)).exactly(4).times
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should print the header' do
|
25
|
+
expect($stdout).to have_received(:puts).with('Build time report')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should print the total time' do
|
29
|
+
expect($stdout).to have_received(:puts).with(/^Total\s+00:00:00/)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should print the build status' do
|
33
|
+
expect($stdout).to have_received(:puts).with(/Status\s+OK/)
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when rake succeeded' do
|
37
|
+
let(:opts) { { failed: false } }
|
38
|
+
|
39
|
+
it 'should print the successful build status' do
|
40
|
+
expect($stdout).to have_received(:puts).with(/Status\s+OK/)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when rake failed' do
|
45
|
+
let(:opts) { { failed: true } }
|
46
|
+
|
47
|
+
it 'should print the failed build status' do
|
48
|
+
expect($stderr).to have_received(:puts).with(/Status\s+Failed/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'empty report' do
|
54
|
+
let(:stats) { Statistics.new }
|
55
|
+
|
56
|
+
it_should_behave_like :report
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'report for 2 tasks' do
|
60
|
+
let(:stats) {
|
61
|
+
s = Statistics.new
|
62
|
+
s.benchmark(task :foo) { }
|
63
|
+
s.benchmark(task :bar) { }
|
64
|
+
s
|
65
|
+
}
|
66
|
+
|
67
|
+
it_should_behave_like :report
|
68
|
+
|
69
|
+
it 'should print each task' do
|
70
|
+
expect($stdout).to have_received(:puts).with(/^foo/)
|
71
|
+
expect($stdout).to have_received(:puts).with(/^bar/)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should print each task's time" do
|
75
|
+
expect($stdout).to have_received(:puts).with(/00:00:00/).exactly(3).times
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'formatting' do
|
80
|
+
let(:stats) {
|
81
|
+
s = Statistics.new
|
82
|
+
s.benchmark(task task_name) { }
|
83
|
+
s
|
84
|
+
}
|
85
|
+
|
86
|
+
let(:header_space) {
|
87
|
+
diff = task_name.to_s.length - subject.columns[0].header.length
|
88
|
+
diff = 0 if diff < 0
|
89
|
+
diff + described_class::SPACE
|
90
|
+
}
|
91
|
+
|
92
|
+
let(:header_underline) {
|
93
|
+
[subject.columns[0].header.length, task_name.to_s.length].max
|
94
|
+
}
|
95
|
+
|
96
|
+
let(:value_space) {
|
97
|
+
diff = subject.columns.first.header.length - task_name.to_s.length
|
98
|
+
diff = 0 if diff < 0
|
99
|
+
diff + described_class::SPACE
|
100
|
+
}
|
101
|
+
|
102
|
+
shared_examples_for :padding do
|
103
|
+
it 'should pad headers' do
|
104
|
+
expect($stdout).to have_received(:puts)
|
105
|
+
.with(Regexp.new("^#{subject.columns[0].header}\\s{#{header_space}}#{subject.columns[1].header}"))
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should pad header underlines' do
|
109
|
+
expect($stdout).to have_received(:puts).with(Regexp.new("^-{#{header_underline}}\\s+"))
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should pad the task names' do
|
113
|
+
expect($stdout).to have_received(:puts).with(Regexp.new("^#{task_name}\\s{#{value_space}}\\d"))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'task names are shorter than headers' do
|
118
|
+
let(:task_name) { :a }
|
119
|
+
|
120
|
+
it_should_behave_like :padding
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'task names are longer than headers' do
|
124
|
+
let(:task_name) { :aaaaaaaaaaaa }
|
125
|
+
|
126
|
+
it_should_behave_like :padding
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|