From a53171d9fe99eee935720bccab84cdfd5092ee5b Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 14:58:07 -0600 Subject: Adding tests for dependency_collector on Linux --- Library/Homebrew/test/dependency_collector_spec.rb | 1 + .../Homebrew/test/os/dependency_collector_spec.rb | 1 + .../test/os/linux/dependency_collector_spec.rb | 23 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 Library/Homebrew/test/os/dependency_collector_spec.rb create mode 100644 Library/Homebrew/test/os/linux/dependency_collector_spec.rb (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb index 46e859b2d..f8fb16c02 100644 --- a/Library/Homebrew/test/dependency_collector_spec.rb +++ b/Library/Homebrew/test/dependency_collector_spec.rb @@ -140,3 +140,4 @@ describe DependencyCollector do end end end +require "test/os/dependency_collector_spec" diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb new file mode 100644 index 000000000..3d7029e40 --- /dev/null +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -0,0 +1 @@ +require "test/os/linux/dependency_collector_spec" if OS.linux? diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb new file mode 100644 index 000000000..37d61c89b --- /dev/null +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -0,0 +1,23 @@ +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + it "creates a resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bzip2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end +end -- cgit v1.2.3 From 5cfcd2ae9f2a4ef731f666e3e78cfb74ae28ae38 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 15:04:43 -0600 Subject: Fixing test --- Library/Homebrew/test/os/linux/dependency_collector_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb index 37d61c89b..eaae99fe9 100644 --- a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -14,9 +14,9 @@ describe DependencyCollector do expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) end - it "creates a resource dependency from a '.bzip2' URL" do + it "creates a resource dependency from a '.bz2' URL" do resource = Resource.new - resource.url("http://example.com/foo.tar.bzip2") + resource.url("http://example.com/foo.tar.bz2") expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) end end -- cgit v1.2.3 From 73a3592981f7645ba81afef0332def27f553abc4 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 08:54:30 +0000 Subject: Renaming linux-specifix file with tests Files are globbed based on their name. Therefore, we have to rename them so tests for Linux are not executed on a Mac. --- .../Homebrew/test/os/dependency_collector_spec.rb | 2 +- .../Homebrew/test/os/linux/dependency_collector.rb | 23 ++++++++++++++++++++++ .../test/os/linux/dependency_collector_spec.rb | 23 ---------------------- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 Library/Homebrew/test/os/linux/dependency_collector.rb delete mode 100644 Library/Homebrew/test/os/linux/dependency_collector_spec.rb (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index 3d7029e40..d190788da 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1 @@ -require "test/os/linux/dependency_collector_spec" if OS.linux? +require "test/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/test/os/linux/dependency_collector.rb b/Library/Homebrew/test/os/linux/dependency_collector.rb new file mode 100644 index 000000000..eaae99fe9 --- /dev/null +++ b/Library/Homebrew/test/os/linux/dependency_collector.rb @@ -0,0 +1,23 @@ +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + it "creates a resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bz2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bz2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end +end diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb deleted file mode 100644 index eaae99fe9..000000000 --- a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "dependency_collector" - -describe DependencyCollector do - alias_matcher :be_a_build_requirement, :be_build - - after(:each) do - described_class.clear_cache - end - - describe "#add" do - it "creates a resource dependency from a '.zip' URL" do - resource = Resource.new - resource.url("http://example.com/foo.zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) - end - - it "creates a resource dependency from a '.bz2' URL" do - resource = Resource.new - resource.url("http://example.com/foo.tar.bz2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) - end - end -end -- cgit v1.2.3 From d25fc5ce50a46b37e84d90151d0ea3c467667231 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 09:54:36 +0000 Subject: Code refactoring --- Library/Homebrew/test/dependency_collector_spec.rb | 1 - Library/Homebrew/test/os/dependency_collector_spec.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb index f8fb16c02..46e859b2d 100644 --- a/Library/Homebrew/test/dependency_collector_spec.rb +++ b/Library/Homebrew/test/dependency_collector_spec.rb @@ -140,4 +140,3 @@ describe DependencyCollector do end end end -require "test/os/dependency_collector_spec" diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index d190788da..4fe064732 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1 @@ -require "test/os/linux/dependency_collector" if OS.linux? +require "test/dependency_collector" -- cgit v1.2.3 From c6dac68d8bdb652152d89a097a9ab9f270832d68 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 10:21:01 +0000 Subject: Code refactoring v3.0 --- .../Homebrew/test/os/dependency_collector_spec.rb | 24 +++++++++++++++++++++- .../Homebrew/test/os/linux/dependency_collector.rb | 23 --------------------- 2 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 Library/Homebrew/test/os/linux/dependency_collector.rb (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index 4fe064732..eaae99fe9 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1,23 @@ -require "test/dependency_collector" +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + it "creates a resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bz2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bz2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end +end diff --git a/Library/Homebrew/test/os/linux/dependency_collector.rb b/Library/Homebrew/test/os/linux/dependency_collector.rb deleted file mode 100644 index eaae99fe9..000000000 --- a/Library/Homebrew/test/os/linux/dependency_collector.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "dependency_collector" - -describe DependencyCollector do - alias_matcher :be_a_build_requirement, :be_build - - after(:each) do - described_class.clear_cache - end - - describe "#add" do - it "creates a resource dependency from a '.zip' URL" do - resource = Resource.new - resource.url("http://example.com/foo.zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) - end - - it "creates a resource dependency from a '.bz2' URL" do - resource = Resource.new - resource.url("http://example.com/foo.tar.bz2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) - end - end -end -- cgit v1.2.3 From 14d7a7a08c9aab7db14ea03f59ec85899e5e3ba6 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 20 Feb 2018 21:33:38 +0000 Subject: Code refactoring 4.0 --- .../Homebrew/test/os/dependency_collector_spec.rb | 23 ---------- .../test/os/linux/dependency_collector_spec.rb | 53 ++++++++++++++++++++++ .../test/os/mac/dependency_collector_spec.rb | 12 +++++ 3 files changed, 65 insertions(+), 23 deletions(-) delete mode 100644 Library/Homebrew/test/os/dependency_collector_spec.rb create mode 100644 Library/Homebrew/test/os/linux/dependency_collector_spec.rb (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb deleted file mode 100644 index eaae99fe9..000000000 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "dependency_collector" - -describe DependencyCollector do - alias_matcher :be_a_build_requirement, :be_build - - after(:each) do - described_class.clear_cache - end - - describe "#add" do - it "creates a resource dependency from a '.zip' URL" do - resource = Resource.new - resource.url("http://example.com/foo.zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) - end - - it "creates a resource dependency from a '.bz2' URL" do - resource = Resource.new - resource.url("http://example.com/foo.tar.bz2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) - end - end -end diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb new file mode 100644 index 000000000..5771fd59a --- /dev/null +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -0,0 +1,53 @@ +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + resource = Resource.new + + context "when xz, zip, and bzip2 are not available" do + it "creates a resource dependency from a '.xz' URL" do + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz") + expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) + end + + it "creates a resource dependency from a '.zip' URL" do + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bz2' URL" do + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end + + context "when xz, zip, and bzip2 are available" do + it "does not create a resource dependency from a '.xz' URL" do + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + + it "does not create a resource dependency from a '.zip' URL" do + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + + it "does not create a resource dependency from a '.bz2' URL" do + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + end + end +end diff --git a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb index 5d260ebf7..a8fe8ba54 100644 --- a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb @@ -36,6 +36,18 @@ describe DependencyCollector do expect(subject.add(resource)).to be nil end + specify "Resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to be nil + end + + specify "Resource dependency from a '.bz2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bz2") + expect(subject.add(resource)).to be nil + end + specify "Resource dependency from a '.git' URL" do resource = Resource.new resource.url("git://example.com/foo/bar.git") -- cgit v1.2.3 From c83dd0d04b857161b47a43b54ba56c7296ac50c0 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 21 Feb 2018 13:44:51 +0000 Subject: brew style: replace tabs with spaces --- .../test/os/linux/dependency_collector_spec.rb | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb index 5771fd59a..543ed39b0 100644 --- a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -12,41 +12,41 @@ describe DependencyCollector do context "when xz, zip, and bzip2 are not available" do it "creates a resource dependency from a '.xz' URL" do - resource.url("http://example.com/foo.xz") - allow_any_instance_of(Object).to receive(:which).with("xz") - expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz") + expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) end it "creates a resource dependency from a '.zip' URL" do - resource.url("http://example.com/foo.zip") - allow_any_instance_of(Object).to receive(:which).with("zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) end it "creates a resource dependency from a '.bz2' URL" do - resource.url("http://example.com/foo.tar.bz2") - allow_any_instance_of(Object).to receive(:which).with("bzip2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) end end context "when xz, zip, and bzip2 are available" do it "does not create a resource dependency from a '.xz' URL" do - resource.url("http://example.com/foo.xz") - allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end it "does not create a resource dependency from a '.zip' URL" do - resource.url("http://example.com/foo.zip") - allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end it "does not create a resource dependency from a '.bz2' URL" do - resource.url("http://example.com/foo.tar.bz2") - allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end end end -- cgit v1.2.3