Skip to content
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

Merged
merged 2 commits into from Aug 10, 2018

Conversation

chipaca
Copy link
Contributor

@chipaca chipaca commented Aug 10, 2018

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).

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).
Copy link
Collaborator

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -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")
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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-io
Copy link

codecov-io commented Aug 10, 2018

Codecov Report

Merging #5627 into master will increase coverage by <.01%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cmd/snap/main.go 58.08% <ø> (ø) ⬆️
testutil/dbustest.go 0% <0%> (ø) ⬆️
cmd/snap/cmd_get.go 86.17% <100%> (+1.79%) ⬆️
cmd/snap/color.go 96.49% <100%> (ø) ⬆️
cmd/snap/cmd_run.go 66.38% <0%> (+1.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 928e6aa...09040a2. Read the comment docs.

@chipaca chipaca merged commit b5d93c2 into snapcore:master Aug 10, 2018
@chipaca chipaca deleted the cmd-snap-test-fixes branch August 26, 2018 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants