omnibus 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -1
  3. data/.travis.yml +11 -3
  4. data/CHANGELOG.md +39 -1
  5. data/Gemfile +0 -4
  6. data/README.md +10 -8
  7. data/Rakefile +18 -7
  8. data/bin/omnibus +3 -3
  9. data/docs/Building on Windows.md +98 -0
  10. data/features/commands/_deprecated.feature +46 -0
  11. data/features/commands/build.feature +9 -0
  12. data/features/commands/clean.feature +21 -0
  13. data/features/commands/list.feature +16 -0
  14. data/features/commands/new.feature +8 -0
  15. data/features/commands/version.feature +12 -0
  16. data/features/step_definitions/generator_steps.rb +28 -0
  17. data/features/support/env.rb +13 -0
  18. data/lib/omnibus.rb +319 -240
  19. data/lib/omnibus/artifact.rb +16 -0
  20. data/lib/omnibus/build_version.rb +39 -20
  21. data/lib/omnibus/build_version_dsl.rb +136 -0
  22. data/lib/omnibus/builder.rb +28 -23
  23. data/lib/omnibus/cleaner.rb +72 -0
  24. data/lib/omnibus/cli.rb +115 -11
  25. data/lib/omnibus/cli/base.rb +82 -81
  26. data/lib/omnibus/cli/cache.rb +80 -32
  27. data/lib/omnibus/cli/deprecated.rb +79 -0
  28. data/lib/omnibus/cli/release.rb +17 -21
  29. data/lib/omnibus/config.rb +38 -13
  30. data/lib/omnibus/exceptions.rb +70 -18
  31. data/lib/omnibus/fetcher.rb +18 -11
  32. data/lib/omnibus/fetchers/git_fetcher.rb +48 -53
  33. data/lib/omnibus/fetchers/net_fetcher.rb +29 -27
  34. data/lib/omnibus/fetchers/path_fetcher.rb +9 -12
  35. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +5 -8
  36. data/lib/omnibus/generator.rb +131 -0
  37. data/lib/omnibus/{templates → generator_files}/.kitchen.local.yml.erb +0 -0
  38. data/lib/omnibus/{templates → generator_files}/.kitchen.yml.erb +0 -0
  39. data/lib/omnibus/{templates → generator_files}/Berksfile.erb +0 -0
  40. data/lib/omnibus/{templates → generator_files}/Gemfile.erb +2 -2
  41. data/lib/omnibus/{templates → generator_files}/README.md.erb +6 -7
  42. data/lib/omnibus/{templates → generator_files}/Vagrantfile.erb +0 -0
  43. data/lib/omnibus/{templates → generator_files}/gitignore.erb +0 -0
  44. data/lib/omnibus/{templates → generator_files}/mac_dmg/background.png +0 -0
  45. data/lib/omnibus/{templates → generator_files}/mac_dmg/icon.png +0 -0
  46. data/lib/omnibus/{templates → generator_files}/mac_pkg/background.png +0 -0
  47. data/lib/omnibus/{templates → generator_files}/mac_pkg/license.html.erb +0 -0
  48. data/lib/omnibus/{templates → generator_files}/mac_pkg/welcome.html.erb +0 -0
  49. data/lib/omnibus/{templates → generator_files}/omnibus.rb.example.erb +0 -0
  50. data/lib/omnibus/{templates → generator_files}/package_scripts/makeselfinst.erb +0 -0
  51. data/lib/omnibus/{templates → generator_files}/package_scripts/postinst.erb +0 -0
  52. data/lib/omnibus/{templates → generator_files}/package_scripts/postrm.erb +0 -0
  53. data/lib/omnibus/{templates → generator_files}/package_scripts/preinst.erb +0 -0
  54. data/lib/omnibus/{templates → generator_files}/package_scripts/prerm.erb +0 -0
  55. data/lib/omnibus/{templates → generator_files}/project.rb.erb +0 -1
  56. data/lib/omnibus/{templates → generator_files}/software/c-example.rb.erb +0 -0
  57. data/lib/omnibus/{templates → generator_files}/software/erlang-example.rb.erb +0 -0
  58. data/lib/omnibus/{templates → generator_files}/software/ruby-example.rb.erb +0 -0
  59. data/lib/omnibus/generator_files/windows_msi/assets/LICENSE.rtf +8 -0
  60. data/lib/omnibus/generator_files/windows_msi/assets/banner_background.bmp +0 -0
  61. data/lib/omnibus/generator_files/windows_msi/assets/dialog_background.bmp +0 -0
  62. data/lib/omnibus/generator_files/windows_msi/assets/project.ico +0 -0
  63. data/lib/omnibus/generator_files/windows_msi/assets/project_16x16.ico +0 -0
  64. data/lib/omnibus/generator_files/windows_msi/assets/project_32x32.ico +0 -0
  65. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +20 -0
  66. data/lib/omnibus/generator_files/windows_msi/parameters.wxi.erb +9 -0
  67. data/lib/omnibus/generator_files/windows_msi/source.wxs.erb +74 -0
  68. data/lib/omnibus/health_check.rb +80 -40
  69. data/lib/omnibus/install_path_cache.rb +11 -12
  70. data/lib/omnibus/library.rb +30 -3
  71. data/lib/omnibus/logger.rb +47 -0
  72. data/lib/omnibus/logging.rb +60 -0
  73. data/lib/omnibus/null_builder.rb +23 -0
  74. data/lib/omnibus/ohai.rb +70 -0
  75. data/lib/omnibus/overrides.rb +69 -48
  76. data/lib/omnibus/package_release.rb +7 -14
  77. data/lib/omnibus/packagers/base.rb +66 -13
  78. data/lib/omnibus/packagers/mac_dmg.rb +23 -3
  79. data/lib/omnibus/packagers/mac_pkg.rb +20 -10
  80. data/lib/omnibus/packagers/windows_msi.rb +109 -0
  81. data/lib/omnibus/project.rb +136 -79
  82. data/lib/omnibus/reports.rb +1 -2
  83. data/lib/omnibus/{s3_cacher.rb → s3_cache.rb} +15 -37
  84. data/lib/omnibus/software.rb +77 -27
  85. data/lib/omnibus/software_s3_urls.rb +50 -0
  86. data/lib/omnibus/sugar.rb +1 -3
  87. data/lib/omnibus/util.rb +45 -18
  88. data/lib/omnibus/version.rb +2 -3
  89. data/omnibus.gemspec +5 -3
  90. data/spec/data/complicated/config/patches/bzip2/makefile_take_env_vars.patch +15 -0
  91. data/spec/data/complicated/config/patches/couchdb/patch_for_couchjs_stack.patch +19 -0
  92. data/spec/data/complicated/config/patches/gd/gd-2.0.33-configure-libpng.patch +100 -0
  93. data/spec/data/complicated/config/patches/keepalived/keepalived-1.2.9_opscode_centos_5.patch +15 -0
  94. data/spec/data/complicated/config/patches/libedit/freebsd-vi-fix.patch +24 -0
  95. data/spec/data/complicated/config/patches/libiconv/libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch +29 -0
  96. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-makefile-dest-fix.patch +35 -0
  97. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-malloc-fix.patch +13 -0
  98. data/spec/data/complicated/config/patches/libwrap/tcp_wrappers-7.6-shared_lib_plus_plus-1.patch +1035 -0
  99. data/spec/data/complicated/config/patches/logrotate/logrotate_basedir_override.patch +12 -0
  100. data/spec/data/complicated/config/patches/ncurses/ncurses-5.9-solaris-xopen_source_extended-detection.patch +11 -0
  101. data/spec/data/complicated/config/patches/ncurses/ncurses-clang.patch +42 -0
  102. data/spec/data/complicated/config/patches/ncurses/patch-aa +23 -0
  103. data/spec/data/complicated/config/patches/ncurses/patch-ab +44 -0
  104. data/spec/data/complicated/config/patches/ncurses/patch-ac +40 -0
  105. data/spec/data/complicated/config/patches/ncurses/patch-ad +12 -0
  106. data/spec/data/complicated/config/patches/ncurses/patch-aix-configure +23 -0
  107. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesf.h +22 -0
  108. data/spec/data/complicated/config/patches/ncurses/patch-cxx_cursesm.h +22 -0
  109. data/spec/data/complicated/config/patches/nrpe/fix_for_runit.patch +64 -0
  110. data/spec/data/complicated/config/patches/openssl/openssl-1.0.1f-do-not-build-docs.patch +101 -0
  111. data/spec/data/complicated/config/patches/postgresql/postgresql-9.1.2-configure-ncurses-fix.patch +12 -0
  112. data/spec/data/complicated/config/patches/ruby/patch-configure +103 -0
  113. data/spec/data/complicated/config/patches/ruby/ruby-aix-configure.patch +10 -0
  114. data/spec/data/complicated/config/patches/ruby/ruby-openssl-1.0.1c.patch +42 -0
  115. data/spec/data/complicated/config/patches/ruby/ruby_aix_1_9_3_448_ssl_EAGAIN.patch +57 -0
  116. data/spec/data/complicated/config/patches/ruby/rvm-cflags.patch +27 -0
  117. data/spec/data/complicated/config/projects/angrychef.rb +32 -0
  118. data/spec/data/complicated/config/projects/chef-windows.rb +32 -0
  119. data/spec/data/complicated/config/projects/chef.rb +32 -0
  120. data/spec/data/complicated/config/projects/chefdk-windows.rb +41 -0
  121. data/spec/data/complicated/config/projects/chefdk.rb +44 -0
  122. data/spec/data/complicated/config/software/appbundler.rb +25 -0
  123. data/spec/data/complicated/config/software/autoconf.rb +35 -0
  124. data/spec/data/complicated/config/software/automake.rb +39 -0
  125. data/spec/data/complicated/config/software/berkshelf.rb +44 -0
  126. data/{lib/omnibus/fetchers.rb → spec/data/complicated/config/software/bundler.rb} +8 -5
  127. data/spec/data/complicated/config/software/bzip2.rb +46 -0
  128. data/spec/data/complicated/config/software/cacerts.rb +44 -0
  129. data/spec/data/complicated/config/software/chef-client-msi.rb +88 -0
  130. data/spec/data/complicated/config/software/chef-gem.rb +26 -0
  131. data/spec/data/complicated/config/software/chef-vault.rb +43 -0
  132. data/spec/data/complicated/config/software/chef-windows.rb +158 -0
  133. data/spec/data/complicated/config/software/chef.rb +170 -0
  134. data/spec/data/complicated/config/software/chefdk.rb +103 -0
  135. data/spec/data/complicated/config/software/couchdb.rb +53 -0
  136. data/spec/data/complicated/config/software/curl.rb +48 -0
  137. data/spec/data/complicated/config/software/erlang.rb +65 -0
  138. data/spec/data/complicated/config/software/expat.rb +21 -0
  139. data/spec/data/complicated/config/software/fcgi.rb +56 -0
  140. data/spec/data/complicated/config/software/fcgiwrap.rb +41 -0
  141. data/spec/data/complicated/config/software/gd.rb +56 -0
  142. data/spec/data/complicated/config/software/gdbm.rb +40 -0
  143. data/spec/data/complicated/config/software/gecode.rb +48 -0
  144. data/spec/data/complicated/config/software/git.rb +40 -0
  145. data/spec/data/complicated/config/software/help2man.rb +30 -0
  146. data/spec/data/complicated/config/software/icu.rb +40 -0
  147. data/spec/data/complicated/config/software/jre.rb +48 -0
  148. data/spec/data/complicated/config/software/keepalived.rb +43 -0
  149. data/spec/data/complicated/config/software/libarchive.rb +50 -0
  150. data/spec/data/complicated/config/software/libedit.rb +69 -0
  151. data/spec/data/complicated/config/software/libffi.rb +71 -0
  152. data/spec/data/complicated/config/software/libgcc.rb +39 -0
  153. data/spec/data/complicated/config/software/libiconv.rb +66 -0
  154. data/spec/data/complicated/config/software/libjpeg.rb +39 -0
  155. data/spec/data/complicated/config/software/libpng.rb +38 -0
  156. data/spec/data/complicated/config/software/libtool.rb +52 -0
  157. data/spec/data/complicated/config/software/libwrap.rb +50 -0
  158. data/spec/data/complicated/config/software/libxml2.rb +51 -0
  159. data/spec/data/complicated/config/software/libxslt.rb +52 -0
  160. data/spec/data/complicated/config/software/libyaml-windows.rb +43 -0
  161. data/spec/data/complicated/config/software/libyaml.rb +62 -0
  162. data/spec/data/complicated/config/software/logrotate.rb +41 -0
  163. data/spec/data/complicated/config/software/makedepend.rb +73 -0
  164. data/spec/data/complicated/config/software/mysql2.rb +42 -0
  165. data/spec/data/complicated/config/software/nagios-plugins.rb +53 -0
  166. data/spec/data/complicated/config/software/nagios.rb +66 -0
  167. data/spec/data/complicated/config/software/ncurses.rb +149 -0
  168. data/spec/data/complicated/config/software/nginx.rb +40 -0
  169. data/spec/data/complicated/config/software/nodejs.rb +44 -0
  170. data/spec/data/complicated/config/software/nokogiri.rb +55 -0
  171. data/spec/data/complicated/config/software/nrpe.rb +61 -0
  172. data/spec/data/complicated/config/software/ohai.rb +64 -0
  173. data/spec/data/complicated/config/software/omnibus-ctl.rb +34 -0
  174. data/spec/data/complicated/config/software/openresty.rb +67 -0
  175. data/spec/data/complicated/config/software/openssl.rb +158 -0
  176. data/spec/data/complicated/config/software/pcre.rb +42 -0
  177. data/spec/data/complicated/config/software/perl-extutils-embed.rb +15 -0
  178. data/spec/data/complicated/config/software/perl-extutils-makemaker.rb +15 -0
  179. data/spec/data/complicated/config/software/perl.rb +48 -0
  180. data/spec/data/complicated/config/software/perl_pg_driver.rb +12 -0
  181. data/spec/data/complicated/config/software/php.rb +41 -0
  182. data/spec/data/complicated/config/software/pip.rb +30 -0
  183. data/spec/data/complicated/config/software/pkg-config.rb +66 -0
  184. data/spec/data/complicated/config/software/popt.rb +47 -0
  185. data/spec/data/complicated/config/software/postgresql.rb +51 -0
  186. data/spec/data/complicated/config/software/preparation.rb +30 -0
  187. data/spec/data/complicated/config/software/pygments.rb +25 -0
  188. data/spec/data/complicated/config/software/python.rb +49 -0
  189. data/spec/data/complicated/config/software/rabbitmq.rb +36 -0
  190. data/spec/data/complicated/config/software/rebar.rb +36 -0
  191. data/spec/data/complicated/config/software/redis.rb +33 -0
  192. data/spec/data/complicated/config/software/rsync.rb +48 -0
  193. data/spec/data/complicated/config/software/ruby-windows-devkit.rb +30 -0
  194. data/spec/data/complicated/config/software/ruby-windows.rb +30 -0
  195. data/spec/data/complicated/config/software/ruby.rb +162 -0
  196. data/spec/data/complicated/config/software/rubygems-customization.rb +57 -0
  197. data/spec/data/complicated/config/software/rubygems.rb +37 -0
  198. data/spec/data/complicated/config/software/runit.rb +118 -0
  199. data/spec/data/complicated/config/software/server-jre.rb +46 -0
  200. data/spec/data/complicated/config/software/setuptools.rb +30 -0
  201. data/spec/data/complicated/config/software/spawn-fcgi.rb +40 -0
  202. data/spec/data/complicated/config/software/sphinx.rb +26 -0
  203. data/spec/data/complicated/config/software/spidermonkey.rb +60 -0
  204. data/spec/data/complicated/config/software/sqitch.rb +24 -0
  205. data/spec/data/complicated/config/software/test-kitchen.rb +39 -0
  206. data/spec/data/complicated/config/software/unicorn.rb +27 -0
  207. data/spec/data/complicated/config/software/util-macros.rb +46 -0
  208. data/spec/data/complicated/config/software/version-manifest.rb +32 -0
  209. data/spec/data/complicated/config/software/xproto.rb +46 -0
  210. data/spec/data/complicated/config/software/yajl.rb +30 -0
  211. data/spec/data/complicated/config/software/zlib.rb +67 -0
  212. data/spec/data/projects/chefdk.rb +4 -4
  213. data/spec/data/projects/sample.rb +3 -0
  214. data/spec/data/software/erchef.rb +1 -1
  215. data/spec/fixtures/sample/files/windows_msi/Resources/assets/LICENSE.rtf +8 -0
  216. data/spec/fixtures/sample/files/windows_msi/Resources/assets/banner_background.bmp +0 -0
  217. data/spec/fixtures/sample/files/windows_msi/Resources/assets/dialog_background.bmp +0 -0
  218. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project.ico +0 -0
  219. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_16x16.ico +0 -0
  220. data/spec/fixtures/sample/files/windows_msi/Resources/assets/project_32x32.ico +0 -0
  221. data/spec/fixtures/sample/files/windows_msi/Resources/localization-en-us.wxl +20 -0
  222. data/spec/fixtures/sample/files/windows_msi/Resources/parameters.wxi.erb +9 -0
  223. data/spec/fixtures/sample/files/windows_msi/Resources/source.wxs +74 -0
  224. data/spec/functional/packagers/mac_spec.rb +3 -20
  225. data/spec/functional/packagers/windows_spec.rb +69 -0
  226. data/spec/spec_helper.rb +79 -1
  227. data/spec/unit/artifact_spec.rb +0 -18
  228. data/spec/unit/build_version_dsl_spec.rb +136 -0
  229. data/spec/unit/build_version_spec.rb +185 -198
  230. data/spec/unit/config_spec.rb +18 -1
  231. data/spec/unit/fetchers/git_fetcher_spec.rb +55 -80
  232. data/spec/unit/fetchers/net_fetcher_spec.rb +11 -21
  233. data/spec/unit/install_path_cache_spec.rb +164 -136
  234. data/spec/unit/library_spec.rb +125 -5
  235. data/spec/unit/omnibus_spec.rb +25 -9
  236. data/spec/unit/overrides_spec.rb +2 -14
  237. data/spec/unit/package_release_spec.rb +0 -18
  238. data/spec/unit/packagers/base_spec.rb +84 -21
  239. data/spec/unit/packagers/mac_pkg_spec.rb +34 -24
  240. data/spec/unit/project_spec.rb +100 -102
  241. data/spec/unit/s3_cacher_spec.rb +0 -18
  242. data/spec/unit/software_spec.rb +152 -6
  243. data/spec/{sugar_spec.rb → unit/sugar_spec.rb} +0 -3
  244. metadata +365 -38
  245. data/lib/omnibus/cli/application.rb +0 -147
  246. data/lib/omnibus/cli/build.rb +0 -64
