dependency_collector: make resource dep available at test-time too

There are formulae that use resource blocks for stuff that is needed in
test blocks. If a resource is a `.zip` archive, one needs `unzip`
utility in `PATH` to extract it, but its only available at build-time,
so one observes an error like that for example:

```
==> brew test psftools --verbose
Testing psftools
==> Downloading https://www.zone38.net/font/pc8x8.zip
Already downloaded: /github/home/.cache/Homebrew/downloads/ea5f6a485687368ff5bc99e4cc43a49b06e081baa51a97ee6ddcd8d1b82d7963--pc8x8.zip
==> Verifying ea5f6a485687368ff5bc99e4cc43a49b06e081baa51a97ee6ddcd8d1b82d7963--pc8x8.zip checksum
unzip -o /github/home/.cache/Homebrew/downloads/ea5f6a485687368ff5bc99e4cc43a49b06e081baa51a97ee6ddcd8d1b82d7963--pc8x8.zip -d /tmp/d20200304-21389-ui0wr0
Error: psftools: failed
undefined method `shelljoin' for nil:NilClass
```

Of course this issue affects Linux the most, because of higher
probability that the system lacks `unzip` for example.

With this commit, all resource guessed dependencies should be available
at build and test time.
This commit is contained in:
Dawid Dziurla 2020-03-04 21:52:46 +01:00
parent 10ba0d5a66
commit 59ce122e90
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B
3 changed files with 10 additions and 10 deletions

View File

@ -142,7 +142,7 @@ class DependencyCollector
end end
def resource_dep(spec, tags) def resource_dep(spec, tags)
tags << :build tags << :build << :test
strategy = spec.download_strategy strategy = spec.download_strategy
if strategy <= CurlDownloadStrategy if strategy <= CurlDownloadStrategy

View File

@ -62,13 +62,13 @@ describe DependencyCollector do
it "creates a resource dependency from a CVS URL" do it "creates a resource dependency from a CVS URL" do
resource = Resource.new resource = Resource.new
resource.url(":pserver:anonymous:@brew.sh:/cvsroot/foo/bar", using: :cvs) resource.url(":pserver:anonymous:@brew.sh:/cvsroot/foo/bar", using: :cvs)
expect(subject.add(resource)).to eq(Dependency.new("cvs", [:build])) expect(subject.add(resource)).to eq(Dependency.new("cvs", [:build, :test]))
end end
it "creates a resource dependency from a '.7z' URL" do it "creates a resource dependency from a '.7z' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.7z") resource.url("https://brew.sh/foo.7z")
expect(subject.add(resource)).to eq(Dependency.new("p7zip", [:build])) expect(subject.add(resource)).to eq(Dependency.new("p7zip", [:build, :test]))
end end
it "creates a resource dependency from a '.gz' URL" do it "creates a resource dependency from a '.gz' URL" do
@ -80,25 +80,25 @@ describe DependencyCollector do
it "creates a resource dependency from a '.lz' URL" do it "creates a resource dependency from a '.lz' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.lz") resource.url("https://brew.sh/foo.lz")
expect(subject.add(resource)).to eq(Dependency.new("lzip", [:build])) expect(subject.add(resource)).to eq(Dependency.new("lzip", [:build, :test]))
end end
it "creates a resource dependency from a '.lha' URL" do it "creates a resource dependency from a '.lha' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.lha") resource.url("https://brew.sh/foo.lha")
expect(subject.add(resource)).to eq(Dependency.new("lha", [:build])) expect(subject.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
end end
it "creates a resource dependency from a '.lzh' URL" do it "creates a resource dependency from a '.lzh' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.lzh") resource.url("https://brew.sh/foo.lzh")
expect(subject.add(resource)).to eq(Dependency.new("lha", [:build])) expect(subject.add(resource)).to eq(Dependency.new("lha", [:build, :test]))
end end
it "creates a resource dependency from a '.rar' URL" do it "creates a resource dependency from a '.rar' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.rar") resource.url("https://brew.sh/foo.rar")
expect(subject.add(resource)).to eq(Dependency.new("unrar", [:build])) expect(subject.add(resource)).to eq(Dependency.new("unrar", [:build, :test]))
end end
it "raises a TypeError for unknown classes" do it "raises a TypeError for unknown classes" do

View File

@ -12,19 +12,19 @@ describe DependencyCollector do
it "creates a resource dependency from a '.xz' URL" do it "creates a resource dependency from a '.xz' URL" do
resource.url("https://brew.sh/foo.xz") resource.url("https://brew.sh/foo.xz")
allow_any_instance_of(Object).to receive(:which).with("xz") allow_any_instance_of(Object).to receive(:which).with("xz")
expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) expect(subject.add(resource)).to eq(Dependency.new("xz", [:build, :test]))
end end
it "creates a resource dependency from a '.zip' URL" do it "creates a resource dependency from a '.zip' URL" do
resource.url("https://brew.sh/foo.zip") resource.url("https://brew.sh/foo.zip")
allow_any_instance_of(Object).to receive(:which).with("unzip") allow_any_instance_of(Object).to receive(:which).with("unzip")
expect(subject.add(resource)).to eq(Dependency.new("unzip", [:build])) expect(subject.add(resource)).to eq(Dependency.new("unzip", [:build, :test]))
end end
it "creates a resource dependency from a '.bz2' URL" do it "creates a resource dependency from a '.bz2' URL" do
resource.url("https://brew.sh/foo.tar.bz2") resource.url("https://brew.sh/foo.tar.bz2")
allow_any_instance_of(Object).to receive(:which).with("bzip2") allow_any_instance_of(Object).to receive(:which).with("bzip2")
expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build, :test]))
end end
end end