albacore 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,22 +47,18 @@ class SQLCmd
47
47
  end
48
48
  integratedParam
49
49
  end
50
-
50
+
51
51
  def check_command
52
52
  sql2008cmdPath = File.join(ENV['SystemDrive'],'program files','microsoft sql server','100','tools','binn', 'sqlcmd.exe')
53
- @command = sql2008cmdPath if File.exists?(sql2008cmdPath)
54
- return true
55
-
56
53
  sql2005cmdPath = File.join(ENV['SystemDrive'],'program files','microsoft sql server','90','tools','binn', 'sqlcmd.exe')
57
- @command = sql2005cmdPath if File.exists?(sql2005cmdPath)
58
- return true
59
-
60
- return true if (!@command.nil?)
61
-
54
+ sql2008cmdPathx86 = File.join(ENV['SystemDrive'],'program files (x86)','microsoft sql server','100','tools','binn', 'sqlcmd.exe')
55
+ sql2005cmdPathx86 = File.join(ENV['SystemDrive'],'program files (x86)','microsoft sql server','90','tools','binn', 'sqlcmd.exe')
56
+ @command = [sql2008cmdPath, sql2005cmdPath, sql2008cmdPathx86, sql2005cmdPathx86].select { |p| File.exist?(p) }.first
57
+ return true if @command != nil
62
58
  fail_with_message 'SQLCmd.command cannot be nil.'
63
59
  return false
64
60
  end
65
-
61
+
66
62
  def build_script_list
67
63
  @scripts.map{|s| "-i \"#{s.strip}\""}.join(" ")
68
64
  end
@@ -1,18 +1,18 @@
1
1
  $: << './'
2
2
  require 'lib/albacore'
3
+ require 'version_bumper'
3
4
 
4
5
  task :default => ['albacore:sample']
5
6
 
6
7
  namespace :specs do
7
8
  require 'spec/rake/spectask'
8
- runtime_is_ironruby = (!defined?(IRONRUBY_VERSION).nil?)
9
9
 
10
10
  @spec_opts = '--colour --format specdoc'
11
11
 
12
12
  desc "Run all specs for albacore"
13
13
  Spec::Rake::SpecTask.new :all do |t|
14
14
  t.spec_files = FileList['spec/**/*_spec.rb'].exclude{ |f|
15
- f if runtime_is_ironruby && (f.include?("ssh") || f.include?("sftp"))
15
+ f if IS_IRONRUBY && (f.include?("zip"))
16
16
  }
17
17
  t.spec_opts << @spec_opts
18
18
  end
@@ -40,7 +40,6 @@ namespace :specs do
40
40
  t.spec_files = FileList['spec/sqlcmd*_spec.rb']
41
41
  t.spec_opts << @spec_opts
42
42
  end
43
-
44
43
 
45
44
  desc "Nant functional specs"
46
45
  Spec::Rake::SpecTask.new :nant do |t|
@@ -107,6 +106,24 @@ namespace :specs do
107
106
  t.spec_files = FileList['spec/yaml*_spec.rb']
108
107
  t.spec_opts << @spec_opts
109
108
  end
109
+
110
+ desc "FluenMigrator functional specs"
111
+ Spec::Rake::SpecTask.new :fluentmigrator do |t|
112
+ t.spec_files = FileList['spec/fluentmigrator*_spec.rb']
113
+ t.spec_opts << @spec_opts
114
+ end
115
+
116
+ desc "Output functional specs"
117
+ Spec::Rake::SpecTask.new :output do |t|
118
+ t.spec_files = FileList['spec/output*_spec.rb']
119
+ t.spec_opts << @spec_opts
120
+ end
121
+
122
+ desc "NChurn functional specs"
123
+ Spec::Rake::SpecTask.new :nchurn do |t|
124
+ t.spec_files = FileList['spec/nchurn*_spec.rb']
125
+ t.spec_opts << @spec_opts
126
+ end
110
127
  end
111
128
 
112
129
  namespace :albacore do
@@ -122,7 +139,8 @@ namespace :albacore do
122
139
  'albacore:ncoverreport',
123
140
  'albacore:mspec',
124
141
  'albacore:nunit',
125
- 'albacore:xunit']
142
+ 'albacore:xunit',
143
+ 'albacore:fluentmigrator']
126
144
 
127
145
  desc "Run a sample MSBuild with YAML autoconfig"
128
146
  msbuild :msbuild
@@ -218,6 +236,18 @@ namespace :albacore do
218
236
  xbuild.targets :clean, :build
219
237
  xbuild.solution = "spec/support/TestSolution/TestSolution.sln"
