albacore 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/EULA.txt +19 -0
  2. data/README.markdown +70 -0
  3. data/VERSION +1 -0
  4. data/lib/albacore.rb +9 -0
  5. data/lib/albacore/assemblyinfo.rb +104 -0
  6. data/lib/albacore/expandtemplates.rb +64 -0
  7. data/lib/albacore/msbuild.rb +63 -0
  8. data/lib/albacore/mspectestrunner.rb +33 -0
  9. data/lib/albacore/ncoverconsole.rb +64 -0
  10. data/lib/albacore/ncoverreport.rb +61 -0
  11. data/lib/albacore/ncoverreports/assemblyfilter.rb +10 -0
  12. data/lib/albacore/ncoverreports/branchcoverage.rb +10 -0
  13. data/lib/albacore/ncoverreports/classfilter.rb +9 -0
  14. data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -0
  15. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -0
  16. data/lib/albacore/ncoverreports/documentfilter.rb +9 -0
  17. data/lib/albacore/ncoverreports/fullcoveragereport.rb +21 -0
  18. data/lib/albacore/ncoverreports/methodcoverage.rb +10 -0
  19. data/lib/albacore/ncoverreports/methodfilter.rb +9 -0
  20. data/lib/albacore/ncoverreports/namespacefilter.rb +9 -0
  21. data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -0
  22. data/lib/albacore/ncoverreports/summaryreport.rb +22 -0
  23. data/lib/albacore/ncoverreports/symbolcoverage.rb +10 -0
  24. data/lib/albacore/nunittestrunner.rb +38 -0
  25. data/lib/albacore/sftp.rb +24 -0
  26. data/lib/albacore/sqlcmd.rb +55 -0
  27. data/lib/albacore/ssh.rb +25 -0
  28. data/lib/albacore/support/albacore_helper.rb +4 -0
  29. data/lib/albacore/support/failure.rb +22 -0
  30. data/lib/albacore/support/logging.rb +32 -0
  31. data/lib/albacore/support/runcommand.rb +45 -0
  32. data/lib/albacore/support/yamlconfig.rb +30 -0
  33. data/lib/albacore/zipdirectory.rb +55 -0
  34. data/lib/rake/assemblyinfotask.rb +22 -0
  35. data/lib/rake/expandtemplatestask.rb +21 -0
  36. data/lib/rake/msbuildtask.rb +22 -0
  37. data/lib/rake/ncoverconsoletask.rb +22 -0
  38. data/lib/rake/ncoverreporttask.rb +22 -0
  39. data/lib/rake/nunittask.rb +22 -0
  40. data/lib/rake/renametask.rb +25 -0
  41. data/lib/rake/sftptask.rb +21 -0
  42. data/lib/rake/sqlcmdtask.rb +22 -0
  43. data/lib/rake/sshtask.rb +21 -0
  44. data/lib/rake/ziptask.rb +21 -0
  45. data/rakefile.rb +144 -0
  46. data/spec/assemblyinfo_spec.rb +246 -0
  47. data/spec/assemblyinfotask_spec.rb +31 -0
  48. data/spec/expandtemplates_spec.rb +127 -0
  49. data/spec/expandtemplatestask_spec.rb +31 -0
  50. data/spec/msbuild_spec.rb +173 -0
  51. data/spec/msbuildtask_spec.rb +31 -0
  52. data/spec/ncoverconsole_spec.rb +247 -0
  53. data/spec/ncoverconsoletask_spec.rb +31 -0
  54. data/spec/ncoverreport_spec.rb +577 -0
  55. data/spec/ncoverreporttask_spec.rb +31 -0
  56. data/spec/nunittask_spec.rb +31 -0
  57. data/spec/patches/system_patch.rb +16 -0
  58. data/spec/patches/tasklib_patch.rb +12 -0
  59. data/spec/renametask_spec.rb +30 -0
  60. data/spec/sftp_spec.rb +30 -0
  61. data/spec/sftptask_spec.rb +41 -0
  62. data/spec/sqlcmd_spec.rb +139 -0
  63. data/spec/sqlcmdtask_spec.rb +31 -0
  64. data/spec/ssh_spec.rb +48 -0
  65. data/spec/sshtask_spec.rb +39 -0
  66. data/spec/support/AssemblyInfo/assemblyinfo.yml +2 -0
  67. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.NUnit.dll +0 -0
  68. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.dll +0 -0
  69. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.MSpecTests.dll +0 -0
  70. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.dll +0 -0
  71. data/spec/support/CodeCoverage/mspec/assemblies/nunit.framework.dll +0 -0
  72. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.Tests.dll +0 -0
  73. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.dll +0 -0
  74. data/spec/support/CodeCoverage/nunit/assemblies/nunit.framework.dll +0 -0
  75. data/spec/support/CodeCoverage/nunit/failing_assemblies/TestSolution.FailingTests.dll +0 -0
  76. data/spec/support/CodeCoverage/nunit/failing_assemblies/nunit.framework.dll +0 -0
  77. data/spec/support/CodeCoverage/report/coverage.xml +4578 -0
  78. data/spec/support/TestSolution/TestSolution.FailingTests/FailingTestFixture.cs +19 -0
  79. data/spec/support/TestSolution/TestSolution.FailingTests/Properties/AssemblyInfo.cs +36 -0
  80. data/spec/support/TestSolution/TestSolution.FailingTests/TestSolution.FailingTests.csproj +63 -0
  81. data/spec/support/TestSolution/TestSolution.MSpecTests/Properties/AssemblyInfo.cs +36 -0
  82. data/spec/support/TestSolution/TestSolution.MSpecTests/SomeSpecTest.cs +18 -0
  83. data/spec/support/TestSolution/TestSolution.MSpecTests/TestSolution.MSpecTests.csproj +77 -0
  84. data/spec/support/TestSolution/TestSolution.Tests/Properties/AssemblyInfo.cs +36 -0
  85. data/spec/support/TestSolution/TestSolution.Tests/SomeTestFixture.cs +23 -0
  86. data/spec/support/TestSolution/TestSolution.Tests/TestSolution.Tests.csproj +69 -0
  87. data/spec/support/TestSolution/TestSolution.sln +38 -0
  88. data/spec/support/TestSolution/TestSolution/Class1.cs +17 -0
  89. data/spec/support/TestSolution/TestSolution/Properties/AssemblyInfo.cs +36 -0
  90. data/spec/support/TestSolution/TestSolution/TestSolution.csproj +59 -0
  91. data/spec/support/assemblyinfotester.rb +42 -0
  92. data/spec/support/expandtemplates/datafiles/multiplevalues.yml +3 -0
  93. data/spec/support/expandtemplates/datafiles/multitemplate-specificfile.yml +11 -0
  94. data/spec/support/expandtemplates/datafiles/multitemplate.yml +4 -0
  95. data/spec/support/expandtemplates/datafiles/sample.yml +1 -0
  96. data/spec/support/expandtemplates/templates/multipleinstance.config +4 -0
  97. data/spec/support/expandtemplates/templates/multiplevalues.config +1 -0
  98. data/spec/support/expandtemplates/templates/sample.config +1 -0
  99. data/spec/support/expandtemplatestestdata.rb +69 -0
  100. data/spec/support/msbuildtestdata.rb +32 -0
  101. data/spec/support/ncoverreporttestdata.rb +26 -0
  102. data/spec/support/spec_helper.rb +15 -0
  103. data/spec/support/test.yml +4 -0
  104. data/spec/support/zip/files/subfolder/sub file.txt +1 -0
  105. data/spec/support/zip/files/testfile.txt +1 -0
  106. data/spec/support/ziptestdata.rb +8 -0
  107. data/spec/yamlconfig_spec.rb +62 -0
  108. data/spec/zip_spec.rb +18 -0
  109. data/spec/ziptask_spec.rb +31 -0
  110. data/yaml_autoconfig_test.yml +1 -0
  111. metadata +262 -0
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ncoverreport'
3
+ require 'rake/ncoverreporttask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::NCoverReportTask, "when running" do
7
+ before :all do
8
+ task = Albacore::NCoverReportTask.new() do |t|
9
+ @yielded_object = t
10
+ end
11
+ task.extend(TasklibPatch)
12
+ Rake::Task[:ncoverreport].invoke
13
+ end
14
+
15
+ it "should yield the ncover report api" do
16
+ @yielded_object.kind_of?(NCoverReport).should == true
17
+ end
18
+ end
19
+
20
+ describe Albacore::NCoverReportTask, "when execution fails" do
21
+ before :all do
22
+ @task = Albacore::NCoverReportTask.new(:failingtask)
23
+ @task.extend(TasklibPatch)
24
+ @task.fail
25
+ Rake::Task["failingtask"].invoke
26
+ end
27
+
28
+ it "should fail the rake task" do
29
+ @task.task_failed.should == true
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/nunittestrunner'
3
+ require 'rake/nunittask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::NUnitTask, "when running" do
7
+ before :all do
8
+ task = Albacore::NUnitTask.new() do |t|
9
+ @yielded_object = t
10
+ end
11
+ task.extend(TasklibPatch)
12
+ Rake::Task[:nunit].invoke
13
+ end
14
+
15
+ it "should yield the nunit api" do
16
+ @yielded_object.kind_of?(NUnitTestRunner).should be_true
17
+ end
18
+ end
19
+
20
+ describe Albacore::NUnitTask, "when execution fails" do
21
+ before :all do
22
+ @task = Albacore::NUnitTask.new(:failingtask)
23
+ @task.extend(TasklibPatch)
24
+ @task.fail
25
+ Rake::Task["failingtask"].invoke
26
+ end
27
+
28
+ it "should fail the rake task" do
29
+ @task.task_failed.should == true
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ module SystemPatch
2
+ attr_accessor :disable_system, :force_system_failure
3
+
4
+ def initialize
5
+ @disable_system = false
6
+ @force_command_failure = false
7
+ end
8
+
9
+ def system(cmd)
10
+ $system_command = cmd
11
+ result = true
12
+ result = super(cmd) if !disable_system
13
+ return false if @force_system_failure
14
+ return result
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module TasklibPatch
2
+ attr_accessor :task_failed
3
+
4
+ def initialize
5
+ super()
6
+ @task_failed = false
7
+ end
8
+
9
+ def fail
10
+ @task_failed = true
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'rake/renametask'
3
+ require 'tasklib_patch'
4
+
5
+ describe Albacore::RenameTask, "when running" do
6
+ before :all do
7
+ task = Albacore::RenameTask.new() do |t|
8
+ @yielded_object = t
9
+ end
10
+ task.extend(TasklibPatch)
11
+ Rake::Task[:rename].invoke
12
+ end
13
+
14
+ it "should yield the rename api" do
15
+ @yielded_object.kind_of?(Albacore::RenameTask).should be_true
16
+ end
17
+ end
18
+
19
+ describe Albacore::RenameTask, "when execution fails" do
20
+ before :all do
21
+ @task = Albacore::RenameTask.new(:failingtask)
22
+ @task.extend(TasklibPatch)
23
+ @task.fail
24
+ Rake::Task["failingtask"].invoke
25
+ end
26
+
27
+ it "should fail the rake task" do
28
+ @task.task_failed.should == true
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/sftp'
3
+
4
+ describe Sftp, 'when uploading files over sftp' do
5
+ before :each do
6
+ @sftpstub = Net::SFTP::Session.stub_instance(:upload! => nil)
7
+ Net::SFTP.stub_method(:start).yields(@sftpstub)
8
+
9
+ @sftp = Sftp.new
10
+ @sftp.server="server"
11
+ @sftp.username="user"
12
+ @sftp.password="secret"
13
+
14
+ @sftp.upload_files = {
15
+ "some.file" => "./somefolder/some.file",
16
+ "another.file" => "another/folder/another.file"
17
+ }
18
+
19
+ @sftp.upload
20
+ end
21
+
22
+ it "should attempt to open a connection with the supplied connection information" do
23
+ Net::SFTP.should have_received(:start).with("server", "user", :password => "secret")
24
+ end
25
+
26
+ it "should upload the local files to the remote destination" do
27
+ @sftpstub.should have_received(:upload!).with("some.file", "./somefolder/some.file")
28
+ @sftpstub.should have_received(:upload!).with("another.file", "another/folder/another.file")
29
+ end
30
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/sftp'
3
+ require 'rake/sftptask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::SftpTask, "when running" do
7
+ before :all do
8
+ @sftpstub = Net::SFTP::Session.stub_instance(:upload! => nil)
9
+ Net::SFTP.stub_method(:start).yields(@sftpstub)
10
+ end
11
+
12
+ before :each do
13
+ task = Albacore::SftpTask.new() do |t|
14
+ @yielded_object = t
15
+ end
16
+ task.extend(TasklibPatch)
17
+ Rake::Task[:sftp].invoke
18
+ end
19
+
20
+ it "should yield the sftp api" do
21
+ @yielded_object.kind_of?(Sftp).should == true
22
+ end
23
+ end
24
+
25
+ describe Albacore::SftpTask, "when execution fails" do
26
+ before :all do
27
+ @sftpstub = Net::SFTP::Session.stub_instance(:upload! => nil)
28
+ Net::SFTP.stub_method(:start).yields(@sftpstub)
29
+ end
30
+
31
+ before :each do
32
+ @task = Albacore::SftpTask.new(:failingtask)
33
+ @task.extend(TasklibPatch)
34
+ @task.fail
35
+ Rake::Task["failingtask"].invoke
36
+ end
37
+
38
+ it "should fail the rake task" do
39
+ @task.task_failed.should be_true
40
+ end
41
+ end
@@ -0,0 +1,139 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/sqlcmd'
3
+
4
+ describe SQLCmd, "when running a script file against a database with authentication information" do
5
+ before :all do
6
+ cmd = SQLCmd.new
7
+ cmd.path_to_command = "sqlcmd.exe"
8
+ cmd.log_level = :verbose
9
+ cmd.extend(SystemPatch)
10
+ cmd.disable_system = true
11
+
12
+ cmd.server="a server"
13
+ cmd.database="a database"
14
+ cmd.username="some user"
15
+ cmd.password="shh! it's a secret!"
16
+ cmd.scripts << "somescript.sql"
17
+
18
+ cmd.run
19
+ end
20
+
21
+ it "should specify the location of the sqlcmd exe" do
22
+ $system_command.should include("sqlcmd.exe")
23
+ end
24
+
25
+ it "should specify the script file" do
26
+ $system_command.should include("-i \"somescript.sql\"")
27
+ end
28
+
29
+ it "should specify the server" do
30
+ $system_command.should include("-S \"a server\"")
31
+ end
32
+
33
+ it "should specify the database" do
34
+ $system_command.should include("-d \"a database\"")
35
+ end
36
+
37
+ it "should specify the username" do
38
+ $system_command.should include("-U \"some user\"")
39
+ end
40
+
41
+ it "should specify the password" do
42
+ $system_command.should include("-P \"shh! it's a secret!\"")
43
+ end
44
+ end
45
+
46
+ describe SQLCmd, "when running with no command path specified" do
47
+ before :all do
48
+ strio = StringIO.new
49
+ @cmd = SQLCmd.new
50
+ @cmd.log_level = :verbose
51
+ @cmd.log_device = strio
52
+ @cmd.extend(SystemPatch)
53
+ @cmd.disable_system = true
54
+
55
+ @cmd.run
56
+ @log_data = strio.string
57
+ end
58
+
59
+ it "should fail" do
60
+ @cmd.failed.should be_true
61
+ end
62
+
63
+ it "should log a failure message" do
64
+ @log_data.should include('SQLCmd.path_to_command cannot be nil.')
65
+ end
66
+ end
67
+
68
+ describe SQLCmd, "when execution of sqlcmd fails" do
69
+ before :all do
70
+ strio = StringIO.new
71
+ @cmd = SQLCmd.new
72
+ @cmd.path_to_command="sqlcmd.exe"
73
+ @cmd.log_level = :verbose
74
+ @cmd.log_device = strio
75
+ @cmd.extend(SystemPatch)
76
+ @cmd.disable_system = true
77
+ @cmd.force_system_failure = true
78
+
79
+ @cmd.run
80
+ @log_data = strio.string
81
+ end
82
+
83
+
84
+ it "should fail" do
85
+ @cmd.failed.should be_true
86
+ end
87
+
88
+ it "should log a failure message" do
89
+ @log_data.should include('SQLCmd Failed. See Build Log For Detail.')
90
+ end
91
+ end
92
+
93
+ describe SQLCmd, "when running multiple script files" do
94
+ before :all do
95
+ cmd = SQLCmd.new
96
+ cmd.path_to_command = "sqlcmd.exe"
97
+ cmd.log_level = :verbose
98
+ cmd.extend(SystemPatch)
99
+ cmd.disable_system = true
100
+
101
+ cmd.scripts << "did you get.sql"
102
+ cmd.scripts << "that thing.sql"
103
+ cmd.scripts << "i sent you.sql"
104
+
105
+ cmd.run
106
+ end
107
+
108
+ it "should specify the first script file" do
109
+ $system_command.should include("-i \"did you get.sql\"")
110
+ end
111
+
112
+ it "should specify the second script file" do
113
+ $system_command.should include("-i \"that thing.sql\"")
114
+ end
115
+
116
+ it "should specify the third script file" do
117
+ $system_command.should include("-i \"i sent you.sql\"")
118
+ end
119
+ end
120
+
121
+ describe SQLCmd, "when running with variables specified" do
122
+ before :all do
123
+ cmd = SQLCmd.new
124
+ cmd.path_to_command = "sqlcmd.exe"
125
+ cmd.log_level = :verbose
126
+ cmd.extend(SystemPatch)
127
+ cmd.disable_system = true
128
+ cmd.scripts << "somescript.sql"
129
+
130
+ cmd.variables = {:myvar => "my value", :another_var => :another_value}
131
+
132
+ cmd.run
133
+ end
134
+
135
+ it "should supply the variables to sqlcmd" do
136
+ $system_command.should include("-v myvar=my value")
137
+ $system_command.should include("-v another_var=another_value")
138
+ end
139
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/sqlcmd'
3
+ require 'rake/sqlcmdtask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::SQLCmdTask, "when running" do
7
+ before :all do
8
+ task = Albacore::SQLCmdTask.new() do |t|
9
+ @yielded_object = t
10
+ end
11
+ task.extend(TasklibPatch)
12
+ Rake::Task[:sqlcmd].invoke
13
+ end
14
+
15
+ it "should yield the sqlcmd api" do
16
+ @yielded_object.kind_of?(SQLCmd).should == true
17
+ end
18
+ end
19
+
20
+ describe Albacore::SQLCmdTask, "when execution fails" do
21
+ before :all do
22
+ @task = Albacore::SQLCmdTask.new(:failingtask)
23
+ @task.extend(TasklibPatch)
24
+ @task.fail
25
+ Rake::Task["failingtask"].invoke
26
+ end
27
+
28
+ it "should fail the rake task" do
29
+ @task.task_failed.should be_true
30
+ end
31
+ end
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ssh'
3
+
4
+ describe Ssh, 'when executing a command over ssh' do
5
+ before :each do
6
+ @sshstub = Net::SSH::Connection::Session.stub_instance(:exec! => nil)
7
+ Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)
8
+
9
+ @ssh = Ssh.new
10
+ @ssh.server="server"
11
+ @ssh.username="user"
12
+ @ssh.password="secret"
13
+ @ssh.commands="execute THIS!"
14
+
15
+ @ssh.execute
16
+ end
17
+
18
+ it "should attempt to open a connection with the supplied connection information" do
19
+ Net::SSH.should have_received(:start)
20
+ end
21
+
22
+ it "should execute the command" do
23
+ @sshstub.should have_received(:exec!)
24
+ end
25
+ end
26
+
27
+ describe Ssh, "when executing multiple commands over ssh" do
28
+ before :each do
29
+ @sshstub = Net::SSH::Connection::Session.stub_instance(:exec! => nil)
30
+ Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)
31
+
32
+ @ssh = Ssh.new
33
+ @ssh.server="server"
34
+ @ssh.username="user"
35
+ @ssh.password="secret"
36
+
37
+ @ssh.commands << "execute THIS!"
38
+ @ssh.commands << "another execution"
39
+
40
+ @ssh.execute
41
+ end
42
+
43
+ it "should execute all of the specified commands" do
44
+ @sshstub.should have_received(:exec!).twice
45
+ end
46
+
47
+ end
48
+
@@ -0,0 +1,39 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ssh'
3
+ require 'rake/sshtask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::SshTask, "when running" do
7
+ before :all do
8
+ Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)
9
+ end
10
+
11
+ before :each do
12
+ task = Albacore::SshTask.new() do |t|
13
+ @yielded_object = t
14
+ end
15
+ task.extend(TasklibPatch)
16
+ Rake::Task[:ssh].invoke
17
+ end
18
+
19
+ it "should yield the ssh api" do
20
+ @yielded_object.kind_of?(Ssh).should == true
21
+ end
22
+ end
23
+
24
+ describe Albacore::SshTask, "when execution fails" do
25
+ before :all do
26
+ Net::SSH.stub_method(:start, &lambda{}).yields(@sshstub)
27
+ end
28
+
29
+ before :each do
30
+ @task = Albacore::SshTask.new(:failingtask)
31
+ @task.extend(TasklibPatch)
32
+ @task.fail
33
+ Rake::Task["failingtask"].invoke
34
+ end
35
+
36
+ it "should fail the rake task" do
37
+ @task.task_failed.should be_true
38
+ end
39
+ end