diff options
| author | Vlad Shablinsky | 2016-07-11 14:52:05 +0300 |
|---|---|---|
| committer | Xu Cheng | 2016-07-16 20:39:13 +0800 |
| commit | 454003c4c1ea43f4fd84db96017636fc4c50b318 (patch) | |
| tree | d618f4477189a8ff3bb42205a25576f08a60e14f /Library | |
| parent | 458f9a008cc5316de9ec18ebae3b0f3990583540 (diff) | |
| download | brew-454003c4c1ea43f4fd84db96017636fc4c50b318.tar.bz2 | |
test_formula: test new HEAD methods
* Test `Formula#update_head_version`
* Test `Formula#latest_head_prefix`
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 12d6eaece..c5175e27e 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -158,6 +158,29 @@ class FormulaTests < Homebrew::TestCase assert_equal prefix, f.installed_prefix end + def test_latest_head_prefix + f = Testball.new + + stamps_with_revisions = [[111111, 1], [222222, 1], [222222, 2], [222222, 0]] + + stamps_with_revisions.each do |stamp, revision| + version = "HEAD-#{stamp}" + version += "_#{revision}" if revision > 0 + prefix = f.rack.join(version) + prefix.mkpath + + tab = Tab.empty + tab.tabfile = prefix.join("INSTALL_RECEIPT.json") + tab.source_modified_time = stamp + tab.write + end + + prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2" + assert_equal prefix, f.latest_head_prefix + ensure + f.rack.rmtree + end + def test_equality x = Testball.new y = Testball.new @@ -282,6 +305,38 @@ class FormulaTests < Homebrew::TestCase assert_equal PkgVersion.parse("HEAD_1"), f.pkg_version end + def test_update_head_version + initial_env = ENV.to_hash + + f = formula do + head "foo", :using => :git + end + + cached_location = f.head.downloader.cached_location + cached_location.mkpath + + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end + end + + f.update_head_version + assert_equal Version.create("HEAD-5658946"), f.head.version + ensure + ENV.replace(initial_env) + cached_location.rmtree + end + def test_legacy_options f = formula do url "foo-1.0" |
