albacore 1.0.0 → 2.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. data/.gitignore +6 -21
  2. data/.travis.yml +31 -12
  3. data/Gemfile +14 -6
  4. data/Guardfile +1 -3
  5. data/README.md +200 -47
  6. data/Rakefile +9 -19
  7. data/albacore.gemspec +33 -23
  8. data/lib/albacore.rb +3 -47
  9. data/lib/albacore/albacore_module.rb +57 -0
  10. data/lib/albacore/application.rb +43 -0
  11. data/lib/albacore/cmd_config.rb +66 -0
  12. data/lib/albacore/config_dsl.rb +55 -0
  13. data/lib/albacore/cross_platform_cmd.rb +291 -0
  14. data/lib/albacore/dsl.rb +90 -0
  15. data/lib/albacore/errors/command_failed_error.rb +11 -0
  16. data/lib/albacore/errors/command_not_found_error.rb +13 -0
  17. data/lib/albacore/errors/unfilled_property_error.rb +14 -0
  18. data/lib/albacore/ext/README.md +12 -0
  19. data/lib/albacore/ext/teamcity.rb +64 -0
  20. data/lib/albacore/facts.rb +25 -0
  21. data/lib/albacore/logging.rb +32 -0
  22. data/lib/albacore/nuget_model.rb +387 -0
  23. data/lib/albacore/paths.rb +34 -0
  24. data/lib/albacore/project.rb +141 -0
  25. data/lib/albacore/semver.rb +5 -0
  26. data/lib/albacore/task_types/asmver.rb +72 -0
  27. data/lib/albacore/task_types/asmver/cpp.rb +20 -0
  28. data/lib/albacore/task_types/asmver/cs.rb +17 -0
  29. data/lib/albacore/task_types/asmver/engine.rb +126 -0
  30. data/lib/albacore/task_types/asmver/file_generator.rb +45 -0
  31. data/lib/albacore/task_types/asmver/fs.rb +37 -0
  32. data/lib/albacore/task_types/asmver/vb.rb +27 -0
  33. data/lib/albacore/task_types/build.rb +192 -0
  34. data/lib/albacore/task_types/nugets_authentication.rb +9 -0
  35. data/lib/albacore/task_types/nugets_pack.rb +378 -0
  36. data/lib/albacore/task_types/nugets_restore.rb +138 -0
  37. data/lib/albacore/task_types/test_runner.rb +39 -0
  38. data/lib/albacore/tasks/README.md +16 -0
  39. data/lib/albacore/tasks/albasemver.rb +49 -0
  40. data/lib/albacore/tasks/projectlint.rb +81 -0
  41. data/lib/albacore/tasks/versionizer.rb +65 -0
  42. data/lib/albacore/tools/fluent_migrator.rb +177 -0
  43. data/lib/albacore/tools/restore_hint_paths.rb +112 -0
  44. data/lib/albacore/version.rb +3 -3
  45. data/spec/Rakefile +5 -0
  46. data/spec/albacore_spec.rb +12 -0
  47. data/spec/asmver_spec.rb +151 -0
  48. data/spec/asmver_task_spec.rb +32 -0
  49. data/spec/build_spec.rb +60 -0
  50. data/spec/config_dsl_spec.rb +83 -0
  51. data/spec/cross_platform_cmd_spec.rb +65 -0
  52. data/spec/dsl_spec.rb +39 -0
  53. data/spec/ext_teamcity_spec.rb +71 -0
  54. data/spec/facts_spec.rb +7 -0
  55. data/spec/nuget_model_spec.rb +401 -0
  56. data/spec/nugets_pack_spec.rb +231 -0
  57. data/spec/nugets_restore_spec.rb +55 -0
  58. data/spec/project_spec.rb +26 -0
  59. data/spec/projectlint/added_but_not_on_filesystem/aproject.csproj +29 -0
  60. data/spec/projectlint/correct/File.cs +1 -0
  61. data/spec/projectlint/correct/Image.txt +1 -0
  62. data/spec/projectlint/correct/MyHeavy.heavy +1 -0
  63. data/spec/projectlint/correct/Schema.xsd +1 -0
  64. data/spec/projectlint/correct/SubFolder/AnotherFile.cs +1 -0
  65. data/spec/projectlint/correct/aproject.csproj +29 -0
  66. data/spec/projectlint/on_filesystem_but_not_added/File.cs +1 -0
  67. data/spec/projectlint/on_filesystem_but_not_added/Image.txt +1 -0
  68. data/spec/projectlint/on_filesystem_but_not_added/aproject.csproj +11 -0
  69. data/spec/projectlint_spec.rb +77 -0
  70. data/spec/smoke_spec.rb +55 -0
  71. data/spec/spec_helper.rb +19 -20
  72. data/spec/support/Nuget/NuGet.exe +0 -0
  73. data/spec/support/echo/FSharp.Core.dll +0 -0
  74. data/spec/support/echo/FSharp.Core.xml +10517 -0
  75. data/spec/support/echo/echo.XML +12 -0
  76. data/spec/support/echo/echo.exe +0 -0
  77. data/spec/support/echo/echo.exe.config +17 -0
  78. data/spec/support/echo/echo.pdb +0 -0
  79. data/spec/support/returnstatus/FSharp.Core.dll +0 -0
  80. data/spec/support/returnstatus/FSharp.Core.xml +10517 -0
  81. data/spec/support/returnstatus/returnstatus.XML +12 -0
  82. data/spec/support/returnstatus/returnstatus.exe +0 -0
  83. data/spec/support/returnstatus/returnstatus.exe.config +17 -0
  84. data/spec/support/returnstatus/returnstatus.pdb +0 -0
  85. data/spec/support/sh_interceptor.rb +83 -0
  86. data/spec/testdata/.gitignore +5 -0
  87. data/spec/testdata/DebugProject/.gitignore +1 -0
  88. data/spec/testdata/DebugProject/Degbu.fsproj +57 -0
  89. data/spec/testdata/DebugProject/Degbu.sln +20 -0
  90. data/spec/testdata/DebugProject/Gemfile +1 -0
  91. data/spec/testdata/DebugProject/Library1.fs +4 -0
  92. data/spec/testdata/DebugProject/Rakefile +22 -0
  93. data/spec/testdata/EmptyProject/EmptyProject.csproj +39 -0
  94. data/spec/{assemblyinfo → testdata/EmptyProject/Properties}/AssemblyInfo.cs +5 -5
  95. data/spec/testdata/Gemfile +1 -0
  96. data/spec/testdata/NuGet.exe +0 -0
  97. data/spec/testdata/Project/Library1.fs +4 -0
  98. data/spec/testdata/Project/Project.fsproj +52 -0
  99. data/spec/testdata/Project/Project.sln +20 -0
  100. data/spec/testdata/Project/packages.config +6 -0
  101. data/spec/testdata/Rakefile +22 -0
  102. data/spec/testdata/TestingDependencies/Sample.Commands/Library.fs +6 -0
  103. data/spec/testdata/TestingDependencies/Sample.Commands/Sample.Commands.fsproj +78 -0
  104. data/spec/testdata/TestingDependencies/Sample.Commands/Script.fsx +8 -0
  105. data/spec/testdata/TestingDependencies/Sample.Commands/packages.config +6 -0
  106. data/spec/testdata/TestingDependencies/Sample.Core/Library.fs +3 -0
  107. data/spec/testdata/TestingDependencies/Sample.Core/Sample.Core.fsproj +59 -0
  108. data/spec/testdata/TestingDependencies/Sample.Core/Script.fsx +8 -0
  109. data/spec/testdata/TestingDependencies/Sample.Core/packages.config +4 -0
  110. data/spec/testdata/TestingDependencies/Sample.sln +26 -0
  111. data/spec/testdata/TestingDependencies/vendor/FSharp.Core.dll +0 -0
  112. data/spec/testdata/TestingDependencies/vendor/FSharp.Core.optdata +0 -0
  113. data/spec/testdata/TestingDependencies/vendor/FSharp.Core.sigdata +0 -0
  114. data/spec/testdata/TestingDependencies/vendor/FSharp.Core.xml +8748 -0
  115. data/spec/testdata/example.nuspec +14 -0
  116. data/spec/testdata/example.symbols.nuspec +21 -0
  117. data/spec/tools/fluent_migrator_spec.rb +80 -0
  118. metadata +303 -212
  119. data/.bundle/config +0 -2
  120. data/.rspec +0 -2
  121. data/CONTRIBUTING.md +0 -87
  122. data/LICENSE +0 -21
  123. data/lib/albacore/albacoretask.rb +0 -50
  124. data/lib/albacore/aspnetcompiler.rb +0 -80
  125. data/lib/albacore/assemblyinfo.rb +0 -163
  126. data/lib/albacore/assemblyinfolanguages/assemblyinfoengine.rb +0 -54
  127. data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +0 -18
  128. data/lib/albacore/assemblyinfolanguages/csharpengine.rb +0 -15
  129. data/lib/albacore/assemblyinfolanguages/fsharpengine.rb +0 -23
  130. data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +0 -15
  131. data/lib/albacore/config/aspnetcompilerconfig.rb +0 -30
  132. data/lib/albacore/config/assemblyinfoconfig.rb +0 -18
  133. data/lib/albacore/config/config.rb +0 -22
  134. data/lib/albacore/config/cscconfig.rb +0 -28
  135. data/lib/albacore/config/docuconfig.rb +0 -19
  136. data/lib/albacore/config/execconfig.rb +0 -19
  137. data/lib/albacore/config/fluentmigratorconfig.rb +0 -19
  138. data/lib/albacore/config/ilmergeconfig.rb +0 -19
  139. data/lib/albacore/config/msbuildconfig.rb +0 -29
  140. data/lib/albacore/config/mspecconfig.rb +0 -19
  141. data/lib/albacore/config/mstestconfig.rb +0 -19
  142. data/lib/albacore/config/nantconfig.rb +0 -18
  143. data/lib/albacore/config/nchurnconfig.rb +0 -19
  144. data/lib/albacore/config/ncoverconsoleconfig.rb +0 -19
  145. data/lib/albacore/config/ncoverreportconfig.rb +0 -18
  146. data/lib/albacore/config/ndependconfig.rb +0 -19
  147. data/lib/albacore/config/netversion.rb +0 -28
  148. data/lib/albacore/config/nugetinstallconfig.rb +0 -18
  149. data/lib/albacore/config/nugetpackconfig.rb +0 -18
  150. data/lib/albacore/config/nugetpushconfig.rb +0 -18
  151. data/lib/albacore/config/nugetupdateconfig.rb +0 -18
  152. data/lib/albacore/config/nunitconfig.rb +0 -19
  153. data/lib/albacore/config/nuspecconfig.rb +0 -18
  154. data/lib/albacore/config/plinkconfig.rb +0 -18
  155. data/lib/albacore/config/specflowconfig.rb +0 -18
  156. data/lib/albacore/config/sqlcmdconfig.rb +0 -18
  157. data/lib/albacore/config/unzipconfig.rb +0 -19
  158. data/lib/albacore/config/xbuildconfig.rb +0 -18
  159. data/lib/albacore/config/xunitconfig.rb +0 -18
  160. data/lib/albacore/config/zipdirectoryconfig.rb +0 -18
  161. data/lib/albacore/csc.rb +0 -77
  162. data/lib/albacore/docu.rb +0 -38
  163. data/lib/albacore/exec.rb +0 -20
  164. data/lib/albacore/fluentmigrator.rb +0 -69
  165. data/lib/albacore/ilmerge.rb +0 -38
  166. data/lib/albacore/msbuild.rb +0 -55
  167. data/lib/albacore/mspec.rb +0 -39
  168. data/lib/albacore/mstest.rb +0 -47
  169. data/lib/albacore/nant.rb +0 -41
  170. data/lib/albacore/nchurn.rb +0 -49
  171. data/lib/albacore/ncoverconsole.rb +0 -56
  172. data/lib/albacore/ncoverreport.rb +0 -40
  173. data/lib/albacore/ncoverreports.rb +0 -16
  174. data/lib/albacore/ncoverreports/assemblyfilter.rb +0 -10
  175. data/lib/albacore/ncoverreports/branchcoverage.rb +0 -10
  176. data/lib/albacore/ncoverreports/classfilter.rb +0 -9
  177. data/lib/albacore/ncoverreports/codecoveragebase.rb +0 -27
  178. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +0 -23
  179. data/lib/albacore/ncoverreports/documentfilter.rb +0 -9
  180. data/lib/albacore/ncoverreports/fullcoveragereport.rb +0 -9
  181. data/lib/albacore/ncoverreports/methodcoverage.rb +0 -10
  182. data/lib/albacore/ncoverreports/methodfilter.rb +0 -9
  183. data/lib/albacore/ncoverreports/namespacefilter.rb +0 -9
  184. data/lib/albacore/ncoverreports/reportbase.rb +0 -23
  185. data/lib/albacore/ncoverreports/reportfilterbase.rb +0 -29
  186. data/lib/albacore/ncoverreports/summaryreport.rb +0 -9
  187. data/lib/albacore/ncoverreports/symbolcoverage.rb +0 -9
  188. data/lib/albacore/ndepend.rb +0 -33
  189. data/lib/albacore/nugetinstall.rb +0 -62
  190. data/lib/albacore/nugetpack.rb +0 -50
  191. data/lib/albacore/nugetpush.rb +0 -40
  192. data/lib/albacore/nugetupdate.rb +0 -50
  193. data/lib/albacore/nunit.rb +0 -46
  194. data/lib/albacore/nuspec.rb +0 -180
  195. data/lib/albacore/output.rb +0 -105
  196. data/lib/albacore/plink.rb +0 -50
  197. data/lib/albacore/specflow.rb +0 -30
  198. data/lib/albacore/sqlcmd.rb +0 -67
  199. data/lib/albacore/support/attrmethods.rb +0 -33
  200. data/lib/albacore/support/createtask.rb +0 -50
  201. data/lib/albacore/support/failure.rb +0 -15
  202. data/lib/albacore/support/logging.rb +0 -38
  203. data/lib/albacore/support/openstruct.rb +0 -13
  204. data/lib/albacore/support/platform.rb +0 -25
  205. data/lib/albacore/support/runcommand.rb +0 -45
  206. data/lib/albacore/support/updateattributes.rb +0 -13
  207. data/lib/albacore/support/yamlconfig.rb +0 -18
  208. data/lib/albacore/unzip.rb +0 -42
  209. data/lib/albacore/xbuild.rb +0 -41
  210. data/lib/albacore/xunit.rb +0 -44
  211. data/lib/albacore/zipdirectory.rb +0 -106
  212. data/spec/albacoremodel_spec.rb +0 -52
  213. data/spec/aspnetcompiler_spec.rb +0 -84
  214. data/spec/assemblyinfo_spec.rb +0 -209
  215. data/spec/attrmethods_spec.rb +0 -135
  216. data/spec/config_spec.rb +0 -32
  217. data/spec/createtask_spec.rb +0 -234
  218. data/spec/csc_spec.rb +0 -86
  219. data/spec/docu_spec.rb +0 -31
  220. data/spec/exec_spec.rb +0 -25
  221. data/spec/fluentmigrator_spec.rb +0 -88
  222. data/spec/ilmerge_spec.rb +0 -35
  223. data/spec/msbuild_spec.rb +0 -55
  224. data/spec/mspec_spec.rb +0 -30
  225. data/spec/mstest_spec.rb +0 -35
  226. data/spec/nant_spec.rb +0 -40
  227. data/spec/nchurn_spec.rb +0 -80
  228. data/spec/ncoverconsole_spec.rb +0 -80
  229. data/spec/ncoverreport_spec.rb +0 -139
  230. data/spec/ndepend_spec.rb +0 -26
  231. data/spec/netversion_spec.rb +0 -51
  232. data/spec/nugetinstall_spec.rb +0 -59
  233. data/spec/nugetpack_spec.rb +0 -49
  234. data/spec/nugetpush_spec.rb +0 -39
  235. data/spec/nugetupdate_spec.rb +0 -49
  236. data/spec/nunit_spec.rb +0 -35
  237. data/spec/nuspec/nuspec.xsd +0 -84
  238. data/spec/nuspec_spec.rb +0 -74
  239. data/spec/output/bar/bar.txt +0 -0
  240. data/spec/output/baz.txt +0 -0
  241. data/spec/output/erb.txt +0 -1
  242. data/spec/output/foo/foo/foo.txt +0 -0
  243. data/spec/output_spec.rb +0 -85
  244. data/spec/patch/system_patch.rb +0 -12
  245. data/spec/platform_spec.rb +0 -15
  246. data/spec/plink_spec.rb +0 -56
  247. data/spec/runcommand_spec.rb +0 -92
  248. data/spec/specflow_spec.rb +0 -30
  249. data/spec/sqlcmd_spec.rb +0 -66
  250. data/spec/unzip_spec.rb +0 -56
  251. data/spec/xbuild_spec.rb +0 -40
  252. data/spec/xunit_spec.rb +0 -30
  253. data/spec/yaml/test.yml +0 -3
  254. data/spec/yamlconfig_spec.rb +0 -53
  255. data/spec/zip/baz.txt +0 -0
  256. data/spec/zip/foo/bar/bar.txt +0 -0
  257. data/spec/zip/foo/foo.txt +0 -0
  258. data/spec/zip_spec.rb +0 -97
