Merge lp:~mvo/snappy/snappy-fix-ftbfs-sbuild into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Michael Vogt
Status: Merged
Approved by: Michael Vogt
Approved revision: 468
Merged at revision: 469
Proposed branch: lp:~mvo/snappy/snappy-fix-ftbfs-sbuild
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 170 lines (+60/-14)
3 files modified
logger/logger.go (+14/-3)
logger/logger_test.go (+38/-10)
snappy/build_test.go (+8/-1)
To merge this branch: bzr merge lp:~mvo/snappy/snappy-fix-ftbfs-sbuild
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
John Lenton (community) Approve
Review via email: mp+259479@code.launchpad.net

Commit message

Fix FTBFS in a sbuild environment by mocking syslog tests and checking for /dev/shm.

Description of the change

Tiny branch that fixes a FTBFS in a sbuild environment. Skipping the logger tests is something I'm not happy with :/

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) wrote :

I suspect you forgot something (inline).

review: Needs Fixing
Revision history for this message
John Lenton (chipaca) :
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks a lot! Insufficient tests, I'm sorry for that (I really should have learned this by now *sigh*). Fixed in r464 and added the missing test :)

Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (5.5 KiB)

The attempt to merge lp:~mvo/snappy/snappy-fix-ftbfs-sbuild into lp:snappy failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update code.google.com/p/go.crypto failed; trying to fetch newer version
update github.com/blakesmith/ar failed; trying to fetch newer version
code.google.com/p/go.crypto now at 69e2a90ed92d03812364aeb947b7068dc42e561e
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/blakesmith/ar now at c9a977dd0cc1392b023382c7bfa5a22af8d3b730
update github.com/jessevdk/go-flags failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/jessevdk/go-flags now at 15347ef417a300349807983f15af9e65cd2e1b3a
update gopkg.in/yaml.v2 failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update launchpad.net/gocheck failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
launchpad.net/gocheck now at <email address hidden>
Building
Running tests from /home/tarmac/tmp/tmp.krhn3eL6z3/src/launchpad.net/snappy
=== RUN Test
OK: 16 passed
--- PASS: Test (0.24 seconds)
PASS
coverage: 80.2% of statements
ok launchpad.net/snappy/clickdeb 0.250s coverage: 80.2% of statements
=== RUN Test
OK: 6 passed
--- PASS: Test (0.05 seconds)
PASS
coverage: 12.2% of statements
ok launchpad.net/snappy/cmd/snappy 0.052s coverage: 12.2% of statements
=== RUN Test
OK: 24 passed
--- PASS: Test (0.08 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.net/snappy/coreconfig 0.081s coverage: 100.0% of statements
=== RUN Test
OK: 47 passed
--- PASS: Test (1.04 seconds)
PASS
coverage: 83.3% of statements
ok launchpad.net/snappy/helpers 1.052s coverage: 83.3% of statements
=== RUN Test
OK: 6 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 93.5% of statements
ok launchpad.net/snappy/logger 0.013s coverage: 93.5% of statements
=== RUN Test
OK: 36 passed
--- PASS: Test (0.15 seconds)
PASS
coverage: 81.5% of statements
ok launchpad.net/snappy/partition 0.150s coverage: 81.5% of statements
=== RUN Test
OK: 3 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.net/snappy/pkg 0.003s coverage: 100.0% of statements
=== RUN Test
OK: 12 passed
--- PASS: Test (0.07 seconds)
PASS
coverage: 94.3% of statements
ok launchpad.net/snappy/policy 0.069s coverage: 94.3% of statements
=== RUN Test
OK: 3 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 84.8% of statements
ok launchpad.net/snappy/priv 0.004s coverage: 84.8% of statements
=== RUN Test
OK: 4 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 50.0% of statements
ok launchpad.net/snappy/progress 0.010s coverage: 50.0% of statements
=== RUN Test
OK: 6 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.net/snappy/release 0.006s coverage: 100.0% of statements
=== RUN Test
drwxr-xr-x root/root 0 2015-05-20 03:11 ./bin
-rwxr-xr-x root/root 31 2015-05...

Read more...

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

I'll make this easy -> go vet says:
logger/logger_test.go:119:26: error strings should not end with punctuation

467. By Michael Vogt

merged lp:snappy

468. By Michael Vogt

logger/logger_test.go: fix go vet error

Revision history for this message
Michael Vogt (mvo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'logger/logger.go'
--- logger/logger.go 2015-05-19 14:09:19 +0000
+++ logger/logger.go 2015-05-22 06:05:46 +0000
@@ -22,6 +22,7 @@
22import (22import (
23 "fmt"23 "fmt"
24 "io"24 "io"
25 "io/ioutil"
25 "log"26 "log"
26 "log/syslog"27 "log/syslog"
27 "os"28 "os"
@@ -114,16 +115,26 @@
114 l.log.Output(3, msg)115 l.log.Output(3, msg)
115}116}
116117
118// variable to allow mocking the syslog.NewLogger call in the tests
119var newSyslog = newSyslogImpl
120
121func newSyslogImpl() (*log.Logger, error) {
122 return syslog.NewLogger(SyslogPriority, SyslogFlags)
123}
124
117// NewConsoleLog creates a ConsoleLog with a log.Logger using the given125// NewConsoleLog creates a ConsoleLog with a log.Logger using the given
118// io.Writer and flag, and a syslog.Writer.126// io.Writer and flag, and a syslog.Writer.
119func NewConsoleLog(w io.Writer, flag int) (*ConsoleLog, error) {127func NewConsoleLog(w io.Writer, flag int) (*ConsoleLog, error) {
120 sys, err := syslog.NewLogger(SyslogPriority, SyslogFlags)128 clog := log.New(w, "", flag)
129
130 sys, err := newSyslog()
121 if err != nil {131 if err != nil {
122 return nil, err132 clog.Output(3, "WARNING: can not create syslog logger")
133 sys = log.New(ioutil.Discard, "", flag)
123 }134 }
124135
125 return &ConsoleLog{136 return &ConsoleLog{
126 log: log.New(w, "", flag),137 log: clog,
127 sys: sys,138 sys: sys,
128 }, nil139 }, nil
129}140}
130141
=== modified file 'logger/logger_test.go'
--- logger/logger_test.go 2015-05-19 14:09:19 +0000
+++ logger/logger_test.go 2015-05-22 06:05:46 +0000
@@ -21,6 +21,7 @@
2121
22import (22import (
23 "bytes"23 "bytes"
24 "fmt"
24 "log"25 "log"
25 "testing"26 "testing"
2627
@@ -32,14 +33,24 @@
3233
33var _ = Suite(&LogSuite{})34var _ = Suite(&LogSuite{})
3435
35type LogSuite struct{}36type LogSuite struct {
37 sysbuf *bytes.Buffer
38}
3639
37func (s *LogSuite) SetUpTest(c *C) {40func (s *LogSuite) SetUpTest(c *C) {
38 c.Assert(logger, Equals, NullLogger)41 c.Assert(logger, Equals, NullLogger)
42
43 // we do not want to pollute syslog in our tests (and sbuild
44 // will also not let us do that)
45 newSyslog = func() (*log.Logger, error) {
46 s.sysbuf = bytes.NewBuffer(nil)
47 return log.New(s.sysbuf, "", SyslogFlags), nil
48 }
39}49}
4050
41func (s *LogSuite) TearDownTest(c *C) {51func (s *LogSuite) TearDownTest(c *C) {
42 SetLogger(NullLogger)52 SetLogger(NullLogger)
53 newSyslog = newSyslogImpl
43}54}
4455
45func (s *LogSuite) TestDefault(c *C) {56func (s *LogSuite) TestDefault(c *C) {
@@ -65,42 +76,59 @@
6576
66func (s *LogSuite) TestDebugf(c *C) {77func (s *LogSuite) TestDebugf(c *C) {
67 var logbuf bytes.Buffer78 var logbuf bytes.Buffer
68 var sysbuf bytes.Buffer
69 l, err := NewConsoleLog(&logbuf, DefaultFlags)79 l, err := NewConsoleLog(&logbuf, DefaultFlags)
70 c.Assert(err, IsNil)80 c.Assert(err, IsNil)
7181
72 l.sys = log.New(&sysbuf, "", SyslogFlags)
73 SetLogger(l)82 SetLogger(l)
7483
75 Debugf("xyzzy")84 Debugf("xyzzy")
76 c.Check(sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: DEBUG: xyzzy`)85 c.Check(s.sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: DEBUG: xyzzy`)
77 c.Check(logbuf.String(), Equals, "")86 c.Check(logbuf.String(), Equals, "")
78}87}
7988
80func (s *LogSuite) TestNoticef(c *C) {89func (s *LogSuite) TestNoticef(c *C) {
81 var logbuf bytes.Buffer90 var logbuf bytes.Buffer
82 var sysbuf bytes.Buffer
83 l, err := NewConsoleLog(&logbuf, DefaultFlags)91 l, err := NewConsoleLog(&logbuf, DefaultFlags)
84 c.Assert(err, IsNil)92 c.Assert(err, IsNil)
8593
86 l.sys = log.New(&sysbuf, "", SyslogFlags)
87 SetLogger(l)94 SetLogger(l)
8895
89 Noticef("xyzzy")96 Noticef("xyzzy")
90 c.Check(sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: xyzzy`)97 c.Check(s.sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: xyzzy`)
91 c.Check(logbuf.String(), Matches, `(?m).*logger_test\.go:\d+: xyzzy`)98 c.Check(logbuf.String(), Matches, `(?m).*logger_test\.go:\d+: xyzzy`)
92}99}
93100
94func (s *LogSuite) TestPanicf(c *C) {101func (s *LogSuite) TestPanicf(c *C) {
95 var logbuf bytes.Buffer102 var logbuf bytes.Buffer
96 var sysbuf bytes.Buffer
97 l, err := NewConsoleLog(&logbuf, DefaultFlags)103 l, err := NewConsoleLog(&logbuf, DefaultFlags)
98 c.Assert(err, IsNil)104 c.Assert(err, IsNil)
99105
100 l.sys = log.New(&sysbuf, "", SyslogFlags)
101 SetLogger(l)106 SetLogger(l)
102107
103 c.Check(func() { Panicf("xyzzy") }, Panics, "xyzzy")108 c.Check(func() { Panicf("xyzzy") }, Panics, "xyzzy")
104 c.Check(sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: PANIC xyzzy`)109 c.Check(s.sysbuf.String(), Matches, `(?m).*logger_test\.go:\d+: PANIC xyzzy`)
105 c.Check(logbuf.String(), Matches, `(?m).*logger_test\.go:\d+: PANIC xyzzy`)110 c.Check(logbuf.String(), Matches, `(?m).*logger_test\.go:\d+: PANIC xyzzy`)
106}111}
112
113func (s *LogSuite) TestSyslogFails(c *C) {
114 var logbuf bytes.Buffer
115
116 // pretend syslog is not available (e.g. because of no /dev/log in
117 // a chroot or something)
118 newSyslog = func() (*log.Logger, error) {
119 return nil, fmt.Errorf("nih nih")
120 }
121
122 // ensure a warning is displayed
123 l, err := NewConsoleLog(&logbuf, DefaultFlags)
124 c.Assert(err, IsNil)
125 c.Check(logbuf.String(), Matches, `(?m).*:\d+: WARNING: can not create syslog logger`)
126
127 // ensure that even without a syslog the console log works and we
128 // do not crash
129 logbuf.Reset()
130 SetLogger(l)
131 Noticef("I do not want to crash")
132 c.Check(logbuf.String(), Matches, `(?m).*logger_test\.go:\d+: I do not want to crash`)
133
134}
107135
=== modified file 'snappy/build_test.go'
--- snappy/build_test.go 2015-05-19 19:34:13 +0000
+++ snappy/build_test.go 2015-05-22 06:05:46 +0000
@@ -325,9 +325,16 @@
325325
326func (s *SnapTestSuite) TestCopyActuallyCopies(c *C) {326func (s *SnapTestSuite) TestCopyActuallyCopies(c *C) {
327 sourceDir := makeExampleSnapSourceDir(c, "name: hello")327 sourceDir := makeExampleSnapSourceDir(c, "name: hello")
328 // hoping to get the non-linking behaviour328
329 // hoping to get the non-linking behaviour via /dev/shm
329 target, err := ioutil.TempDir("/dev/shm", "copy")330 target, err := ioutil.TempDir("/dev/shm", "copy")
331 // sbuild environments won't allow writing to /dev/shm, so its
332 // ok to skip there
333 if os.IsPermission(err) {
334 c.Skip("/dev/shm is not writable for us")
335 }
330 c.Assert(err, IsNil)336 c.Assert(err, IsNil)
337
331 defer os.Remove(target)338 defer os.Remove(target)
332 c.Assert(copyToBuildDir(sourceDir, target), IsNil)339 c.Assert(copyToBuildDir(sourceDir, target), IsNil)
333 out, err := exec.Command("diff", "-qrN", sourceDir, target).Output()340 out, err := exec.Command("diff", "-qrN", sourceDir, target).Output()

Subscribers

People subscribed via source and target branches