@@ -1,24 +1,7 @@
1
- #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
1
  require 'spec_helper'
19
2
 
20
3
  module Omnibus
21
- describe Packager::MacDmg, :functional do
4
+ describe Packager::MacDmg, :functional, :mac_only do
22
5
  let(:name) { 'sample' }
23
6
  let(:version) { '12.4.0' }
24
7
 
@@ -64,8 +47,8 @@ module Omnibus
64
47
 
65
48
  # There is a tiny bit of hard-coding here, but I don't see a better
66
49
  # solution for generating the package name
67
- pkg = "#{project.package_dir}/#{name}-#{version}-1.mac_os_x.10.9.2.pkg"
68
- dmg = "#{project.package_dir}/#{name}-#{version}-1.mac_os_x.10.9.2.dmg"
50
+ pkg = "#{project.package_dir}/#{name}-#{version}-1.pkg"
51
+ dmg = "#{project.package_dir}/#{name}-#{version}-1.dmg"
69
52
 
70
53
  expect(File.exist?(pkg)).to be_true
71
54
  expect(File.exist?(dmg)).to be_true
@@ -0,0 +1,69 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+
20
+ module Omnibus
21
+ describe Packager::WindowsMsi, :functional, :windows_only do
22
+ let(:name) { 'sample' }
23
+ let(:version) { '12.4.0' }
24
+
25
+ let(:project) do
26
+ Project.new(<<-EOH, __FILE__)
27
+ name '#{name}'
28
+ maintainer 'Chef'
29
+ homepage 'https://getchef.com'
30
+ build_version '#{version}'
31
+ install_path '#{tmp_path}\\opt\\#{name}'
32
+ EOH
33
+ end
34
+
35
+ let(:windows_packager) { Packager::WindowsMsi.new(project) }
36
+
37
+ before do
38
+ # Reset stale configuration
39
+ Omnibus.config.reset!
40
+
41
+ # Tell things to install into the cache directory
42
+ root = "#{tmp_path}/var/omnibus"
43
+ Omnibus.config.cache_dir "#{root}/cache"
44
+ Omnibus.config.install_path_cache_dir "#{root}/cache/install_path"
45
+ Omnibus.config.source_dir "#{root}/src"
46
+ Omnibus.config.build_dir "#{root}/build"
47
+ Omnibus.config.package_dir "#{root}/pkg"
48
+ Omnibus.config.package_tmp "#{root}/pkg-tmp"
49
+
50
+ # Point at our sample project fixture
51
+ Omnibus.config.project_root "#{fixtures_path}/sample"
52
+
53
+ # Create the target directory
54
+ FileUtils.mkdir_p(project.install_path)
55
+
56
+ # Create a file to be included in the MSI
57
+ FileUtils.touch(File.join(project.install_path, 'golden_file'))
58
+ end
59
+
60
+ it 'builds a pkg and a dmg' do
61
+ # Create the pkg resource
62
+ windows_packager.run!
63
+
64
+ # There is a tiny bit of hard-coding here, but I don't see a better
65
+ # solution for generating the package name
66
+ expect(File.exist?("#{project.package_dir}/#{name}-#{version}-1.windows.msi")).to be_true
67
+ end
68
+ end
69
+ end
@@ -17,6 +17,10 @@ module Omnibus
17
17
  File.join(SPEC_DATA, 'projects', "#{name}.rb")