220
238
  end
239
+
240
+ desc "FluentMigrator Test Runner Example"
241
+ fluentmigrator do |migrator|
242
+ db_file = "#{ENV['TEMP']}/fluentmigrator.sqlite3"
243
+ File.delete(db_file) if File.exist?(db_file)
244
+
245
+ migrator.command = "spec/support/Tools/FluentMigrator-0.9/Migrate.exe"
246
+ migrator.target = "spec/support/FluentMigrator/TestSolution.FluentMigrator.dll"
247
+ migrator.provider = "sqlite"
248
+ migrator.connection = "Data Source=#{db_file};"
249
+ end
250
+
221
251
  end
222
252
 
223
253
  namespace :jeweler do
@@ -236,8 +266,5 @@ namespace :jeweler do
236
266
  "spec/",
237
267
  "pkg/"
238
268
  )
239
-
240
- gs.add_dependency('rake', '>= 0.8.7')
241
- gs.add_dependency('rubyzip', '>= 0.9.4')
242
269
  end
243
270
  end
@@ -24,10 +24,13 @@ describe CSC, "when supplying a file list with 2 files to compile" do
24
24
  end
25
25
  end
26
26
 
27
+ # TODO: If designed by contract this is an unncessary responsibility of the class.
28
+ # It should be removed and only validate that the parameter is being specified as CSC expects it.
27
29
  describe CSC, "when targeting a library and an output file" do
28
30
  before :each do
29
31
  @folder = File.join(File.expand_path(File.dirname(__FILE__)), "support", "csc")
30
32
  csc = CSC.new
33
+
31
34
  csc.compile FileList[File.join(@folder, "File1.cs")]
32
35
  csc.target = :library
33
36
  csc.output = File.join(@folder, "output", "File1.dll")
@@ -217,3 +220,34 @@ describe CSC, "when defining processor symbols" do
217
220
  csc.system_command.should include("/define:symbol1;symbol2")
218
221
  end
219
222
  end
