albacore 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/EULA.txt +19 -0
- data/README.markdown +70 -0
- data/VERSION +1 -0
- data/lib/albacore.rb +9 -0
- data/lib/albacore/assemblyinfo.rb +104 -0
- data/lib/albacore/expandtemplates.rb +64 -0
- data/lib/albacore/msbuild.rb +63 -0
- data/lib/albacore/mspectestrunner.rb +33 -0
- data/lib/albacore/ncoverconsole.rb +64 -0
- data/lib/albacore/ncoverreport.rb +61 -0
- data/lib/albacore/ncoverreports/assemblyfilter.rb +10 -0
- data/lib/albacore/ncoverreports/branchcoverage.rb +10 -0
- data/lib/albacore/ncoverreports/classfilter.rb +9 -0
- data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -0
- data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -0
- data/lib/albacore/ncoverreports/documentfilter.rb +9 -0
- data/lib/albacore/ncoverreports/fullcoveragereport.rb +21 -0
- data/lib/albacore/ncoverreports/methodcoverage.rb +10 -0
- data/lib/albacore/ncoverreports/methodfilter.rb +9 -0
- data/lib/albacore/ncoverreports/namespacefilter.rb +9 -0
- data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -0
- data/lib/albacore/ncoverreports/summaryreport.rb +22 -0
- data/lib/albacore/ncoverreports/symbolcoverage.rb +10 -0
- data/lib/albacore/nunittestrunner.rb +38 -0
- data/lib/albacore/sftp.rb +24 -0
- data/lib/albacore/sqlcmd.rb +55 -0
- data/lib/albacore/ssh.rb +25 -0
- data/lib/albacore/support/albacore_helper.rb +4 -0
- data/lib/albacore/support/failure.rb +22 -0
- data/lib/albacore/support/logging.rb +32 -0
- data/lib/albacore/support/runcommand.rb +45 -0
- data/lib/albacore/support/yamlconfig.rb +30 -0
- data/lib/albacore/zipdirectory.rb +55 -0
- data/lib/rake/assemblyinfotask.rb +22 -0
- data/lib/rake/expandtemplatestask.rb +21 -0
- data/lib/rake/msbuildtask.rb +22 -0
- data/lib/rake/ncoverconsoletask.rb +22 -0
- data/lib/rake/ncoverreporttask.rb +22 -0
- data/lib/rake/nunittask.rb +22 -0
- data/lib/rake/renametask.rb +25 -0
- data/lib/rake/sftptask.rb +21 -0
- data/lib/rake/sqlcmdtask.rb +22 -0
- data/lib/rake/sshtask.rb +21 -0
- data/lib/rake/ziptask.rb +21 -0
- data/rakefile.rb +144 -0
- data/spec/assemblyinfo_spec.rb +246 -0
- data/spec/assemblyinfotask_spec.rb +31 -0
- data/spec/expandtemplates_spec.rb +127 -0
- data/spec/expandtemplatestask_spec.rb +31 -0
- data/spec/msbuild_spec.rb +173 -0
- data/spec/msbuildtask_spec.rb +31 -0
- data/spec/ncoverconsole_spec.rb +247 -0
- data/spec/ncoverconsoletask_spec.rb +31 -0
- data/spec/ncoverreport_spec.rb +577 -0
- data/spec/ncoverreporttask_spec.rb +31 -0
- data/spec/nunittask_spec.rb +31 -0
- data/spec/patches/system_patch.rb +16 -0
- data/spec/patches/tasklib_patch.rb +12 -0
- data/spec/renametask_spec.rb +30 -0
- data/spec/sftp_spec.rb +30 -0
- data/spec/sftptask_spec.rb +41 -0
- data/spec/sqlcmd_spec.rb +139 -0
- data/spec/sqlcmdtask_spec.rb +31 -0
- data/spec/ssh_spec.rb +48 -0
- data/spec/sshtask_spec.rb +39 -0
- data/spec/support/AssemblyInfo/assemblyinfo.yml +2 -0
- data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.NUnit.dll +0 -0
- data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.dll +0 -0
- data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.MSpecTests.dll +0 -0
- data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.dll +0 -0
- data/spec/support/CodeCoverage/mspec/assemblies/nunit.framework.dll +0 -0
- data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.Tests.dll +0 -0
- data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.dll +0 -0
- data/spec/support/CodeCoverage/nunit/assemblies/nunit.framework.dll +0 -0
- data/spec/support/CodeCoverage/nunit/failing_assemblies/TestSolution.FailingTests.dll +0 -0
- data/spec/support/CodeCoverage/nunit/failing_assemblies/nunit.framework.dll +0 -0
- data/spec/support/CodeCoverage/report/coverage.xml +4578 -0
- data/spec/support/TestSolution/TestSolution.FailingTests/FailingTestFixture.cs +19 -0
- data/spec/support/TestSolution/TestSolution.FailingTests/Properties/AssemblyInfo.cs +36 -0
- data/spec/support/TestSolution/TestSolution.FailingTests/TestSolution.FailingTests.csproj +63 -0
- data/spec/support/TestSolution/TestSolution.MSpecTests/Properties/AssemblyInfo.cs +36 -0
- data/spec/support/TestSolution/TestSolution.MSpecTests/SomeSpecTest.cs +18 -0
- data/spec/support/TestSolution/TestSolution.MSpecTests/TestSolution.MSpecTests.csproj +77 -0
- data/spec/support/TestSolution/TestSolution.Tests/Properties/AssemblyInfo.cs +36 -0
- data/spec/support/TestSolution/TestSolution.Tests/SomeTestFixture.cs +23 -0
- data/spec/support/TestSolution/TestSolution.Tests/TestSolution.Tests.csproj +69 -0
- data/spec/support/TestSolution/TestSolution.sln +38 -0
- data/spec/support/TestSolution/TestSolution/Class1.cs +17 -0
- data/spec/support/TestSolution/TestSolution/Properties/AssemblyInfo.cs +36 -0
- data/spec/support/TestSolution/TestSolution/TestSolution.csproj +59 -0
- data/spec/support/assemblyinfotester.rb +42 -0
- data/spec/support/expandtemplates/datafiles/multiplevalues.yml +3 -0
- data/spec/support/expandtemplates/datafiles/multitemplate-specificfile.yml +11 -0
- data/spec/support/expandtemplates/datafiles/multitemplate.yml +4 -0
- data/spec/support/expandtemplates/datafiles/sample.yml +1 -0
- data/spec/support/expandtemplates/templates/multipleinstance.config +4 -0
- data/spec/support/expandtemplates/templates/multiplevalues.config +1 -0
- data/spec/support/expandtemplates/templates/sample.config +1 -0
- data/spec/support/expandtemplatestestdata.rb +69 -0
- data/spec/support/msbuildtestdata.rb +32 -0
- data/spec/support/ncoverreporttestdata.rb +26 -0
- data/spec/support/spec_helper.rb +15 -0
- data/spec/support/test.yml +4 -0
- data/spec/support/zip/files/subfolder/sub file.txt +1 -0
- data/spec/support/zip/files/testfile.txt +1 -0
- data/spec/support/ziptestdata.rb +8 -0
- data/spec/yamlconfig_spec.rb +62 -0
- data/spec/zip_spec.rb +18 -0
- data/spec/ziptask_spec.rb +31 -0
- data/yaml_autoconfig_test.yml +1 -0
- metadata +262 -0
data/EULA.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2009 Derick Bailey. All Rights Reserved.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Welcome to the Albacore project.
|
2
|
+
|
3
|
+
Albacore is intended to be a professional quality suite of Rake tasks to help automate the process of building a .NET based system. All tasks are built using a test-first approach through rspec, and all tests are included in the Albacore gem.
|
4
|
+
|
5
|
+
## How To Install Albacore From Gemcutter Gems:
|
6
|
+
|
7
|
+
If you would like to install the current, stable release of Albacore, you can do so easily through the Gemcutter gem server. Follow these simple instructions and you will be good to go.
|
8
|
+
|
9
|
+
**Step 1:** Setup Gemcutter as a gem source
|
10
|
+
|
11
|
+
> gem source -a http://gemcutter.org
|
12
|
+
|
13
|
+
(note: you only need to do this once for any given computer that is going to install gems from gemcutter.)
|
14
|
+
|
15
|
+
**Step 2:** Install the Albacore gem
|
16
|
+
|
17
|
+
> gem install Albacore
|
18
|
+
|
19
|
+
## How To Manually Build And Install The Albacore Gem
|
20
|
+
|
21
|
+
If you would like to install the latest source code for Albacore, and get all the new features and functionality (possibly in an unstable form), you can manually build and install the Albacore gem. Follow these simple instructions and you will be good to go.
|
22
|
+
|
23
|
+
**Step 1:** Clone Albacore
|
24
|
+
|
25
|
+
Use your Github account to fork Albacore, or clone it directly from my public clone URL.
|
26
|
+
|
27
|
+
> git clone git://github.com/derickbailey/Albacore.git Albacore
|
28
|
+
|
29
|
+
**Step 2:** Build the gem
|
30
|
+
|
31
|
+
In your local clone of Albacore, use the jeweler rake tasks to build the latest version of the Albacore code into a gem.
|
32
|
+
|
33
|
+
> rake jeweler:gemspec
|
34
|
+
>
|
35
|
+
> rake jeweler:build
|
36
|
+
|
37
|
+
this will produce an 'Albacore-#.#.#.gem' file in the 'pkg' folder, where '#.#.#' is the version number. For example 'Albacore-0.0.1.gem'.
|
38
|
+
|
39
|
+
**Step 3:** Install the gem
|
40
|
+
|
41
|
+
After building the gem, you can install it from your local file system.
|
42
|
+
|
43
|
+
> gem install -l pkg\Albacore-#.#.#.gem
|
44
|
+
|
45
|
+
where '#.#.#' is the version number of the gem. For example 'Albacore-0.0.1.gem'
|
46
|
+
|
47
|
+
## How To Use Albacore
|
48
|
+
|
49
|
+
After installing Albacore, you only need to
|
50
|
+
|
51
|
+
require 'albacore'
|
52
|
+
|
53
|
+
in your rakefile. This will allow you to use the tasks that Albacore includes.
|
54
|
+
|
55
|
+
desc "Run a sample build using the MSBuildTask"
|
56
|
+
Albacore::MSBuildTask.new(:msbuild) do |msb|
|
57
|
+
msb.properties :configuration => :Debug
|
58
|
+
msb.targets [:Clean, :Build]
|
59
|
+
msb.solution = "spec/support/TestSolution/TestSolution.sln"
|
60
|
+
end
|
61
|
+
|
62
|
+
Beyond the simple example, check out the [Albacore Wiki](http://wiki.github.com/derickbailey/Albacore) for detailed instructions on how to use the built in tasks and their options.
|
63
|
+
|
64
|
+
## Contributors
|
65
|
+
|
66
|
+
Many thanks for contributions to Albacore are due:
|
67
|
+
|
68
|
+
* [Ben Hall](http://github.com/benhall): SSH, SFTP, ZipDirectory, Rename, YAML auto config, and other great additions
|
69
|
+
* [Sean Biefeld](http://github.com/seanbiefeld): MSpecTestRunner for NCoverConsole
|
70
|
+
* [Kevin Colyar](http://github.com/kevincolyar): Testing and updating of MSBuild to work with Cygwin
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.7
|
data/lib/albacore.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
2
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "albacore"))
|
3
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "albacore", 'support'))
|
4
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "rake"))
|
5
|
+
|
6
|
+
require 'logging'
|
7
|
+
|
8
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'rake/*.rb')).each {|f| require f }
|
9
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'albacore/*.rb')).each {|f| require f }
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class AssemblyInfo
|
4
|
+
include Failure
|
5
|
+
include YAMLConfig
|
6
|
+
|
7
|
+
attr_accessor :version, :title, :description, :output_file, :custom_attributes
|
8
|
+
attr_accessor :copyright, :com_visible, :com_guid, :company_name, :product_name
|
9
|
+
attr_accessor :file_version, :trademark, :namespaces
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super()
|
13
|
+
@namespaces = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def write
|
17
|
+
write_assemblyinfo @output_file
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_assemblyinfo(assemblyinfo_file)
|
21
|
+
valid = check_output_file assemblyinfo_file
|
22
|
+
return if !valid
|
23
|
+
|
24
|
+
asm_data = build_assembly_info_data
|
25
|
+
|
26
|
+
@logger.info "Generating Assembly Info File At: " + File.expand_path(assemblyinfo_file)
|
27
|
+
File.open(assemblyinfo_file, 'w') do |f|
|
28
|
+
f.write asm_data
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def check_output_file(file)
|
33
|
+
return true if file
|
34
|
+
fail_with_message 'output_file cannot be nil'
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_assembly_info_data
|
39
|
+
asm_data = build_using_statements + "\n"
|
40
|
+
|
41
|
+
asm_data << build_attribute("AssemblyTitle", @title) if @title != nil
|
42
|
+
asm_data << build_attribute("AssemblyDescription", @description) if @description != nil
|
43
|
+
asm_data << build_attribute("AssemblyCompany", @company_name) if @company_name != nil
|
44
|
+
asm_data << build_attribute("AssemblyProduct", @product_name) if @product_name != nil
|
45
|
+
|
46
|
+
asm_data << build_attribute("AssemblyCopyright", @copyright) if @copyright != nil
|
47
|
+
asm_data << build_attribute("AssemblyTrademark", @trademark) if @trademark != nil
|
48
|
+
|
49
|
+
asm_data << build_attribute("ComVisible", @com_visible) if @com_visible != nil
|
50
|
+
asm_data << build_attribute("Guid", @com_guid) if @com_guid != nil
|
51
|
+
|
52
|
+
asm_data << build_attribute("AssemblyVersion", @version) if @version != nil
|
53
|
+
asm_data << build_attribute("AssemblyFileVersion", @file_version) if @file_version != nil
|
54
|
+
|
55
|
+
asm_data << "\n"
|
56
|
+
if @custom_attributes != nil
|
57
|
+
attributes = build_custom_attributes()
|
58
|
+
asm_data << attributes.join
|
59
|
+
asm_data << "\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
asm_data
|
63
|
+
end
|
64
|
+
|
65
|
+
def custom_attributes(attributes)
|
66
|
+
@custom_attributes = attributes
|
67
|
+
end
|
68
|
+
|
69
|
+
def namespaces(namespaces)
|
70
|
+
@namespaces = namespaces
|
71
|
+
end
|
72
|
+
|
73
|
+
def build_using_statements
|
74
|
+
@namespaces = [] if @namespaces.nil?
|
75
|
+
|
76
|
+
@namespaces << "System.Reflection"
|
77
|
+
@namespaces << "System.Runtime.InteropServices"
|
78
|
+
|
79
|
+
namespaces = ''
|
80
|
+
@namespaces.each do |ns|
|
81
|
+
namespaces << "using #{ns};\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
namespaces
|
85
|
+
end
|
86
|
+
|
87
|
+
def build_attribute(attr_name, attr_data)
|
88
|
+
attribute = "[assembly: #{attr_name}("
|
89
|
+
attribute << "#{attr_data.inspect}" if attr_data != nil
|
90
|
+
attribute << ")]\n"
|
91
|
+
|
92
|
+
@logger.debug "Build Assembly Info Attribute: " + attribute
|
93
|
+
attribute
|
94
|
+
end
|
95
|
+
|
96
|
+
def build_custom_attributes()
|
97
|
+
attributes = []
|
98
|
+
@custom_attributes.each do |key, value|
|
99
|
+
attributes << build_attribute(key, value)
|
100
|
+
end
|
101
|
+
attributes
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class ExpandTemplates
|
5
|
+
include YAMLConfig
|
6
|
+
include Logging
|
7
|
+
|
8
|
+
attr_accessor :expand_files, :data_file
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@expand_files = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def expand
|
16
|
+
return if @data_file.nil?
|
17
|
+
return if @expand_files.empty?
|
18
|
+
|
19
|
+
config = read_config
|
20
|
+
@expand_files.each { |template_file, output_file|
|
21
|
+
file_config = get_config_for_file config, template_file
|
22
|
+
expand_template template_file, output_file, file_config
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def expand_template(template_file, output_file, config)
|
29
|
+
@logger.info "Parsing #{template_file} into #{output_file}"
|
30
|
+
|
31
|
+
template_data = ''
|
32
|
+
File.open(template_file, "r") {|f|
|
33
|
+
template_data = f.read
|
34
|
+
}
|
35
|
+
template_data
|
36
|
+
|
37
|
+
template_data.gsub!(/\#\{(.*?)\}/) {|match|
|
38
|
+
value = config[$1]
|
39
|
+
@logger.debug "Found \"\#{#{$1}}\": Replacing with \"#{value}\"."
|
40
|
+
value
|
41
|
+
}
|
42
|
+
|
43
|
+
File.open(output_file, "w") {|output|
|
44
|
+
output.write(template_data)
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def read_config
|
49
|
+
YAML::load(File.open(@data_file, "r"))
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_config_for_file(original_config, file)
|
53
|
+
filename = File.basename(file)
|
54
|
+
file_config = original_config[filename]
|
55
|
+
if file_config.nil?
|
56
|
+
@logger.debug "No config data found for #{filename}. Using global data."
|
57
|
+
new_config = original_config
|
58
|
+
else
|
59
|
+
@logger.debug "Found config data for #{filename}."
|
60
|
+
new_config = original_config.merge(file_config)
|
61
|
+
end
|
62
|
+
new_config
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class MSBuild
|
4
|
+
include RunCommand
|
5
|
+
include YAMLConfig
|
6
|
+
|
7
|
+
attr_accessor :solution, :verbosity
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super()
|
11
|
+
@path_to_command = build_path_to_command
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_path_to_command
|
15
|
+
win_dir = ENV['windir'] || ENV['WINDIR']
|
16
|
+
File.join(win_dir.dup, 'Microsoft.NET', 'Framework', 'v3.5', 'MSBuild.exe')
|
17
|
+
end
|
18
|
+
|
19
|
+
def targets(targets)
|
20
|
+
@targets=targets
|
21
|
+
end
|
22
|
+
|
23
|
+
def properties=(properties)
|
24
|
+
@properties = properties
|
25
|
+
end
|
26
|
+
|
27
|
+
def build
|
28
|
+
build_solution(@solution)
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_solution(solution)
|
32
|
+
check_solution solution
|
33
|
+
|
34
|
+
command_parameters = []
|
35
|
+
command_parameters << "\"#{solution}\""
|
36
|
+
command_parameters << "\"/verbosity:#{@verbosity}\"" if @verbosity != nil
|
37
|
+
command_parameters << build_properties if @properties != nil
|
38
|
+
command_parameters << "\"/target:#{build_targets}\"" if @targets != nil
|
39
|
+
|
40
|
+
result = run_command "MSBuild", command_parameters.join(" ")
|
41
|
+
|
42
|
+
failure_message = 'MSBuild Failed. See Build Log For Detail'
|
43
|
+
fail_with_message failure_message if !result
|
44
|
+
end
|
45
|
+
|
46
|
+
def check_solution(file)
|
47
|
+
return if file
|
48
|
+
msg = 'solution cannot be nil'
|
49
|
+
fail_with_message msg
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_targets
|
53
|
+
@targets.join ";"
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_properties
|
57
|
+
option_text = []
|
58
|
+
@properties.each do |key, value|
|
59
|
+
option_text << "/p:#{key}\=\"#{value}\""
|
60
|
+
end
|
61
|
+
option_text.join(" ")
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class MSpecTestRunner
|
4
|
+
include Logging
|
5
|
+
include YAMLConfig
|
6
|
+
|
7
|
+
attr_accessor :assemblies, :path_to_command, :html_output
|
8
|
+
|
9
|
+
def initialize(path_to_command)
|
10
|
+
super()
|
11
|
+
@path_to_command = path_to_command
|
12
|
+
@assemblies=[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_command_line
|
16
|
+
command = []
|
17
|
+
command << @path_to_command
|
18
|
+
command << build_assembly_list unless @assemblies.empty?
|
19
|
+
command << build_html_output unless @html_output.nil?
|
20
|
+
|
21
|
+
cmdline = command.join(" ")
|
22
|
+
@logger.debug "Build MSpec Test Runner Command Line: " + cmdline
|
23
|
+
cmdline
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_assembly_list
|
27
|
+
@assemblies.map{|asm| "\"#{asm}\""}.join(" ")
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_html_output
|
31
|
+
"--html #{@html_output}"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class NCoverConsole
|
4
|
+
include RunCommand
|
5
|
+
include YAMLConfig
|
6
|
+
|
7
|
+
attr_accessor :output, :testrunner, :working_directory, :cover_assemblies
|
8
|
+
attr_accessor :ignore_assemblies, :coverage
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@output = {}
|
13
|
+
@testrunner_args = []
|
14
|
+
@cover_assemblies = []
|
15
|
+
@ignore_assemblies = []
|
16
|
+
@coverage = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def working_directory=(working_dir)
|
20
|
+
@working_directory = "//working-directory " + working_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def run
|
24
|
+
check_testrunner
|
25
|
+
return false if @failed
|
26
|
+
|
27
|
+
command_parameters = []
|
28
|
+
command_parameters << build_output_options(@output) unless @output.nil?
|
29
|
+
command_parameters << @working_directory unless @working_directory.nil?
|
30
|
+
command_parameters << build_assembly_list("assemblies", @cover_assemblies) unless @cover_assemblies.empty?
|
31
|
+
command_parameters << build_assembly_list("exclude-assemblies", @ignore_assemblies) unless @ignore_assemblies.empty?
|
32
|
+
command_parameters << build_coverage_list(@coverage) unless @coverage.empty?
|
33
|
+
command_parameters << @testrunner.get_command_line
|
34
|
+
|
35
|
+
result = run_command "NCover.Console", command_parameters.join(" ")
|
36
|
+
|
37
|
+
failure_msg = 'Code Coverage Analysis Failed. See Build Log For Detail.'
|
38
|
+
fail_with_message failure_msg if !result
|
39
|
+
end
|
40
|
+
|
41
|
+
def check_testrunner
|
42
|
+
return if (!@testrunner.nil?)
|
43
|
+
msg = 'testrunner cannot be nil.'
|
44
|
+
@logger.info msg
|
45
|
+
fail
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_output_options(output)
|
49
|
+
options = []
|
50
|
+
output.each do |key, value|
|
51
|
+
options << "//#{key} #{value}"
|
52
|
+
end
|
53
|
+
options.join(" ")
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_assembly_list(param_name, list)
|
57
|
+
assembly_list = list.map{|asm| "\"#{asm}\""}.join(';')
|
58
|
+
"//#{param_name} #{assembly_list}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def build_coverage_list(coverage)
|
62
|
+
"//coverage-type \"#{coverage.join(', ')}\""
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'ncoverreports/*.rb')).each {|f| require f }
|
2
|
+
require 'albacore/support/albacore_helper'
|
3
|
+
|
4
|
+
class NCoverReport
|
5
|
+
include RunCommand
|
6
|
+
include YAMLConfig
|
7
|
+
|
8
|
+
attr_accessor :coverage_files, :reports, :required_coverage, :filters
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@coverage_files = []
|
13
|
+
@reports = []
|
14
|
+
@required_coverage = []
|
15
|
+
@filters = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
check_command
|
20
|
+
return if @failed
|
21
|
+
|
22
|
+
command_parameters = []
|
23
|
+
command_parameters << build_coverage_files unless @coverage_files.empty?
|
24
|
+
command_parameters << build_reports unless @reports.empty?
|
25
|
+
command_parameters << build_required_coverage unless @required_coverage.empty?
|
26
|
+
command_parameters << build_filters unless @filters.empty?
|
27
|
+
|
28
|
+
result = run_command "NCover.Reporting", command_parameters.join(" ")
|
29
|
+
|
30
|
+
failure_msg = 'Code Coverage Reporting Failed. See Build Log For Detail.'
|
31
|
+
fail_with_message failure_msg if !result
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_command
|
35
|
+
return if @path_to_command
|
36
|
+
fail_with_message 'NCoverReport.path_to_command cannot be nil.'
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_filters
|
40
|
+
@filters.map{|f| "//cf #{f.get_filter_options}"}.join(" ")
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_coverage_files
|
44
|
+
@coverage_files.map{|f| "\"#{f}\""}.join(" ")
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_reports
|
48
|
+
@reports.map{|r|
|
49
|
+
report = "//or #{r.report_type}"
|
50
|
+
report << ":#{r.report_format}" unless r.report_format.nil?
|
51
|
+
report << ":\"#{r.output_path}\"" unless r.output_path.nil?
|
52
|
+
report
|
53
|
+
}.join(" ")
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_required_coverage
|
57
|
+
@required_coverage.map{|c|
|
58
|
+
coverage = "//mc #{c.get_coverage_options}"
|
59
|
+
}.join(" ")
|
60
|
+
end
|
61
|
+
end
|