18
18
  end
19
19
 
20
+ def complicated_path
21
+ File.join(SPEC_DATA, 'complicated')
22
+ end
23
+
20
24
  def fixtures_path
21
25
  File.expand_path('../fixtures', __FILE__)
22
26
  end
@@ -24,17 +28,88 @@ module Omnibus
24
28
  def tmp_path
25
29
  File.expand_path('../../tmp', __FILE__)
26
30
  end
31
+
32
+ #
33
+ # Stub the given environment key.
34
+ #
35
+ # @param [String] key
36
+ # @param [String] value
37
+ #
38
+ def stub_env(key, value)
39
+ unless @__env_already_stubbed__
40
+ ENV.stub(:[]).and_call_original
41
+ @__env_already_stubbed__ = true
42
+ end
43
+
44
+ ENV.stub(:[]).with(key).and_return(value.to_s)
45
+ end
46
+
47
+ #
48
+ # Stub Ohai with the given data.
49
+ #
50
+ # @param [Hash] data
51
+ #
52
+ def stub_ohai(data = {})
53
+ system = ::Ohai::System.new
54
+ system.data = Mash.new(data)
55
+
56
+ Ohai.stub(:ohai).and_return(system)
57
+ end
58
+
59
+ #
60
+ # Grab the result of the log command. Since Omnibus uses the block form of
61
+ # the logger, this method handles both types of logging.
62
+ #
63
+ # @example
64
+ # output = capture_logging { some_command }
65
+ # expect(output).to include('whatever')
66
+ #
67
+ def capture_logging
68
+ original = Omnibus.logger
69
+ Omnibus.logger = TestLogger.new
70
+ yield
71
+ Omnibus.logger.output
72
+ ensure
73
+ Omnibus.logger = original
74
+ end
75
+ end
76
+ end
77
+
78
+ module Omnibus
79
+ class TestLogger < Logger
80
+ def initialize(*)
81
+ super(StringIO.new)
82
+ @level = -1
83
+ end
84
+
85
+ def output
86
+ @logdev.dev.string
87
+ end
27
88
  end
