New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/snap: fix some corner-case test setup weirdness #5627
Conversation
In some cases, when running the tests in a particular way, some bits of the environment were not set up properly and tests would fail. In particular colour support was getting isatty for stdout wrong, as it was never mocked outside of the colour tests. And dbus tests were failing to unset the session bus env var. It's a mystery how these things sometimes worked :-) but this should fix it for good. I've also taken the opportunity to unify our isatty handling (at least within cmd/snap; there's still code in progress/ doing it separately).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
testutil/dbustest.go
Outdated
@@ -54,6 +54,7 @@ func (s *DBusTest) SetUpSuite(c *C) { | |||
err := s.dbusDaemon.Start() | |||
c.Assert(err, IsNil) | |||
s.oldSessionBusEnv = os.Getenv("DBUS_SESSION_BUS_ADDRESS") | |||
os.Unsetenv("DBUS_SESSION_BUS_ADDRESS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do:
os.Setenv("DBUS_SESSION_BUS_ADDRESS", fmt.Sprintf("unix:%s/user_bus_socket", s.tmpdir))
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'd think so, but it doesn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes a while for the socket to appear, http://paste.ubuntu.com/p/mwvRRjjqzf/
Codecov Report
@@ Coverage Diff @@
## master #5627 +/- ##
==========================================
+ Coverage 78.94% 78.94% +<.01%
==========================================
Files 520 520
Lines 39571 39577 +6
==========================================
+ Hits 31238 31243 +5
+ Misses 5790 5789 -1
- Partials 2543 2545 +2
Continue to review full report at Codecov.
|
In some cases, when running the tests in a particular way, some bits
of the environment were not set up properly and tests would fail. In
particular colour support was getting isatty for stdout wrong, as it
was never mocked outside of the colour tests. And dbus tests were
failing to unset the session bus env var. It's a mystery how these
things sometimes worked :-) but this should fix it for good.
I've also taken the opportunity to unify our isatty handling (at least
within cmd/snap; there's still code in progress/ doing it separately).