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,231 @@
1
+ require 'spec_helper'
2
+ require 'support/sh_interceptor'
3
+ require 'albacore'
4
+ require 'albacore/task_types/nugets_pack'
5
+
6
+ class ConfigFac
7
+ def self.create id, curr, gen_symbols = true
8
+ cfg = Albacore::NugetsPack::Config.new
9
+ cfg.target = 'net40'
10
+ cfg.configuration = 'Debug'
11
+ cfg.files = Dir.glob(File.join(curr, 'testdata', 'Project', '*.fsproj'))
12
+ cfg.out = 'spec/testdata/pkg'
13
+ cfg.exe = 'NuGet.exe'
14
+ cfg.with_metadata do |m|
15
+ m.id = id
16
+ m.authors = 'haf'
17
+ m.owners = 'haf owner'
18
+ m.description = 'a nice lib'
19
+ m.language = 'Danish'
20
+ m.project_url = 'https://github.com/haf/Reasonable'
21
+ m.license_url = 'https://github.com/haf/README.md'
22
+ m.version = '0.2.3'
23
+ m.release_notes = %{
24
+ v10.0.0:
25
+ - Some notes
26
+ }
27
+ m.require_license_acceptance = false
28
+
29
+ m.add_dependency 'Abc.Package', '>= 1.0.2'
30
+ m.add_framework_dependency 'System.Transactions', '4.0.0'
31
+ end
32
+ cfg.gen_symbols if gen_symbols # files: *.{pdb,dll,all compiled files}
33
+ cfg
34
+ end
35
+ end
36
+
37
+ shared_context 'pack_config' do
38
+ let :id do
39
+ 'Sample.Nuget'
40
+ end
41
+ let :curr do
42
+ File.dirname(__FILE__)
43
+ end
44
+ let :config do
45
+ cfg = ConfigFac.create id, curr, true
46
+ end
47
+ end
48
+
49
+ shared_context 'pack_config no symbols' do
50
+ let :id do
51
+ 'Sample.Nuget'
52
+ end
53
+ let :curr do
54
+ File.dirname(__FILE__)
55
+ end
56
+ let :config do
57
+ cfg = ConfigFac.create id, curr, false
58
+ end
59
+ end
60
+
61
+ # testing the command for nuget
62
+
63
+ describe Albacore::NugetsPack::Cmd, "when calling #execute" do
64
+
65
+ include_context 'path testing'
66
+
67
+ let :cmd do
68
+ Albacore::NugetsPack::Cmd.new 'NuGet.exe', config.opts()
69
+ end
70
+
71
+ subject do
72
+ cmd.extend ShInterceptor
73
+ cmd.execute './spec/testdata/example.nuspec', './spec/testdata/example.symbols.nuspec'
74
+ #puts "## INVOCATIONS:"
75
+ #cmd.invocations.each do |i|
76
+ # puts "#{i}"
77
+ #end
78
+ cmd
79
+ end
80
+
81
+ describe "first invocation" do
82
+ include_context 'pack_config'
83
+ it "should run the correct executable" do
84
+ subject.mono_command(0).should eq('NuGet.exe')
85
+ end
86
+ it "should include the correct parameters" do
87
+ subject.mono_parameters(0).should eq(%W[Pack -OutputDirectory #{path 'spec/testdata/pkg'} ./spec/testdata/example.nuspec])
88
+ end
89
+ end
90
+
91
+ describe "second invocation" do
92
+ include_context 'pack_config'
93
+ it "should include -Symbols" do
94
+ subject.mono_parameters(1).should eq(%W[Pack -OutputDirectory #{path 'spec/testdata/pkg'} -Symbols ./spec/testdata/example.symbols.nuspec])
95
+ end
96
+ end
97
+
98
+ describe "without symbols" do
99
+ include_context 'pack_config no symbols'
100
+ subject do
101
+ cmd.extend ShInterceptor
102
+ cmd.execute './spec/testdata/example.nuspec'
103
+ cmd
104
+ end
105
+ it 'should not include -Symbols' do
106
+ subject.mono_parameters(0).should eq(%W[Pack -OutputDirectory #{path 'spec/testdata/pkg'} ./spec/testdata/example.nuspec])
107
+ end
108
+ it 'should not have a second invocation' do
109
+ subject.invocations.length.should eq(1)
110
+ end
111
+ end
112
+ end
113
+
114
+ describe Albacore::NugetsPack::Cmd, 'when calling :get_nuget_path_of' do
115
+ include_context 'pack_config'
116
+
117
+ subject do
118
+ Albacore::NugetsPack::Cmd.new 'NuGet.exe', config.opts()
119
+ end
120
+
121
+ let :sample1 do
122
+ <<EXAMPLE_OUTPUT
123
+ Attempting to build package from 'MyNuget.Package.nuspec'.
124
+ Successfully created package 'Y:\\Shared\\build\\pkg\\MyNuget.Package.1.0.0.nupkg'.
125
+ Successfully created package 'Y:\\Shared\\build\\pkg\\MyNuget.Package.1.0.0.symbols.nupkg'.
126
+ EXAMPLE_OUTPUT
127
+ end
128
+
129
+ let :sample2 do
130
+ <<EXAMPLE_OUTPUT
131
+ Attempting to build package from 'MyNuget.Package.nuspec'.
132
+ Successfully created package '/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0.nupkg'.
133
+ Successfully created package '/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0.symbols.nupkg'.
134
+ EXAMPLE_OUTPUT
135
+ end
136
+
137
+ it "should match sample1 with last nupkg mentioned" do
138
+ match = subject.send(:get_nuget_path_of) { sample1 }
139
+ match.should eq('Y:\\Shared\\build\\pkg\\MyNuget.Package.1.0.0.symbols.nupkg')
140
+ end
141
+
142
+ it 'should match sample2 with last nupkg mentioned' do
143
+ match = subject.send(:get_nuget_path_of) { sample2 }
144
+ match.should eq('/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0.symbols.nupkg')
145
+ end
146
+ end
147
+
148
+
149
+ describe Albacore::NugetsPack::NuspecTask, "when testing public interface" do
150
+ include_context 'pack_config'
151
+ include_context 'path testing'
152
+
153
+ it "accepts .nuspec files" do
154
+ Albacore::NugetsPack::NuspecTask.accept?('some.nuspec').should be_true
155
+ end
156
+
157
+ let (:cmd) do
158
+ Albacore::NugetsPack::Cmd.new 'NuGet.exe', config.opts()
159
+ end
160
+
161
+ subject do
162
+ cmd
163
+ end
164
+
165
+ before do
166
+ cmd.extend(ShInterceptor)
167
+ task = Albacore::NugetsPack::NuspecTask.new cmd, config, './spec/testdata/example.nuspec'
168
+ task.execute
169
+ end
170
+
171
+ it "should run the correct executable" do
172
+ subject.mono_command.should eq('NuGet.exe')
173
+ end
174
+ it "should give the correct parameters" do
175
+ subject.mono_parameters.should eq(%W[Pack -OutputDirectory #{path 'spec/testdata/pkg'} ./spec/testdata/example.nuspec])
176
+ end
177
+ end
178
+
179
+ describe Albacore::NugetsPack::ProjectTask, "when testing public interface" do
180
+ let :projfile do
181
+ curr = File.dirname(__FILE__)
182
+ File.join curr, "testdata", "Project.fsproj"
183
+ end
184
+ it "can be created" do
185
+ Albacore::NugetsPack::ProjectTask.new(Map.new(:files => [projfile]))
186
+ end
187
+ it "rejects .nuspec files" do
188
+ Albacore::NugetsPack::ProjectTask.accept?('some.nuspec').should eq false
189
+ end
190
+ end
191
+
192
+ describe Albacore::NugetsPack::ProjectTask, "creating nuget from proj file" do
193
+ let(:cmdo) { Hash.new }
194
+
195
+ subject do
196
+ Albacore::NugetsPack::ProjectTask.new(config.opts()) do |cmd|
197
+ cmd.extend ShInterceptor
198
+ cmdo[:cmd] = cmd
199
+ end
200
+ end
201
+
202
+ before :each do
203
+ subject.execute
204
+ end
205
+
206
+ describe 'when generating symbols' do
207
+ include_context 'pack_config'
208
+ it 'should have generated a nuspec' do
209
+ cmdo[:cmd].mono_parameters(0)[-1].should include('Sample.Nuget.nuspec')
210
+ end
211
+ it 'should have generated a symbol nuspec' do
212
+ cmdo[:cmd].mono_parameters(1)[-1].should include('Sample.Nuget.symbols.nuspec')
213
+ end
214
+ end
215
+
216
+ describe 'when not generating symbols' do
217
+ include_context 'pack_config no symbols'
218
+ it 'should have generated a nuspec' do
219
+ cmdo[:cmd].mono_parameters(0)[-1].should include('Sample.Nuget.nuspec')
220
+ end
221
+ it 'should have done no further calls' do
222
+ cmdo[:cmd].invocations.length.should eq(1)
223
+ end
224
+ it 'should have no further invocations' do
225
+ begin
226
+ cmdo[:cmd].mono_parameters(1)
227
+ rescue RuntimeError
228
+ end
229
+ end
230
+ end
231
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'albacore'
3
+ require 'albacore/task_types/nugets_restore'
4
+ require 'albacore/dsl'
5
+ require 'support/sh_interceptor'
6
+
7
+ class NGConf
8
+ self.extend Albacore::DSL
9
+ end
10
+
11
+ shared_context 'cmd context' do
12
+ let (:hafsrc) { OpenStruct.new(:name => 'haf-source', :uri => 'https://haf.se/nugets') }
13
+ before(:each) { cmd.extend ShInterceptor }
14
+ subject { cmd.execute ; cmd.mono_parameters }
15
+ end
16
+
17
+
18
+ describe Albacore::NugetsRestore::RemoveSourceCmd, 'when calling #execute should remove source' do
19
+ let(:cmd) { Albacore::NugetsRestore::RemoveSourceCmd.new 'nuget.exe', hafsrc }
20
+ include_context 'cmd context'
21
+ %w[remove sources -name haf-source].each { |k|
22
+ it { should include(k) }
23
+ }
24
+ end
25
+
26
+ describe Albacore::NugetsRestore::AddSourceCmd, 'when calling #execute should remove source' do
27
+ let (:cmd) { Albacore::NugetsRestore::AddSourceCmd.new 'nuget.exe', hafsrc, 'u', 'p' }
28
+ include_context 'cmd context'
29
+ %w[sources add -name haf-source].each { |k|
30
+ it { should include(k) }
31
+ }
32
+ end
33
+
34
+ describe Albacore::NugetsRestore::Cmd, 'when calling #execute with specific source' do
35
+
36
+ let (:cmd) {
37
+ cfg = Albacore::NugetsRestore::Config.new
38
+ cfg.out = 'src/packages'
39
+ cfg.add_parameter '-Source'
40
+ cfg.add_parameter 'http://localhost:8081'
41
+
42
+ cmd = Albacore::NugetsRestore::Cmd.new nil, 'NuGet.exe', cfg.opts_for_pkgcfg('src/Proj/packages.config')
43
+ }
44
+
45
+ let (:path) {
46
+ Albacore::Paths.normalise_slashes('src/Proj/packages.config')
47
+ }
48
+
49
+ include_context 'cmd context'
50
+
51
+ %W[install -OutputDirectory src/packages -Source http://localhost:8081].each { |parameter|
52
+ it { should include(parameter) }
53
+ }
54
+ it { should include(path) }
55
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'albacore/semver'
3
+ require 'albacore/project'
4
+
5
+ describe Albacore::Project, "when loading packages.config" do
6
+ subject {
7
+ p = File.expand_path('../testdata/Project/Project.fsproj', __FILE__)
8
+ #puts "path: #{p}"
9
+ Albacore::Project.new(p)
10
+ }
11
+ let(:nlog) { subject.declared_packages.find { |p| p.id == 'NLog' } }
12
+ it("should have three packages") { subject.declared_packages.length.should == 3 }
13
+ it("should contain NLog") { nlog.should_not be_nil }
14
+ it("should have a four number on NLog") { nlog.version.should eq("2.0.0.2000") }
15
+ it("should have a semver number") { nlog.semver.should eq(Albacore::SemVer.new(2, 0, 0)) }
16
+ end
17
+
18
+ describe Albacore::Project, "when reading project file" do
19
+ subject {
20
+ p = File.expand_path('../testdata/Project/Project.fsproj', __FILE__)
21
+ Albacore::Project.new(p)
22
+ }
23
+ let(:library1) { subject.included_files.find { |p| p.include == 'Library1.fs' } }
24
+ it("should contain library1") { library1.should_not be_nil }
25
+
26
+ end
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <Configuration Condition=" '$(Configuration)' == '' ">
5
+ Debug
6
+ </Configuration>
7
+ <Platform Condition=" '$(Platform)' == '' ">
8
+ AnyCPU
9
+ </Platform>
10
+ </PropertyGroup>
11
+ <ItemGroup>
12
+ <Compile Include="SomeOtherFolder\SomeFile.cs">
13
+ <Link>SomeNewFolder\SomeFile.cs</Link>
14
+ </Compile>
15
+ <Compile Include="File.cs" />
16
+ <Compile Include="SubFolder\AnotherFile.cs" />
17
+ </ItemGroup>
18
+ <ItemGroup>
19
+ <Content Include="Image.txt" />
20
+ </ItemGroup>
21
+ <ItemGroup>
22
+ <EmbeddedResource Include="MyHeavy.heavy">
23
+ <SubType>Designer</SubType>
24
+ </EmbeddedResource>
25
+ <None Include="Schema.xsd">
26
+ <SubType>Designer</SubType>
27
+ </None>
28
+ </ItemGroup>
29
+ </Project>
@@ -0,0 +1 @@
1
+ code!
@@ -0,0 +1 @@
1
+ An image
@@ -0,0 +1 @@
1
+ My very heavy file
@@ -0,0 +1 @@
1
+ An xsd, nothing to be done
@@ -0,0 +1 @@
1
+ Another file with code
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <Configuration Condition=" '$(Configuration)' == '' ">
5
+ Debug
6
+ </Configuration>
7
+ <Platform Condition=" '$(Platform)' == '' ">
8
+ AnyCPU
9
+ </Platform>
10
+ </PropertyGroup>
11
+ <ItemGroup>
12
+ <Compile Include="SomeOtherFolder\SomeFile.cs">
13
+ <Link>SomeNewFolder\SomeFile.cs</Link>
14
+ </Compile>
15
+ <Compile Include="File.cs" />
16
+ <Compile Include="SubFolder\AnotherFile.cs" />
17
+ </ItemGroup>
18
+ <ItemGroup>
19
+ <Content Include="Image.txt" />
20
+ </ItemGroup>
21
+ <ItemGroup>
22
+ <EmbeddedResource Include="MyHeavy.heavy">
23
+ <SubType>Designer</SubType>
24
+ </EmbeddedResource>
25
+ <None Include="Schema.xsd">
26
+ <SubType>Designer</SubType>
27
+ </None>
28
+ </ItemGroup>
29
+ </Project>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <Configuration Condition=" '$(Configuration)' == '' ">
5
+ Debug
6
+ </Configuration>
7
+ <Platform Condition=" '$(Platform)' == '' ">
8
+ AnyCPU
9
+ </Platform>
10
+ </PropertyGroup>
11
+ </Project>
@@ -0,0 +1,77 @@
1
+ require 'albacore'
2
+ require 'albacore/tasks/projectlint'
3
+
4
+ class ProjectLintReturn
5
+ attr_reader :failed, :failure_message
6
+ def initialize(failed, message=nil)
7
+ @failed = failed
8
+ @failure_message = message
9
+ end
10
+ end
11
+
12
+ def project_lint_on(name, path, ignores=nil)
13
+ root_folder = File.expand_path(File.join(File.dirname(__FILE__),'projectlint'))
14
+ f = Albacore::Tasks::ProjectLint.new name do |c|
15
+ c.project = File.join(root_folder, path)
16
+ if ignores
17
+ c.ignores = ignores
18
+ end
19
+ end
20
+ begin
21
+ f.execute
22
+ rescue Exception => e
23
+ return ProjectLintReturn.new(true, e.message)
24
+ end
25
+ return ProjectLintReturn.new(false)
26
+ end
27
+
28
+ describe "when supplying a csproj file with files added but not present on the filesystem" do
29
+ before(:all) { @f = project_lint_on(:first, File.join( 'added_but_not_on_filesystem', 'aproject.csproj')) }
30
+
31
+ it("should fail") { @f.failed.should be_true }
32
+
33
+ it("should report failure") { @f.failure_message.should include("-") }
34
+
35
+ it("should report file.cs") { @f.failure_message.should include('File.cs') }
36
+
37
+ it("should report Image.txt") { @f.failure_message.should include('Image.txt') }
38
+
39
+ it("should report MyHeavy.heavy") { @f.failure_message.should include('MyHeavy.heavy') }
40
+
41
+ it("should report Schema.xsd") { @f.failure_message.should include('Schema.xsd') }
42
+
43
+ it("should report SubFolder/AnotherFile.cs") { @f.failure_message.should include('AnotherFile.cs') }
44
+
45
+ it("should not report linked files") { @f.failure_message.should_not include('SomeFile.cs') }
46
+ end
47
+
48
+ describe "when supplying a correct csproj file with files added and present on the filesystem" do
49
+
50
+ before(:all) { @f = project_lint_on(:second, File.join( 'correct', 'aproject.csproj')) }
51
+
52
+ it("should not fail") {
53
+ @f.failed.should be_false
54
+ }
55
+ it("no message") { @f.failure_message.should be_nil }
56
+ end
57
+
58
+ describe "when supplying a csproj file with files not added but present on the filesystem" do
59
+ before(:all) { @f = project_lint_on(:third, File.join( 'on_filesystem_but_not_added', 'aproject.csproj')) }
60
+
61
+ it("should fail") { @f.failed.should be_true }
62
+
63
+ it("should report failure") { @f.failure_message.should include("+") }
64
+
65
+ it("should report file.cs") { @f.failure_message.should include('File.cs') }
66
+
67
+ it("should report Image.txt") { @f.failure_message.should include('Image.txt') }
68
+ end
69
+
70
+
71
+ describe "when supplying a csproj files with files on filesystem ignored" do
72
+ before(:all) {
73
+ @f = project_lint_on(:fourth, File.join('on_filesystem_but_not_added', 'aproject.csproj'), [/.*\.txt$/, /.*\.cs$/])
74
+ }
75
+
76
+ it("should not fail") { @f.failed.should be_false }
77
+ end