28
89
  end
29
90
 
91
+ def windows?
92
+ !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
93
+ end
94
+
95
+ def mac?
96
+ !!(RUBY_PLATFORM =~ /darwin/)
97
+ end
98
+
30
99
  RSpec.configure do |config|
31
100
  config.include Omnibus::RSpec
32
101
  config.filter_run focus: true
33
102
  config.run_all_when_everything_filtered = true
34
103
  config.treat_symbols_as_metadata_keys_with_true_values = true
35
104
 
36
- # Clear the tmp_path on each run
105
+ config.filter_run_excluding windows_only: true unless windows?
106
+ config.filter_run_excluding mac_only: true unless mac?
107
+
37
108
  config.before(:each) do
109
+ # Suppress logging
110
+ Omnibus.logger.level = :unknown
111
+
112
+ # Clear the tmp_path on each run
38
113
  FileUtils.rm_rf(tmp_path)
39
114
  FileUtils.mkdir_p(tmp_path)
40
115
  end
@@ -43,4 +118,7 @@ RSpec.configure do |config|
43
118
  config.expect_with :rspec do |c|
44
119
  c.syntax = :expect
45
120
  end
121
+
122
+ # Run specs in a random order
123
+ config.order = 'random'
46
124
  end
@@ -1,21 +1,3 @@
1
- #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'omnibus/artifact'
19
1
  require 'spec_helper'
20
2
 
21
3
  describe Omnibus::Artifact do
@@ -0,0 +1,136 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'spec_helper'
19
+
20
+ describe Omnibus::BuildVersionDSL do
21
+ let(:subject_with_version) { Omnibus::BuildVersionDSL.new(version_string) }
22
+ let(:subject_with_description) { Omnibus::BuildVersionDSL.new(&description) }
23
+
24
+ let(:version_string) { "1.0.0" }
25
+ let(:description) { nil }
26
+
27
+ let(:zoo_version) { double("BuildVersion", semver: "5.5.5", custom: "7.7.7") }
28
+ let(:zoo_software) { double("software", name: 'zoo', project_dir: '/etc/zoo', version: "6.6.6") }
29
+
30
+ describe "when given nil" do
31
+ it "should fail" do
32
+ expect { subject.build_version }.to raise_error
33
+ end
34
+ end
35
+
36
+ describe "when given a string" do
37
+ it "should set the version to the string" do
38
+ expect(subject_with_version.build_version).to eq("1.0.0")
39
+ end
40
+ end
41
+
42
+ describe "when given a :git source" do
43
+ describe "when given a software as source" do
44
+ let(:description) do
45
+ proc do
46
+ source(:git, from_dependency: 'zoo')
47
+ end
48
+ end
49
+
50
+ describe "before resolving version" do
51
+ it "should mention the version is not ready yet" do
52
+ expect(subject_with_description.explain).to match(/will be determined/)
53
+ end
54
+
55
+ it "should include the dependency name in the message" do
56
+ expect(subject_with_description.explain).to match(/zoo/)
57
+ end
58
+ end
59
+
60
+ describe "after resolving version" do
61
+ before do
62
+ Omnibus::BuildVersion.should_receive(:new).with("/etc/zoo").and_return(zoo_version)
63
+ subject_with_description.resolve(zoo_software)
64
+ end
65
+
66
+ it "should create the version with path from source with semver" do
67
+ expect(subject_with_description.explain).to eq("Build Version: 5.5.5")
68
+ end
69
+ end
70
+ end
71
+
72
+ describe "when not given a software as source" do
73
+ let(:description) do
74
+ proc { source(:git) }
75
+ end
76
+
77
+ it "should create the version with default path as semver" do
78
+ Omnibus::BuildVersion.should_receive(:new).with(no_args).and_return(zoo_version)
79
+ expect(subject_with_description.build_version).to eq("5.5.5")
80
+ end
81
+ end
82
+
83
+ describe "when given an output format" do
84
+ let(:description) do
85
+ proc do
86
+ source(:git)
87
+ output_format(:custom)
88
+ end
89
+ end
90
+
91
+ it "should output the version with given function" do
92
+ Omnibus::BuildVersion.should_receive(:new).with(no_args).and_return(zoo_version)
93
+ expect(subject_with_description.build_version).to eq("7.7.7")
94
+ end
95
+ end
96
+ end
97
+
98
+ describe "when given a :version source" do
99
+ describe "when given a software as source" do
100
+ let(:description) do
101
+ proc do
102
+ source(:version, from_dependency: 'zoo')
103
+ end
104
+ end
105
+
106
+ it "should create the version with version from source" do
107
+ subject_with_description.resolve(zoo_software)
108
+ expect(subject_with_description.build_version).to eq("6.6.6")
109
+ end
110
+ end
111
+
112
+ describe "when not given a software as source" do
113
+ let(:description) do
114
+ proc do
115
+ source(:version)
116
+ end
117
+ end
118
+
119
+ it "should fail" do
120
+ expect { subject_with_description.build_version }.to raise_error
121
+ end
122
+ end
123
+ end
124
+
125
+ describe "when given an unknown source" do
126
+ let(:description) do
127
+ proc do
128
+ source(:park)
129
+ end
130
+ end
131
+
132
+ it "should fail" do
133
+ expect { subject_with_description.build_version }.to raise_error
134
+ end
135
+ end
136
+ end
@@ -1,258 +1,245 @@
1
- #
2
- # Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'omnibus/build_version'
19
1
  require 'spec_helper'
20
2
 
21
- describe Omnibus::BuildVersion do
3
+ module Omnibus
4
+ describe BuildVersion do
5
+ let(:git_describe) { '11.0.0-alpha1-207-g694b062' }
6
+ let(:valid_semver_regex) { /^\d+\.\d+\.\d+(\-[\dA-Za-z\-\.]+)?(\+[\dA-Za-z\-\.]+)?$/ }
7
+ let(:valid_git_describe_regex) { /^\d+\.\d+\.\d+(\-[A-Za-z0-9\-\.]+)?(\-\d+\-g[0-9a-f]+)?$/ }
22
8
 
23
- let(:git_describe) { '11.0.0-alpha1-207-g694b062' }
24
- let(:valid_semver_regex) { /^\d+\.\d+\.\d+(\-[\dA-Za-z\-\.]+)?(\+[\dA-Za-z\-\.]+)?$/ }
25
- let(:valid_git_describe_regex) { /^\d+\.\d+\.\d+(\-[A-Za-z0-9\-\.]+)?(\-\d+\-g[0-9a-f]+)?$/ }
9
+ subject(:build_version) { described_class.new }
26
10
 