@@ -0,0 +1,112 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'nokogiri'
4
+ require 'pathname'
5
+ require 'rake'
6
+ require 'albacore/logging'
7
+ require 'albacore/project'
8
+
9
+ module Albacore::Tools
10
+ # a package repository is a location where the nugets or wraps are stored
11
+ class PackageRepo
12
+ include Logging
13
+ # initialize that package repository with a path to all the packages
14
+ def initialize path
15
+ @path = path
16
+ end
17
+ # find the latest package based on the package id
18
+ def find_latest pkg_id
19
+ trace "finding latest from #{@path}, id: #{pkg_id}"
20
+ sorted = Dir.glob(File.join(@path, "#{pkg_id}*/**/*.dll")) # find the latest
21
+ path = sorted.first
22
+ Package.new pkg_id, path
23
+ end
24
+ end
25
+
26
+ # a package encapsulates the properties of a set package with a
27
+ # distinct path, version and id
28
+ class Package
29
+ attr_reader :id, :path
30
+ def initialize id, path
31
+ @id = id
32
+ @path = path
33
+ end
34
+ def path
35
+ @path
36
+ end
37
+ def to_s
38
+ "Package[#{@path}]"
39
+ end
40
+ end
41
+
42
+ # a tuple of a package and a ref
43
+ class MatchedRef
44
+ attr_accessor :package, :ref
45
+ def initialize package, ref
46
+ @package, @ref = package, ref
47
+ end
48
+ end
49
+
50
+
51
+ module RestoreHintPaths
52
+ class Config
53
+ attr_accessor :asmname_to_package
54
+ attr_accessor :lang
55
+ attr_accessor :projs, :dry_run
56
+ def initialize
57
+ @asmname_to_package = {}
58
+ @lang = 'fs'
59
+ end
60
+ end
61
+ class Task
62
+ include Logging
63
+ def initialize config
64
+ @config = config
65
+ end
66
+ def execute
67
+ ps = map_file_list(@config.projs) || find_projs_in_need(@config.lang)
68
+ ps.each do |proj|
69
+ info "fixing #{proj}"
70
+ fix_refs proj, @config.asmname_to_package
71
+ info "saving #{proj}"
72
+ proj.save unless @config.dry_run
73
+ end
74
+ end
75
+
76
+ private
77
+ def find_projs_in_need ext
78
+ map_file_list FileList["./src/**/*.#{ext}proj"]
79
+ end
80
+ def map_file_list fl
81
+ return nil if fl.nil?
82
+ fl.collect{ |path| Project.new(path) }.
83
+ keep_if{ |fp| fp.has_faulty_refs? && fp.has_packages_config? }
84
+ end
85
+ def matched_refs refs, packages, asmname_to_package = {}
86
+ refs.collect { |ref|
87
+ ref_include_id = asmname_to_package.fetch(ref['Include'].split(',')[0]) { |k| k }
88
+ found_pkg = packages[ref_include_id]
89
+ debug "ref[Include] = #{ref_include_id}, package: #{found_pkg}" unless found_pkg.nil?
90
+ debug "NOMATCH: #{ref_include_id}" if found_pkg.nil?
91
+ found_pkg.nil? ? nil : MatchedRef.new(found_pkg, ref)
92
+ }.keep_if { |match| not match.nil? }
93
+ end
94
+
95
+ def fix_refs p, asmname_to_package = {}
96
+ packages = Hash[p.find_packages.collect { |v| [v.id, v] }]
97
+ trace "packages: #{packages}"
98
+ matches = matched_refs p.faulty_refs, packages, asmname_to_package
99
+ trace "matches: #{matches}"
100
+ matches.each{ |match|
101
+ dll_path = Pathname.new match.package.path
102
+ proj_path = Pathname.new p.proj_path_base
103
+ hint_path = Nokogiri::XML::Node.new "HintPath", p.proj_xml_node
104
+ hint_path.content = dll_path.relative_path_from proj_path
105
+ match.ref << hint_path
106
+ debug "For #{p.asmname} => hint_path: #{hint_path}"
107
+ }
108
+ trace p.proj_xml_node
109
+ end
110
+ end
111
+ end
112
+ end
@@ -1,3 +1,3 @@
1
- module Albacore
2
- VERSION = "1.0.0"
3
- end
1
+ module Albacore
2
+ VERSION = "2.0.0.rc.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'albacore'
2
+ task :default do
3
+ sh "ruby --version"
4
+ sh "oh noes"
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe "pub sub" do
4
+ it {
5
+ @got_it = false
6
+ Albacore.subscribe :pubsub do |obj|
7
+ @got_it = obj
8
+ end
9
+ Albacore.publish :pubsub, true
10
+ @got_it.should be_true
11
+ }
12
+ end
@@ -0,0 +1,151 @@
1
+ require 'albacore/task_types/asmver/engine'
2
+ require 'albacore/task_types/asmver/file_generator'
3
+
4
+ include Albacore::Asmver
5
+
6
+ %w|Fs Vb Cpp Cs|.each do |lang|
7
+ require "albacore/task_types/asmver/#{lang.downcase}"
8
+ describe "the #{lang} engine" do
9
+ subject do
10
+ "Albacore::Asmver::#{lang}".split('::').inject(Object) { |o, c| o.const_get c }.new
11
+ end
12
+ %w|build_attribute build_named_parameters build_positional_parameters build_using_statement build_comment namespace_end namespace_start|.each do |m|
13
+ it "should have a public API ##{m.to_s}" do
14
+ should respond_to(:"#{m}")
15
+ end
16
+ end
17
+ describe 'when building version attribute' do
18
+ let :version do
19
+ subject.build_attribute 'AssemblyVersion', '0.2.3'
20
+ end
21
+ it 'should contain the name AssemblyVersion' do
22
+ version.should include('AssemblyVersion')
23
+ end
24
+ it 'should contain the version 0.2.3' do
25
+ version.should include('0.2.3')
26
+ end
27
+ it 'should include the "assembly:" string' do
28
+ version.should include('assembly: ')
29
+ end
30
+ end
31
+ describe 'when building using statement' do
32
+ let :using do
33
+ subject.build_using_statement 'System.Runtime.CompilerServices'
34
+ end
35
+ it 'should contain the namespace System.Runtime.CompilerServices' do
36
+ using.should =~ /System.{1,2}Runtime.{1,2}CompilerServices/
37
+ end
38
+ end
39
+ describe 'when building named parameters' do
40
+ let :plist do
41
+ subject.build_named_parameters milk_cows: true, birds_fly: false, hungry_server: 'sad server'
42
+ end
43
+ it 'should include the parameter names' do
44
+ plist.should =~ /milk_cows .{1,2} true. birds_fly .{1,2} false. hungry_server .{1,2} "sad server"/
45
+ end
46
+ end
47
+ describe 'when building positional parameters' do
48
+ let :plist do
49
+ subject.build_positional_parameters ((%w|a b c hello|) << false)
50
+ end
51
+ it 'should include the positional parameters' do
52
+ plist.should eq('"a", "b", "c", "hello", false')
53
+ end
54
+ end
55
+ describe 'when building single line comment' do
56
+ let :comment do
57
+ subject.build_comment 'this is my comment'
58
+ end
59
+ it 'should include the string verbatim' do
60
+ comment =~ /this is my comment/
61
+ end
62
+ let :expected do
63
+ { 'Fs' => %r{// this is my comment},
64
+ 'Vb' => %r{' this is my comment},
65
+ 'Cs' => %r{// this is my comment},
66
+ 'Cpp' => %r{// this is my comment}
67
+ }[lang]
68
+ end
69
+ it 'should include the correct syntax for single line comment' do
70
+ comment.should =~ expected
71
+ end
72
+ end
73
+ describe 'when building a multi-line comment' do
74
+ let :comment do
75
+ subject.build_comment %{This is a very interesting comment
76
+ on many lines}
77
+ end
78
+ let :expected do
79
+ { 'Cs' => %{/*
80
+ This is a very interesting comment
81
+ on many lines
82
+ */},
83
+ 'Fs' => %{(*
84
+ This is a very interesting comment
85
+ on many lines
86
+ *)},
87
+ 'Vb' =>
88
+ %{' This is a very interesting comment
89
+ ' on many lines},
90
+ 'Cpp' => %{/*
91
+ This is a very interesting comment
92
+ on many lines
93
+ */}
94
+ }[lang]
95
+ end
96
+ it 'should build the multiline comment' do
97
+ comment.should eq(expected)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ describe FileGenerator do
103
+ subject do
104
+ FileGenerator.new(Fs.new, 'MyNamespace.Here', {})
105
+ end
106
+ it do
107
+ subject.should respond_to(:generate)
108
+ end
109
+ end
110
+ describe FileGenerator, 'when generating F# file' do
111
+ subject do
112
+ FileGenerator.new(Fs.new, 'My.Fs.Ns', {})
113
+ end
114
+ let :generated do
115
+ subject.generate com_visible: false,
116
+ assembly_title: 'My.Ns',
117
+ assembly_version: '0.1.2',
118
+ custom_thing: %w|a b c|,
119
+ named_thing: { :b => 3, :c => 'hi' }
120
+ end
121
+ it 'should include namespace' do
122
+ generated.should =~ /namespace My\.Fs\.Ns(\r\n?|\n)/
123
+ end
124
+ it 'should open System.Reflection' do
125
+ generated.should =~ /open System\.Reflection/
126
+ end
127
+ it 'should open System.Runtime.CompilerServices' do
128
+ generated.should =~ /open System\.Runtime\.CompilerServices/
129
+ end
130
+ it 'should open System.Runtime.InteropServices' do
131
+ generated.should =~ /open System\.Runtime\.InteropServices/
132
+ end
133
+ it 'should generate the ComVisible attribute' do
134
+ generated.should include('[<assembly: ComVisible(false)>]')
135
+ end
136
+ it 'should generate the AssemblyTitle attribute' do
137
+ generated.should include('[<assembly: AssemblyTitle("My.Ns")>]')
138
+ end
139
+ it 'should generate the AssemblyVersion attribute' do
140
+ generated.should include('[<assembly: AssemblyVersion("0.1.2")>]')
141
+ end
142
+ it 'should generate the CustomThing attribute' do
143
+ generated.should include('[<assembly: CustomThing("a", "b", "c")>]')
144
+ end
145
+ it 'should generate the NamedThing attribute' do
146
+ generated.should include('[<assembly: NamedThing(b = 3, c = "hi")>]')
147
+ end
148
+ it 'should end with ()\n' do
149
+ generated.should =~ /\(\)(\r\n?|\n)$/m
150
+ end
151
+ end
@@ -0,0 +1,32 @@
1
+ require 'albacore/task_types/asmver'
2
+
3
+ describe ::Albacore::Asmver::Config, 'when setting attributes and out' do
4
+ let :strio do
5
+ StringIO.new
6
+ end
7
+ subject do
8
+ ::Albacore::Asmver::Config.new
9
+ end
10
+ def task
11
+ @task
12
+ end
13
+ before :each do
14
+ subject.file_path = 'Version.fs'
15
+ subject.namespace = 'Hello.World'
16
+ subject.attributes guid: 'b766f4f3-3f4e-49d0-a451-9c152059ae81',
17
+ assembly_version: '0.1.2'
18
+ subject.out = strio
19
+ @task = ::Albacore::Asmver::Task.new(subject.opts)
20
+ @task.execute
21
+ end
22
+ it 'should write namespace' do
23
+ strio.string.should include('namespace Hello.World')
24
+ end
25
+ it 'should write Guid("...")' do
26
+ strio.string.should include('[<assembly: Guid("b766f4f3-3f4e-49d0-a451-9c152059ae81")>]')
27
+ end
28
+ it 'should write AssemblyVersion' do
29
+ strio.string.should include('[<assembly: AssemblyVersion("0.1.2")>]')
30
+ end
31
+ end
32
+
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'support/sh_interceptor'
3
+ require 'albacore'
4
+ require 'albacore/task_types/build'
5
+
6
+ describe 'build config' do
7
+ subject do
8
+ Albacore::Build::Config.new
9
+ end
10
+ %w[file= sln= target target= logging logging= prop cores cores=].each do |writer|
11
+ it "should have property :#{writer}" do
12
+ subject.respond_to?(:"#{writer}").should be_true
13
+ end
14
+ end
15
+ it 'should not have any property' do
16
+ subject.respond_to?(:something_nonexistent).should be_false
17
+ end
18
+
19
+ describe 'when setting properties' do
20
+ before do
21
+ subject.logging = 'minimal'
22
+ end
23
+ it do
24
+ subject.parameters.should include('/verbosity:minimal')
25
+ end
26
+ end
27
+ end
28
+
29
+ describe 'when running with sln' do
30
+ let :cfg do
31
+ Albacore::Build::Config.new
32
+ end
33
+
34
+ include_context 'path testing'
35
+
36
+ let(:cmd) do
37
+ cmd = Albacore::Build::Cmd.new cfg.work_dir, 'xbuild', cfg.parameters
38
+ cmd.extend ShInterceptor
39
+ end
40
+
41
+ before do
42
+ cfg.sln = 'src/HelloWorld.sln'
43
+ cmd.execute
44
+ end
45
+
46
+ subject do
47
+ cmd
48
+ end
49
+
50
+ it do
51
+ subject.executable.should eq('xbuild')
52
+ end
53
+ it do
54
+ subject.parameters.should eq(%W|/verbosity:minimal #{path 'src/HelloWorld.sln'}|)
55
+ end
56
+ it do
57
+ subject.is_mono_command?.should be_false
58
+ end
59
+ end
60
+
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+ require 'rake'
3
+ require 'albacore/config_dsl'
4
+
5
+ class Example
6
+ # self.include won't work: 'private method ...'
7
+ self.extend ::Albacore::ConfigDSL
8
+
9
+ attr_path :out, :in
10
+
11
+ attr_path_accessor :a, :b
12
+
13
+ attr_path :x do |path|
14
+ @was_called = path
15
+ end
16
+
17
+ attr_path_accessor :y do |val|
18
+ @y_called = val
19
+ end
20
+
21
+ def out
22
+ @out
23
+ end
24
+ def in
25
+ @in
26
+ end
27
+
28
+ def x
29
+ @x
30
+ end
31
+
32
+ # whether the block was called
33
+ def was_called
34
+ @was_called
35
+ end
36
+
37
+ def y_called
38
+ @y_called
39
+ end
40
+ end
41
+
42
+ describe Example, 'when setting properties' do
43
+ before do
44
+ subject.out = 'a/b/c'
45
+ subject.in = 'a\\b\\c'
46
+ subject.a = 'a/b/c'
47
+ subject.b = 'a\\b\\c'
48
+ end
49
+ let :expected do
50
+ ::Rake::Win32.windows? ? 'a\\b\\c' : 'a/b/c'
51
+ end
52
+ it 'should have remapped :in' do
53
+ subject.in.should eq(expected)
54
+ end
55
+ it 'should have remapped :out' do
56
+ subject.out.should eq(expected)
57
+ end
58
+ it 'should be able to read and write :a' do
59
+ subject.a.should eq(expected)
60
+ end
61
+ it 'should be able to read and write :b' do
62
+ subject.b.should eq(expected)
63
+ end
64
+ end
65
+
66
+ describe Example, 'when using blocks for properties' do
67
+ before do
68
+ subject.x = 'a/b/c'
69
+ subject.y = 'a\\b\\c'
70
+ end
71
+ let :expected do
72
+ ::Rake::Win32.windows? ? 'a\\b\\c' : 'a/b/c'
73
+ end
74
+ it 'should have written x' do
75
+ subject.x.should eq(expected)
76
+ end
77
+ it 'should have called x block' do
78
+ subject.was_called.should eq(expected)
79
+ end
80
+ it 'should have called y block' do
81
+ subject.y_called.should eq(expected)
82
+ end
83
+ end