Skip to content

Commit

Permalink
chore: testing rpmbuild not in path
Browse files Browse the repository at this point in the history
and adding it to travis
  • Loading branch information
caarlos0 committed Feb 16, 2018
1 parent b2faa8b commit f592011
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dist: trusty
sudo: required
addons:
apt:
packages:
- rpmbuild
language: go
go: 1.9
services:
Expand Down
6 changes: 5 additions & 1 deletion rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func (*RPM) Package(info nfpm.Info, w io.Writer) error {
cmd.Dir = temps.Root
out, err := cmd.CombinedOutput()
if err != nil {
return errors.Wrapf(err, "rpmbuild failed: %s", string(out))
var msg = "rpmbuild failed"
if string(out) != "" {
msg += ": " + string(out)
}
return errors.Wrap(err, msg)
}

rpm, err := os.Open(temps.RPM)
Expand Down
12 changes: 10 additions & 2 deletions rpm/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rpm

import (
"io/ioutil"
"os"
"testing"

"github.com/goreleaser/nfpm"
Expand Down Expand Up @@ -54,10 +55,17 @@ func TestNoFiles(t *testing.T) {
Vendor: "nope",
License: "MIT",
Bindir: "/usr/local/bin",
Files: map[string]string{},
ConfigFiles: map[string]string{},
}),
ioutil.Discard,
)
assert.Error(t, err)
}

func TestRPMBuildNotInPath(t *testing.T) {
assert.NoError(t, os.Setenv("PATH", ""))
var err = Default.Package(
nfpm.WithDefaults(nfpm.Info{}),
ioutil.Discard,
)
assert.EqualError(t, err, `rpmbuild failed: exec: "rpmbuild": executable file not found in $PATH`)
}

0 comments on commit f592011

Please sign in to comment.