27
- subject(:build_version) { Omnibus::BuildVersion.new }
11
+ before do
12
+ described_class.any_instance.stub(:shellout)
13
+ .and_return(double('ouput', stdout: git_describe, exitstatus: 0))
28
14
 
29
- before :each do
30
- ENV['BUILD_ID'] = nil
31
- ENV['OMNIBUS_APPEND_TIMESTAMP'] = nil
32
- Omnibus::BuildVersion.any_instance.stub(:shellout)
33
- .and_return(double('ouput', stdout: git_describe, exitstatus: 0))
34
- end
15
+ Omnibus.reset!
16
+ end
35
17
 
36
- describe 'git describe parsing' do
18
+ describe 'git describe parsing' do
37
19
 
38
- # we prefer our git tags to be SemVer compliant
20
+ # we prefer our git tags to be SemVer compliant
39
21
 
40
- # release version
41
- context '11.0.1' do
42
- let(:git_describe) { '11.0.1' }
43
- its(:version_tag) { should == '11.0.1' }
44
- its(:prerelease_tag) { should be_nil }
45
- its(:git_sha_tag) { should be_nil }
46
- its(:commits_since_tag) { should == 0 }
47
- its(:development_version?) { should be_true }
48
- its(:prerelease_version?) { should be_false }
49
- end
22
+ # release version
23
+ context '11.0.1' do
24
+ let(:git_describe) { '11.0.1' }
25
+ its(:version_tag) { should == '11.0.1' }
26
+ its(:prerelease_tag) { should be_nil }
27
+ its(:git_sha_tag) { should be_nil }
28
+ its(:commits_since_tag) { should == 0 }
29
+ its(:development_version?) { should be_true }
30
+ its(:prerelease_version?) { should be_false }
31
+ end
50
32
 
51
- # SemVer compliant prerelease version
52
- context '11.0.0-alpha.2' do
53
- let(:git_describe) { '11.0.0-alpha.2' }
54
- its(:version_tag) { should == '11.0.0' }
55
- its(:prerelease_tag) { should == 'alpha.2' }
56
- its(:git_sha_tag) { should be_nil }
57
- its(:commits_since_tag) { should == 0 }
58
- its(:development_version?) { should be_false }
59
- its(:prerelease_version?) { should be_true }
60
- end
33
+ # SemVer compliant prerelease version
34
+ context '11.0.0-alpha.2' do
35
+ let(:git_describe) { '11.0.0-alpha.2' }
36
+ its(:version_tag) { should == '11.0.0' }
37
+ its(:prerelease_tag) { should == 'alpha.2' }
38
+ its(:git_sha_tag) { should be_nil }
39
+ its(:commits_since_tag) { should == 0 }
40
+ its(:development_version?) { should be_false }
41
+ its(:prerelease_version?) { should be_true }
42
+ end
61
43
 
62
- # full git describe string
63
- context '11.0.0-alpha.3-59-gf55b180' do
64
- let(:git_describe) { '11.0.0-alpha.3-59-gf55b180' }
65
- its(:version_tag) { should == '11.0.0' }
66
- its(:prerelease_tag) { should == 'alpha.3' }
67
- its(:git_sha_tag) { should == 'f55b180' }
68
- its(:commits_since_tag) { should == 59 }
69
- its(:development_version?) { should be_false }
70
- its(:prerelease_version?) { should be_true }
71
- end
44
+ # full git describe string
45
+ context '11.0.0-alpha.3-59-gf55b180' do
46
+ let(:git_describe) { '11.0.0-alpha.3-59-gf55b180' }
47
+ its(:version_tag) { should == '11.0.0' }
48
+ its(:prerelease_tag) { should == 'alpha.3' }
49
+ its(:git_sha_tag) { should == 'f55b180' }
50
+ its(:commits_since_tag) { should == 59 }
51
+ its(:development_version?) { should be_false }
52
+ its(:prerelease_version?) { should be_true }
53
+ end
72
54
 
73
- # Degenerate git tag formats
74
-
75
- # RubyGems compliant git tag
76
- context '10.16.0.rc.0' do
77
- let(:git_describe) { '10.16.0.rc.0' }
78
- its(:version_tag) { should == '10.16.0' }
79
- its(:prerelease_tag) { should == 'rc.0' }
80
- its(:git_sha_tag) { should be_nil }
81
- its(:commits_since_tag) { should == 0 }
82
- its(:development_version?) { should be_false }
83
- its(:prerelease_version?) { should be_true }
84
- end
55
+ # Degenerate git tag formats
56
+
57
+ # RubyGems compliant git tag
58
+ context '10.16.0.rc.0' do
59
+ let(:git_describe) { '10.16.0.rc.0' }
60
+ its(:version_tag) { should == '10.16.0' }
61
+ its(:prerelease_tag) { should == 'rc.0' }
62
+ its(:git_sha_tag) { should be_nil }
63
+ its(:commits_since_tag) { should == 0 }
64
+ its(:development_version?) { should be_false }
65
+ its(:prerelease_version?) { should be_true }
66
+ end
85
67
 
86
- # dash seperated prerelease
87
- context '11.0.0-alpha-2' do
88
- let(:git_describe) { '11.0.0-alpha-2' }
89
- its(:version_tag) { should == '11.0.0' }
90
- its(:prerelease_tag) { should == 'alpha-2' }
91
- its(:git_sha_tag) { should be_nil }
92
- its(:commits_since_tag) { should == 0 }
93
- its(:development_version?) { should be_false }
94
- its(:prerelease_version?) { should be_true }
95
- end
68
+ # dash seperated prerelease
69
+ context '11.0.0-alpha-2' do
70
+ let(:git_describe) { '11.0.0-alpha-2' }
71
+ its(:version_tag) { should == '11.0.0' }
72
+ its(:prerelease_tag) { should == 'alpha-2' }
73
+ its(:git_sha_tag) { should be_nil }
74
+ its(:commits_since_tag) { should == 0 }
75
+ its(:development_version?) { should be_false }
76
+ its(:prerelease_version?) { should be_true }
77
+ end
96
78
 
97
- # dash seperated prerelease full git describe string
98
- context '11.0.0-alpha-2-59-gf55b180' do
99
- let(:git_describe) { '11.0.0-alpha-2-59-gf55b180' }
100
- its(:version_tag) { should == '11.0.0' }
101
- its(:prerelease_tag) { should == 'alpha-2' }
102
- its(:git_sha_tag) { should == 'f55b180' }
103
- its(:commits_since_tag) { should == 59 }
104
- its(:development_version?) { should be_false }
105
- its(:prerelease_version?) { should be_true }
106
- end
79
+ # dash seperated prerelease full git describe string
80
+ context '11.0.0-alpha-2-59-gf55b180' do
81
+ let(:git_describe) { '11.0.0-alpha-2-59-gf55b180' }
82
+ its(:version_tag) { should == '11.0.0' }
83
+ its(:prerelease_tag) { should == 'alpha-2' }
84
+ its(:git_sha_tag) { should == 'f55b180' }
85
+ its(:commits_since_tag) { should == 59 }
86
+ its(:development_version?) { should be_false }
87
+ its(:prerelease_version?) { should be_true }
88
+ end
107
89
 
108
- # WTF git tag
109
- context '11.0.0-alpha2' do
110
- let(:git_describe) { '11.0.0-alpha2' }
111
- its(:version_tag) { should == '11.0.0' }
112
- its(:prerelease_tag) { should == 'alpha2' }
113
- its(:git_sha_tag) { should be_nil }
114
- its(:commits_since_tag) { should == 0 }
115
- its(:development_version?) { should be_false }
116
- its(:prerelease_version?) { should be_true }
90
+ # WTF git tag
91
+ context '11.0.0-alpha2' do
92
+ let(:git_describe) { '11.0.0-alpha2' }
93
+ its(:version_tag) { should == '11.0.0' }
94
+ its(:prerelease_tag) { should == 'alpha2' }
95
+ its(:git_sha_tag) { should be_nil }
96
+ its(:commits_since_tag) { should == 0 }
97
+ its(:development_version?) { should be_false }
98
+ its(:prerelease_version?) { should be_true }
99
+ end
117
100
  end
118
- end
119
101
 
120
- describe 'semver output' do
121
- let(:today_string) { Time.now.utc.strftime('%Y%m%d') }
102
+ describe 'semver output' do
103
+ let(:today_string) { Time.now.utc.strftime('%Y%m%d') }
122
104
 
123
- it 'generates a valid semver version' do
124
- expect(build_version.semver).to match(valid_semver_regex)
125
- end
105
+ it 'generates a valid semver version' do
106
+ expect(build_version.semver).to match(valid_semver_regex)
107
+ end
126
108
 