223
+
224
+ describe CSC, "when specifying main entry point be generated" do
225
+ let :csc do
226
+ csc = CSC.new
227
+ csc.main = "Program.Main"
228
+
229
+ csc.extend(SystemPatch)
230
+ csc.disable_system = true
231
+ csc.execute
232
+ csc
233
+ end
234
+
235
+ it "should provide the main parameter" do
236
+ csc.system_command.should include("/main:Program.Main")
237
+ end
238
+ end
239
+
240
+ describe CSC, "when specifying main entry point not be generated" do
241
+ let :csc do
242
+ csc = CSC.new
243
+
244
+ csc.extend(SystemPatch)
245
+ csc.disable_system = true
246
+ csc.execute
247
+ csc
248
+ end
249
+
250
+ it "should not provide the main parameter" do
251
+ csc.system_command.should_not include("/main")
252
+ end
253
+ end
@@ -0,0 +1,185 @@
1
+ require 'spec_helper'
2
+ require 'albacore/fluentmigratorrunner'
3
+
4
+ shared_examples_for "fluentmigrator paths" do
5
+ before :all do
6
+ @fluent_migrator_path = File.join(File.dirname(__FILE__), 'support', 'Tools', 'FluentMigrator-0.9', 'Migrate.exe')
7
+ @test_assembly = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'fluentmigrator', 'assemblies', 'TestSolution.FluentMigrator.dll')
8
+ end
9
+ end
10
+
11
+ describe FluentMigratorRunner, "the command parameters for an migrator runner" do
12
+ it_should_behave_like "fluentmigrator paths"
13
+
14
+ before :all do
15
+ @migrator = FluentMigratorRunner.new(@fluent_migrator_path)
16
+ end
17
+
18
+ context "Required params" do
19
+ before :all do
20
+ @command_parameters = @migrator.get_command_parameters
21
+ end
22
+
23
+ it "doesn't include command" do
24
+ @command_parameters.should_not include(@fluent_migrator_path)
25
+ end
26
+
27
+ it "includes target" do
28
+ @command_parameters.should include("/target")
29
+ end
30
+
31
+ it "includes provider" do
32
+ @command_parameters.should include("/provider")
33
+ end
34
+
35
+ it "includes connection" do
36
+ @command_parameters.should include("/connection")
37
+ end
38
+ end
39
+
40
+ context "Optional options" do
41
+ before :all do
42
+ @migrator.namespace = 'namespace'
43
+ @migrator.output = 'output.txt'
44
+ @migrator.preview = 1
45
+ @migrator.steps = 1
46
+ @migrator.task = 'migrate:up'
47
+ @migrator.version = '001'
48
+ @migrator.verbose = 1
49
+ @migrator.script_directory = 'c:\scripts'
50
+ @migrator.profile = 'MyProfile'
51
+ @migrator.timeout = 90
52
+ @command_parameters = @migrator.get_command_parameters
53
+ end
54
+
55
+ it "includes ns" do
56
+ @command_parameters.should include('/ns')
57
+ end
58
+
59
+ it "includes ouy" do
60
+ @command_parameters.should include('/out')
61
+ end
62
+
63
+ it "includes preview" do
64
+ @command_parameters.should include('/preview')
65
+ end
66
+
67
+ it "includes steps" do
68
+ @command_parameters.should include('/steps')
69
+ end
70
+
71
+ it "includes task" do
72
+ @command_parameters.should include('/task')
73
+ end
74
+
75
+ it "includes version" do
76
+ @command_parameters.should include('/version')
77
+ end
78
+
79
+ it "includes verbose" do
80
+ @command_parameters.should include('/verbose')
81
+ end
82
+
83
+ it "includes wd" do
84
+ @command_parameters.should include('/wd')
85
+ end
86
+
87
+ it "includes profile" do
88
+ @command_parameters.should include('/profile')
89
+ end
90
+
91
+ it "includes timeout" do
92
+ @command_parameters.should include('/timeout')
93
+ end
94
+ end
95
+ end
96
+
97
+ describe FluentMigratorRunner, "the command line string for an fluentmigrator runner" do
98
+ it_should_behave_like "fluentmigrator paths"
99
+
100
+ before :all do
101
+ migrator = FluentMigratorRunner.new(@fluent_migrator_path)
102
+ migrator.target = @test_assembly
103
+
104
+ @command_line = migrator.get_command_line
105
+ @command_parameters = migrator.get_command_parameters
106
+ end
107
+
108
+ it "starts with the path to the command" do
109
+ @command_line.should =~ /^#{@fluent_migrator_path}.*$/
110
+ end
111
+
112
+ it "includes the command parameters" do
113
+ @command_line.downcase.should include(@command_parameters.downcase)
114
+ end
115
+ end
116
+
117
+ describe FluentMigratorRunner, "when using the configuration command and not providing a command in the intializer" do
118
+ it_should_behave_like "fluentmigrator paths"
119
+
120
+ before :all do
121
+ Albacore.configure do |config|
122
+ config.fluentmigrator.command = "configured command"
123
+ end
124
+ @migrator = FluentMigratorRunner.new
125
+ end
126
+
127
+ it "uses the configuration command" do
128
+ @migrator.command.should == "configured command"
129
+ end
130
+ end
131
+
132
+ describe FluentMigratorRunner, "when the command has been set through configuration and providing a command in the intializer" do
133
+ it_should_behave_like "fluentmigrator paths"
134
+
135
+ before :all do
136
+ Albacore.configure do |config|
137
+ config.fluentmigrator.command = "configured command"
138
+ end
139
+ @migrator = FluentMigratorRunner.new("initializer command")
140
+ end
141
+
142
+ it "uses the initializer command" do
143
+ @migrator.command.should == "initializer command"
144
+ end
145
+ end
146
+
147
+ describe FluentMigratorRunner, "when configuration has been provided" do
148
+ before :all do
149
+ Albacore.configure do |config|
150
+ config.fluentmigrator do |migrator|
151
+ migrator.target = 'target.dll'
152
+ migrator.provider = 'provider'
153
+ migrator.connection = 'connection'
154
+ migrator.namespace = 'namespace'
155
+ migrator.output = 'output.txt'
156
+ migrator.preview = true
157
+ migrator.steps = 1
158
+ migrator.task = 'migrate:up'
159
+ migrator.version = '001'
160
+ migrator.verbose = true
161
+ migrator.script_directory = 'c:\scripts'
162
+ migrator.profile = 'MyProfile'
163
+ migrator.timeout = 90
164
+ end
165
+ end
166
+
167
+ @migrator = FluentMigratorRunner.new
168
+ end
169
+
170
+ it "uses the provided configuration" do
171
+ @migrator.target.should == 'target.dll'
172
+ @migrator.provider.should == 'provider'
173
+ @migrator.connection.should == 'connection'
174
+ @migrator.namespace.should == 'namespace'
175
+ @migrator.output.should == 'output.txt'
176
+ @migrator.preview.should == true
177
+ @migrator.steps.should == 1
178
+ @migrator.task.should == 'migrate:up'
179
+ @migrator.version.should == '001'
180
+ @migrator.verbose.should == true
181
+ @migrator.script_directory.should == 'c:\scripts'
182
+ @migrator.profile.should == 'MyProfile'
183
+ @migrator.timeout.should == 90
184
+ end
185
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ require 'albacore/nchurn'
3
+ require 'patches/system_patch'
4
+
5
+ class NChurn
6
+ attr_accessor :failure_message
7
+
8
+ def fail_with_message(m)
9
+ @failure_message = m
10
+ end
11
+ end
12
+
13
+ class NChurnTestData
14
+ attr_reader :nchurn_command
15
+ attr_reader :output_text
16
+ def initialize
17
+ @nchurn_command = File.join(File.dirname(__FILE__), 'support', 'Tools', 'NChurn-v0.4', 'nchurn.exe')
18
+ @output_text = 'nchurn-test.txt'
19
+
20
+ end
21
+
22
+ def remove!
23
+ FileUtils.rm @output_text if File.exist? @output_text
24
+ end
25
+ end
26
+
27
+ describe NChurn, "when running nchurn" do
28
+ before :all do
29
+ @nchurn = NChurn.new
30
+ @nchurn.extend SystemPatch
31
+ @test_data = NChurnTestData.new
32
+ @test_data.remove!
33
+
34
+ end
35
+
36
+ before :each do
37
+ @nchurn.failure_message = nil
38
+ end
39
+
40
+ it "should fail with no command" do
41
+ @nchurn.execute
42
+ @nchurn.failure_message.should eql('Churn Analysis Failed. See Build Log For Detail.')
43
+ end
44
+
45
+ it "should succeed and redirect to file" do
46
+ @nchurn.command = NChurnTestData.new.nchurn_command
47
+ @nchurn.output @test_data.output_text
48
+
49
+ @nchurn.execute
50
+ @nchurn.failure_message.should be_nil
51
+ File.exist?(@test_data.output_text).should be_true
52
+ end
53
+
54
+ it "should pass all parameters correctly" do
55
+ @nchurn.command = "nchurn.exe"
56
+ @nchurn.disable_system = true
57
+ @nchurn.output @test_data.output_text
58
+ @nchurn.input "file.txt"
59
+
60
+ @nchurn.churn_precent 30
61
+ @nchurn.top 10
62
+ @nchurn.report_as :xml
63
+ @nchurn.env_path 'c:/tools'
64
+ @nchurn.adapter :git
65
+ @nchurn.exclude "exe"
66
+ @nchurn.include "foo"
67
+
68
+ @nchurn.execute
69
+ @nchurn.failure_message.should be_nil
70
+ cmd = %{"nchurn.exe" -i "file.txt" -c 0.3 -t 10 -r xml -p "c:/tools" -a git -x "exe" -n "foo" > "nchurn-test.txt"}
71
+ @nchurn.system_command.should eql(cmd)
72
+ end
73
+
74
+ end
75
+
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+ require 'spec_helper.rb'
3
+ require 'albacore/nuspec.rb'
4
+
5
+ if IS_IRONRUBY
6
+ require 'support\ironruby_validator'
7
+ else
8
+ require 'support\nokogiri_validator'
9
+ end
10
+
11
+ describe Nuspec, 'when creating a file with minimum requirements' do
12
+ let(:working_dir) do
13
+ wd = File.expand_path(File.join(File.dirname(__FILE__), 'support/nuspec/output'))
14
+ FileUtils.mkdir(wd) unless File.exist?(wd)
15
+ wd
16
+ end
17
+
18
+ let(:nuspec_output) { File.join(working_dir, 'nuspec_test.nuspec') }
19
+ let(:schema_file) { File.expand_path(File.join(working_dir, '../', 'nuspec.xsd')) }
20
+
21
+ let(:nuspec) do
22
+ nuspec = Nuspec.new
23
+ nuspec.id="nuspec_test"
24
+ nuspec.output_file = "nuspec_test.nuspec"
25
+ nuspec.version = "1.2.3"
26
+ nuspec.authors = "Author Name"
27
+ nuspec.description = "test_xml_document"
28
+ nuspec.working_directory = working_dir
29
+ nuspec
30
+ end
31
+
32
+ before do
33
+ nuspec.execute
34
+ end
35
+
36
+ it "should produce the nuspec xml" do
37
+ File.exist?(nuspec_output).should be_true
38
+ end
39
+
40
+ it "should produce a valid xml file" do
41
+ is_valid = XmlValidator.validate(nuspec_output, schema_file)
42
+ is_valid.should be_true
43
+ end
44
+ end