aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2015-07-31 16:14:26 +0800
committerXu Cheng2015-07-31 19:44:07 +0800
commit8054161153b598d392b0be25a882ae87a5455726 (patch)
tree67a995b6273c9a1349a9bfa02217671aeb8e3551 /Library
parenta9e71ca9057798880fb6885e6de9db2b2b7cac34 (diff)
downloadbrew-8054161153b598d392b0be25a882ae87a5455726.tar.bz2
test_tab: add test for Tab#spec
Fixes Homebrew/homebrew#42147. Closes Homebrew/homebrew#42205. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/fixtures/receipt.json8
-rw-r--r--Library/Homebrew/test/fixtures/receipt_old.json17
-rw-r--r--Library/Homebrew/test/test_tab.rb19
3 files changed, 42 insertions, 2 deletions
diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json
index 955d56b47..8a3adc672 100644
--- a/Library/Homebrew/test/fixtures/receipt.json
+++ b/Library/Homebrew/test/fixtures/receipt.json
@@ -9,9 +9,13 @@
],
"built_as_bottle": false,
"poured_from_bottle": true,
- "tapped_from": "Homebrew/homebrew",
"time": 1403827774,
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"stdlib": "libcxx",
- "compiler": "clang"
+ "compiler": "clang",
+ "source": {
+ "path": "/usr/local/Library/Formula/foo.rb",
+ "tap": "Homebrew/homebrew",
+ "spec": "stable"
+ }
}
diff --git a/Library/Homebrew/test/fixtures/receipt_old.json b/Library/Homebrew/test/fixtures/receipt_old.json
new file mode 100644
index 000000000..955d56b47
--- /dev/null
+++ b/Library/Homebrew/test/fixtures/receipt_old.json
@@ -0,0 +1,17 @@
+{
+ "used_options": [
+ "--with-foo",
+ "--without-bar"
+ ],
+ "unused_options": [
+ "--with-baz",
+ "--without-qux"
+ ],
+ "built_as_bottle": false,
+ "poured_from_bottle": true,
+ "tapped_from": "Homebrew/homebrew",
+ "time": 1403827774,
+ "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
+ "stdlib": "libcxx",
+ "compiler": "clang"
+}
diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb
index eebfe9be3..af537267c 100644
--- a/Library/Homebrew/test/test_tab.rb
+++ b/Library/Homebrew/test/test_tab.rb
@@ -19,6 +19,7 @@ class TabTests < Homebrew::TestCase
"source" => {
"tap" => "Homebrew/homebrew",
"path" => nil,
+ "spec" => "stable",
},
})
end
@@ -66,6 +67,22 @@ class TabTests < Homebrew::TestCase
assert_predicate @tab, :poured_from_bottle
end
+ def test_from_old_version_file
+ path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt_old.json")
+ tab = Tab.from_file(path)
+
+ assert_equal @used.sort, tab.used_options.sort
+ assert_equal @unused.sort, tab.unused_options.sort
+ refute_predicate tab, :built_as_bottle
+ assert_predicate tab, :poured_from_bottle
+ assert_equal "Homebrew/homebrew", tab.tap
+ assert_equal :stable, tab.spec
+ refute_nil tab.time
+ assert_equal TEST_SHA1, tab.HEAD
+ assert_equal :clang, tab.cxxstdlib.compiler
+ assert_equal :libcxx, tab.cxxstdlib.type
+ end
+
def test_from_file
path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json")
tab = Tab.from_file(path)
@@ -75,6 +92,7 @@ class TabTests < Homebrew::TestCase
refute_predicate tab, :built_as_bottle
assert_predicate tab, :poured_from_bottle
assert_equal "Homebrew/homebrew", tab.tap
+ assert_equal :stable, tab.spec
refute_nil tab.time
assert_equal TEST_SHA1, tab.HEAD
assert_equal :clang, tab.cxxstdlib.compiler
@@ -88,6 +106,7 @@ class TabTests < Homebrew::TestCase
assert_equal @tab.built_as_bottle, tab.built_as_bottle
assert_equal @tab.poured_from_bottle, tab.poured_from_bottle
assert_equal @tab.tap, tab.tap
+ assert_equal @tab.spec, tab.spec
assert_equal @tab.time, tab.time
assert_equal @tab.HEAD, tab.HEAD
assert_equal @tab.compiler, tab.compiler