127
- it "generates a version matching format 'MAJOR.MINOR.PATCH-PRERELEASE+TIMESTAMP.git.COMMITS_SINCE.GIT_SHA'" do
128
- expect(build_version.semver).to match(/11.0.0-alpha1\+#{today_string}[0-9]+.git.207.694b062/)
129
- end
109
+ it "generates a version matching format 'MAJOR.MINOR.PATCH-PRERELEASE+TIMESTAMP.git.COMMITS_SINCE.GIT_SHA'" do
110
+ expect(build_version.semver).to match(/11.0.0-alpha1\+#{today_string}[0-9]+.git.207.694b062/)
111
+ end
130
112
 
131
- it "uses ENV['BUILD_ID'] to generate timestamp if set" do
132
- ENV['BUILD_ID'] = '2012-12-25_16-41-40'
133
- expect(build_version.semver).to eq('11.0.0-alpha1+20121225164140.git.207.694b062')
134
- end
113
+ it "uses ENV['BUILD_ID'] to generate timestamp if set" do
114
+ stub_env('BUILD_ID', '2012-12-25_16-41-40')
115
+ expect(build_version.semver).to eq('11.0.0-alpha1+20121225164140.git.207.694b062')
116
+ end
135
117
 
136
- it "fails on invalid ENV['BUILD_ID'] values" do
137
- ENV['BUILD_ID'] = 'AAAA'
138
- expect { build_version.semver }.to raise_error(ArgumentError)
139
- end
118
+ it "fails on invalid ENV['BUILD_ID'] values" do
119
+ stub_env('BUILD_ID', 'AAAA')
120
+ expect { build_version.semver }.to raise_error(ArgumentError)
121
+ end
140
122
 
141
- context 'prerelease version with dashes' do
142
- let(:git_describe) { '11.0.0-alpha-3-207-g694b062' }
123
+ context 'prerelease version with dashes' do
124
+ let(:git_describe) { '11.0.0-alpha-3-207-g694b062' }
143
125
 
144
- it 'converts all dashes to dots' do
145
- expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
126
+ it 'converts all dashes to dots' do
127
+ expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
128
+ end
146
129
  end
147
- end
148
130
 
149
- context 'exact version' do
150
- let(:git_describe) { '11.0.0-alpha2' }
131
+ context 'exact version' do
132
+ let(:git_describe) { '11.0.0-alpha2' }
151
133
 
152
- it 'appends a timestamp with no git info' do
153
- expect(build_version.semver).to match(/11.0.0-alpha2\+#{today_string}[0-9]+/)
134
+ it 'appends a timestamp with no git info' do
135
+ expect(build_version.semver).to match(/11.0.0-alpha2\+#{today_string}[0-9]+/)
136
+ end
154
137
  end
155
- end
156
138
 
157
- describe 'appending a timestamp' do
158
- let(:git_describe) { '11.0.0-alpha-3-207-g694b062' }
139
+ describe 'appending a timestamp' do
140
+ let(:git_describe) { '11.0.0-alpha-3-207-g694b062' }
159
141
 
160
- it 'appends a timestamp by default' do
161
- expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
162
- end
142
+ it 'appends a timestamp by default' do
143
+ expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
144
+ end
145
+
146
+ describe "ENV['OMNIBUS_APPEND_TIMESTAMP'] is set" do
147
+ ['true', 't', 'yes', 'y', 1].each do |truthy|
148
+ context "to #{truthy}" do
149
+ before { stub_env('OMNIBUS_APPEND_TIMESTAMP', truthy) }
150
+
151
+ it 'appends a timestamp' do
152
+ expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
153
+ end
154
+ end
155
+ end
156
+
157
+ ['false', 'f', 'no', 'n', 0].each do |falsey|
158
+ context "to #{falsey}" do
159
+ before { stub_env('OMNIBUS_APPEND_TIMESTAMP', falsey) }
160
+
161
+ it 'does not append a timestamp' do
162
+ expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ describe 'Config.append_timestamp is set' do
169
+ context 'is true' do
170
+ before { Config.stub(:append_timestamp).and_return(true) }
163
171
 
164
- describe "ENV['OMNIBUS_APPEND_TIMESTAMP'] is set" do
165
- ['true', 't', 'yes', 'y', 1].each do |truthy|
166
- context "to #{truthy}" do
167
- before { ENV['OMNIBUS_APPEND_TIMESTAMP'] = truthy.to_s }
168
172
  it 'appends a timestamp' do
169
173
  expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
170
174
  end
171
175
  end
172
- end
173
176
 
174
- ['false', 'f', 'no', 'n', 0].each do |falsey|
175
- context "to #{falsey}" do
176
- before { ENV['OMNIBUS_APPEND_TIMESTAMP'] = falsey.to_s }
177
+ context 'is false' do
178
+ before { Config.stub(:append_timestamp).and_return(false) }
177
179
  it 'does not append a timestamp' do
178
180
  expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
179
181
  end
180
182
  end
181
183
  end
182
- end
183
184
 
184
- describe 'Omnibus::Config.append_timestamp is set' do
185
- context 'is true' do
186
- before { Omnibus::Config.append_timestamp(true) }
187
- it 'appends a timestamp' do
188
- expect(build_version.semver).to match(/11.0.0-alpha.3\+#{today_string}[0-9]+.git.207.694b062/)
185
+ describe 'both are set' do
186
+ before do
187
+ stub_env('OMNIBUS_APPEND_TIMESTAMP', 'false')
188
+ Config.stub(:append_timestamp).and_return(true)
189
189
  end
190
- end
191
190
 
192
- context 'is false' do
193
- before { Omnibus::Config.append_timestamp(false) }
194
- it 'does not append a timestamp' do
191
+ it "prefers the value from ENV['OMNIBUS_APPEND_TIMESTAMP']" do
195
192
  expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
196
193
  end
197
194
  end
198
195
  end
199
-
200
- describe 'both are set' do
201
- before do
202
- ENV['OMNIBUS_APPEND_TIMESTAMP'] = 'false'
203
- Omnibus::Config.append_timestamp(true)
204
- end
205
- it "prefers the value from ENV['OMNIBUS_APPEND_TIMESTAMP']" do
206
- expect(build_version.semver).to match(/11.0.0-alpha.3\+git.207.694b062/)
207
- end
208
- end
209
196
  end
210
- end
211
197
 
212
- describe 'git describe output' do
213
- it 'generates a valid git describe version' do
214
- expect(build_version.git_describe).to match(valid_git_describe_regex)
215
- end
198
+ describe 'git describe output' do
199
+ it 'generates a valid git describe version' do
200
+ expect(build_version.git_describe).to match(valid_git_describe_regex)
201
+ end
216
202
 
217
- it "generates a version matching format 'MAJOR.MINOR.PATCH-PRELEASE.COMMITS_SINCE-gGIT_SHA'" do
218
- expect(build_version.git_describe).to eq(git_describe)
203
+ it "generates a version matching format 'MAJOR.MINOR.PATCH-PRELEASE.COMMITS_SINCE-gGIT_SHA'" do
204
+ expect(build_version.git_describe).to eq(git_describe)
205
+ end
219
206
  end
220
- end
221
207
 
222
- describe 'deprecated full output' do
223
- it 'generates a valid git describe version' do
224
- expect(Omnibus::BuildVersion.full).to match(valid_git_describe_regex)
225
- end
208
+ describe 'deprecated full output' do
209
+ it 'generates a valid git describe version' do
210
+ expect(BuildVersion.full).to match(valid_git_describe_regex)
211
+ end
226
212
 
227
- it 'outputs a deprecation message' do
228
- expect(Omnibus::BuildVersion).to receive(:puts).with(/is deprecated/)
229
- Omnibus::BuildVersion.full
213
+ it 'outputs a deprecation message' do
214
+ output = capture_logging { BuildVersion.full }
215
+ expect(output).to include('DEPRECATED')
216
+ end
230
217
  end
231
- end
232
218
 
233
- describe '`git describe` command failure' do
234
- before do
235
- stderr = <<-STDERR
236
- fatal: No tags can describe '809ea1afcce67e1148c1bf0822d40a7ef12c380e'.
237
- Try --always, or create some tags.
238
- STDERR
239
- build_version.stub(:shellout)
240
- .and_return(double('ouput', stderr: stderr, exitstatus: 128))
241
- end
242
- it 'sets the version to 0.0.0' do
243
- expect(build_version.git_describe).to eq('0.0.0')
219
+ describe '`git describe` command failure' do
220
+ before do
221
+ stderr = <<-STDERR
222
+ fatal: No tags can describe '809ea1afcce67e1148c1bf0822d40a7ef12c380e'.
223
+ Try --always, or create some tags.
224
+ STDERR
225
+ build_version.stub(:shellout)
226
+ .and_return(double('ouput', stderr: stderr, exitstatus: 128))
227
+ end
228
+ it 'sets the version to 0.0.0' do
229
+ expect(build_version.git_describe).to eq('0.0.0')
230
+ end
244
231
  end
245
- end
246
232
 
247
- describe '#initialize `path` parameter' do
248
- let(:path) { '/some/fake/path' }
249
- subject(:build_version) { Omnibus::BuildVersion.new(path) }
233
+ describe '#initialize `path` parameter' do
234
+ let(:path) { '/some/fake/path' }
235
+ subject(:build_version) { BuildVersion.new(path) }
250
236
 
251
- it 'runs `git describe` at an alternate path' do
252
- expect(build_version).to receive(:shellout)
253
- .with('git describe', live_stream: nil, cwd: path)
254
- .and_return(double('ouput', stdout: git_describe, exitstatus: 0))
255
- build_version.git_describe
237
+ it 'runs `git describe` at an alternate path' do
238
+ expect(build_version).to receive(:shellout)
239
+ .with('git describe --tags', live_stream: nil, cwd: path)
240
+ .and_return(double('ouput', stdout: git_describe, exitstatus: 0))
241
+ build_version.git_describe
242
+ end
256
243
  end
257
244
  end
258
245
  end