Merge lp:~rogpeppe/juju-core/562-lose-testbase into lp:~go-bot/juju-core/trunk

Proposed by Roger Peppe
Status: Merged
Approved by: Roger Peppe
Approved revision: no longer in the source branch.
Merged at revision: 2818
Proposed branch: lp:~rogpeppe/juju-core/562-lose-testbase
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 472 lines (+48/-181)
13 files modified
agent/tools/tools_test.go (+1/-2)
cmd/args_test.go (+2/-2)
cmd/package_test.go (+6/-5)
cmd/supercommand_test.go (+2/-2)
dependencies.tsv (+1/-1)
environs/sync/sync_test.go (+15/-2)
juju/osenv/package_test.go (+2/-2)
state/api/rsyslog/rsyslog_test.go (+1/-1)
testing/base.go (+13/-4)
testing/imports.go (+5/-42)
testing/testbase/log.go (+0/-39)
testing/testbase/log_test.go (+0/-53)
testing/testbase/package_test.go (+0/-26)
To merge this branch: bzr merge lp:~rogpeppe/juju-core/562-lose-testbase
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+221560@code.launchpad.net

Commit message

testing/testbase: remove

It's unnecessary - we move FindJujuCoreImports to
testing (and make it call the less specific version in
github.com/juju/testing).

We temporarily lose the ability to change the logging level
in tests, but that will be reinstated directly in LoggingSuite - it's
not crucial behaviour.

Eventually most tests will use testing.IsolationSuite,
but in the meantime, add testing.CleanupSuite to
those tests that need it.

https://codereview.appspot.com/99670045/

Description of the change

testing/testbase: remove

It's unnecessary - we move FindJujuCoreImports to
testing (and make it call the less specific version in
github.com/juju/testing).

We temporarily lose the ability to change the logging level
in tests, but that will be reinstated directly in LoggingSuite - it's
not crucial behaviour.

Eventually most tests will use testing.IsolationSuite,
but in the meantime, add testing.CleanupSuite to
those tests that need it.

https://codereview.appspot.com/99670045/

To post a comment you must log in.
Revision history for this message
Roger Peppe (rogpeppe) wrote :

Reviewers: mp+221560_code.launchpad.net,

Message:
Please take a look.

Description:
testing/testbase: remove

It's unnecessary - we move FindJujuCoreImports to
testing (and make it call the less specific version in
github.com/juju/testing).

We temporarily lose the ability to change the logging level
in tests, but that will be reinstated directly in LoggingSuite - it's
not crucial behaviour.

Eventually most tests will use testing.IsolationSuite,
but in the meantime, add testing.CleanupSuite to
those tests that need it.

https://code.launchpad.net/~rogpeppe/juju-core/562-lose-testbase/+merge/221560

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/99670045/

Affected files (+59, -189 lines):
   A [revision details]
   M agent/tools/tools_test.go
   M cmd/args_test.go
   M cmd/package_test.go
   M cmd/supercommand_test.go
   M dependencies.tsv
   M environs/sync/sync_test.go
   M juju/osenv/package_test.go
   M state/api/rsyslog/rsyslog_test.go
   M testing/base.go
   M testing/imports.go
   D testing/testbase/log.go
   D testing/testbase/log_test.go
   D testing/testbase/package_test.go
   M utils/exec/package_test.go
   M utils/fslock/package_test.go
   M utils/home_windows_test.go
   M utils/package_test.go

Revision history for this message
Roger Peppe (rogpeppe) wrote :
Revision history for this message
Francesco Banconi (frankban) wrote :

Thanks for this branch Roger!
LGTM with some minor/questions below.

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go
File cmd/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go#newcode26
cmd/package_test.go:26: jc.DeepEquals,
So I presume github.com/juju/testing/checkers.DeepEquals is preferred
over launchpad.net/gocheck.DeepEquals.

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go
File cmd/supercommand_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode11
cmd/supercommand_test.go:11: gitjujutesting "github.com/juju/testing"
We use just "github.com/juju/testing" and coretesting for
"launchpad.net/juju-core/testing" elsewhere.
Anyway this makes the diff short and clean, so <shrug>.
Do we have conventions for import names?

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode28
cmd/supercommand_test.go:28: gitjujutesting.IsolationSuite
Cool.

https://codereview.appspot.com/99670045/diff/40001/testing/base.go
File testing/base.go (right):

https://codereview.appspot.com/99670045/diff/40001/testing/base.go#newcode33
testing/base.go:33: t.CleanupSuite.SetUpSuite(c)
In the Isolation suite we use the reversed order:
s.CleanupSuite.SetUpSuite(c)
s.LoggingSuite.SetUpSuite(c)
I don't think in this case it makes so much difference, but keeping them
in sync now can avoid some confusion in the future.
What do you think?
This also applies to sync_test.

https://codereview.appspot.com/99670045/diff/40001/testing/imports.go
File testing/imports.go (right):

https://codereview.appspot.com/99670045/diff/40001/testing/imports.go#newcode17
testing/imports.go:17: imps, err := testing.FindImports(packageName,
jujuPkgPrefix)
Nice.

https://codereview.appspot.com/99670045/diff/40001/utils/exec/package_test.go
File utils/exec/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/utils/exec/package_test.go#newcode7
utils/exec/package_test.go:7: stdtesting "testing"
This looks like an import error: stdtesting vs testing.

https://codereview.appspot.com/99670045/diff/40001/utils/fslock/package_test.go
File utils/fslock/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/utils/fslock/package_test.go#newcode7
utils/fslock/package_test.go:7: stdtesting "testing"
Ditto.

https://codereview.appspot.com/99670045/

Revision history for this message
Roger Peppe (rogpeppe) wrote :

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go
File cmd/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go#newcode26
cmd/package_test.go:26: jc.DeepEquals,
On 2014/05/30 16:14:56, frankban wrote:
> So I presume github.com/juju/testing/checkers.DeepEquals is preferred
over
> launchpad.net/gocheck.DeepEquals.

It gives better diagnostics on failure.

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go
File cmd/supercommand_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode11
cmd/supercommand_test.go:11: gitjujutesting "github.com/juju/testing"
On 2014/05/30 16:14:57, frankban wrote:
> We use just "github.com/juju/testing" and coretesting for
> "launchpad.net/juju-core/testing" elsewhere.
> Anyway this makes the diff short and clean, so <shrug>.
> Do we have conventions for import names?

not really. i asked about this on juju-dev, and no-one seemed that
bothered.

https://codereview.appspot.com/99670045/diff/40001/testing/base.go
File testing/base.go (right):

https://codereview.appspot.com/99670045/diff/40001/testing/base.go#newcode33
testing/base.go:33: t.CleanupSuite.SetUpSuite(c)
On 2014/05/30 16:14:57, frankban wrote:
> In the Isolation suite we use the reversed order:
> s.CleanupSuite.SetUpSuite(c)
> s.LoggingSuite.SetUpSuite(c)
> I don't think in this case it makes so much difference, but keeping
them in sync
> now can avoid some confusion in the future.
> What do you think?
> This also applies to sync_test.

sgtm, will do.

https://codereview.appspot.com/99670045/diff/40001/utils/exec/package_test.go
File utils/exec/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/utils/exec/package_test.go#newcode7
utils/exec/package_test.go:7: stdtesting "testing"
On 2014/05/30 16:14:57, frankban wrote:
> This looks like an import error: stdtesting vs testing.

yup, i haven't resolved all the trunk merging issues. will fix.

https://codereview.appspot.com/99670045/

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

My feeling is, I don't care where and how things are aliased, but it
should be consistent so that when I am looking at a file and I see
"coretesting" and the next file I see "testing" .. I shouldn't have to
think that might be juju-core/testing, just sans alias.

Also I'm -1 with respect to alias of the standard lib testing to
stdtesting. That just inserts unneeded convention in to our code. We can
easily alias our other testing packages and not have to remember that
stdtesting is really just testing.

I think we should try to use the aliases coretesting, gitjujutesting,
statetesting, jujutesting, etc.. even if they aren't conflicting with
any other imported packages. That consistency will make our code a whole
lot easier to follow IMO.

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go
File cmd/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go#newcode7
cmd/package_test.go:7: stdtesting "testing"
Why alias the standard library testing package?

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go
File cmd/supercommand_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode16
cmd/supercommand_test.go:16: "launchpad.net/juju-core/testing"
Why not alias this to coretesting?

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go
File environs/sync/sync_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go#newcode15
environs/sync/sync_test.go:15: "testing"
Same vein. Here we don't alias to stdtesting.

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go#newcode32
environs/sync/sync_test.go:32: coretesting
"launchpad.net/juju-core/testing"
Again, here we do alias to coretesting.

https://codereview.appspot.com/99670045/

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

On 2014/05/30 16:30:53, wwitzel3 wrote:
> My feeling is, I don't care where and how things are aliased, but it
should be
> consistent so that when I am looking at a file and I see "coretesting"
and the
> next file I see "testing" .. I shouldn't have to think that might be
> juju-core/testing, just sans alias.

> Also I'm -1 with respect to alias of the standard lib testing to
stdtesting.
> That just inserts unneeded convention in to our code. We can easily
alias our
> other testing packages and not have to remember that stdtesting is
really just
> testing.

> I think we should try to use the aliases coretesting, gitjujutesting,
> statetesting, jujutesting, etc.. even if they aren't conflicting with
any other
> imported packages. That consistency will make our code a whole lot
easier to
> follow IMO.

> https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go
> File cmd/package_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/package_test.go#newcode7
> cmd/package_test.go:7: stdtesting "testing"
> Why alias the standard library testing package?

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go
> File cmd/supercommand_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode16
> cmd/supercommand_test.go:16: "launchpad.net/juju-core/testing"
> Why not alias this to coretesting?

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go
> File environs/sync/sync_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go#newcode15
> environs/sync/sync_test.go:15: "testing"
> Same vein. Here we don't alias to stdtesting.

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go#newcode32
> environs/sync/sync_test.go:32: coretesting
"launchpad.net/juju-core/testing"
> Again, here we do alias to coretesting.

And by "how" I meant, naming wise.

https://codereview.appspot.com/99670045/

Revision history for this message
John A Meinel (jameinel) wrote :

I'm pretty sure Tim makes active use of the "run the test suite with a different log level", though I think he's the only one that I know of that does.

It would be good to at least keep him up to date on the change and where it is headed.

I do agree with the idea from William that it will be easier to understand test suites if we use common naming for the actual test packages. Though it really starts to sound like we should just be naming the packages like that, rather than forcing everyone to do the aliasing.

Especially "testing" because it is reasonably likely that you might need more than one of those in a new test suite.

Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 30 May 2014 17:30, <email address hidden> wrote:
> My feeling is, I don't care where and how things are aliased, but it
> should be consistent so that when I am looking at a file and I see
> "coretesting" and the next file I see "testing" .. I shouldn't have to
> think that might be juju-core/testing, just sans alias.
>
> Also I'm -1 with respect to alias of the standard lib testing to
> stdtesting. That just inserts unneeded convention in to our code. We can
> easily alias our other testing packages and not have to remember that
> stdtesting is really just testing.
>
> I think we should try to use the aliases coretesting, gitjujutesting,
> statetesting, jujutesting, etc.. even if they aren't conflicting with
> any other imported packages. That consistency will make our code a whole
> lot easier to follow IMO.

Perhaps you're right, but that's not been the convention up until now.
If we do decide to do that, perhaps we should just rename those packages so
we don't need the identifier.

Revision history for this message
Roger Peppe (rogpeppe) wrote :

Please take a look.

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go
File cmd/supercommand_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/cmd/supercommand_test.go#newcode16
cmd/supercommand_test.go:16: "launchpad.net/juju-core/testing"
On 2014/05/30 16:30:52, wwitzel3 wrote:
> Why not alias this to coretesting?

The original rationale was that juju-core/testing feels "native" so
earns the right to be unaliased when reasonable. I've left it that way
here to save churn, although it could easily be coretesting too.

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go
File environs/sync/sync_test.go (right):

https://codereview.appspot.com/99670045/diff/40001/environs/sync/sync_test.go#newcode15
environs/sync/sync_test.go:15: "testing"
On 2014/05/30 16:30:52, wwitzel3 wrote:
> Same vein. Here we don't alias to stdtesting.

Yeah, conventionally we would alias to stdtesting here
(after all, the identifier is only used once)

https://codereview.appspot.com/99670045/diff/40001/testing/base.go
File testing/base.go (right):

https://codereview.appspot.com/99670045/diff/40001/testing/base.go#newcode33
testing/base.go:33: t.CleanupSuite.SetUpSuite(c)
On 2014/05/30 16:19:40, rog wrote:
> On 2014/05/30 16:14:57, frankban wrote:
> > In the Isolation suite we use the reversed order:
> > s.CleanupSuite.SetUpSuite(c)
> > s.LoggingSuite.SetUpSuite(c)
> > I don't think in this case it makes so much difference, but keeping
them in
> sync
> > now can avoid some confusion in the future.
> > What do you think?
> > This also applies to sync_test.

> sgtm, will do.

Done.

https://codereview.appspot.com/99670045/

Revision history for this message
Go Bot (go-bot) wrote :

The attempt to merge lp:~rogpeppe/juju-core/562-lose-testbase into lp:juju-core failed. Below is the output from the failed tests.

godeps: cannot update "/home/tarmac/trees/src/github.com/juju/testing": fatal: reference is not a tree: 77f66ce9a8a203fd6af74b38fb207666d5cdeae6
mongod: no process found

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'agent/tools/tools_test.go'
2--- agent/tools/tools_test.go 2014-05-20 04:27:02 +0000
3+++ agent/tools/tools_test.go 2014-06-02 13:47:12 +0000
4@@ -15,7 +15,6 @@
5
6 agenttools "launchpad.net/juju-core/agent/tools"
7 "launchpad.net/juju-core/testing"
8- "launchpad.net/juju-core/testing/testbase"
9 coretest "launchpad.net/juju-core/tools"
10 "launchpad.net/juju-core/version"
11 )
12@@ -37,7 +36,7 @@
13 // or any of the other bigger packages that'll drag in yet more dependencies.
14 // Only imports that start with "launchpad.net/juju-core" are checked, and the
15 // resulting slice has that prefix removed to keep the output short.
16- c.Assert(testbase.FindJujuCoreImports(c, "launchpad.net/juju-core/agent/tools"),
17+ c.Assert(testing.FindJujuCoreImports(c, "launchpad.net/juju-core/agent/tools"),
18 gc.DeepEquals,
19 []string{"juju/arch", "tools", "utils/set", "version"})
20 }
21
22=== modified file 'cmd/args_test.go'
23--- cmd/args_test.go 2014-04-11 01:04:15 +0000
24+++ cmd/args_test.go 2014-06-02 13:47:12 +0000
25@@ -7,15 +7,15 @@
26 "fmt"
27 "io/ioutil"
28
29+ "github.com/juju/testing"
30 "launchpad.net/gnuflag"
31 gc "launchpad.net/gocheck"
32
33 "launchpad.net/juju-core/cmd"
34- "launchpad.net/juju-core/testing/testbase"
35 )
36
37 type ArgsSuite struct {
38- testbase.LoggingSuite
39+ testing.LoggingSuite
40 }
41
42 var _ = gc.Suite(&ArgsSuite{})
43
44=== modified file 'cmd/package_test.go'
45--- cmd/package_test.go 2014-05-21 02:34:39 +0000
46+++ cmd/package_test.go 2014-06-02 13:47:12 +0000
47@@ -4,14 +4,15 @@
48 package cmd_test
49
50 import (
51- "testing"
52+ stdtesting "testing"
53
54+ jc "github.com/juju/testing/checkers"
55 gc "launchpad.net/gocheck"
56
57- "launchpad.net/juju-core/testing/testbase"
58+ coretesting "launchpad.net/juju-core/testing"
59 )
60
61-func Test(t *testing.T) { gc.TestingT(t) }
62+func Test(t *stdtesting.T) { gc.TestingT(t) }
63
64 type Dependencies struct{}
65
66@@ -21,7 +22,7 @@
67 // This test is to ensure we don't bring in dependencies without thinking.
68 // Looking at the "environs/config", it is just for JujuHome. This should
69 // really be moved into "juju/osenv".
70- c.Assert(testbase.FindJujuCoreImports(c, "launchpad.net/juju-core/cmd"),
71- gc.DeepEquals,
72+ c.Assert(coretesting.FindJujuCoreImports(c, "launchpad.net/juju-core/cmd"),
73+ jc.DeepEquals,
74 []string{"juju/arch", "juju/osenv", "names", "utils", "version"})
75 }
76
77=== modified file 'cmd/supercommand_test.go'
78--- cmd/supercommand_test.go 2014-05-26 04:33:18 +0000
79+++ cmd/supercommand_test.go 2014-06-02 13:47:12 +0000
80@@ -8,12 +8,12 @@
81 "fmt"
82 "strings"
83
84+ gitjujutesting "github.com/juju/testing"
85 "launchpad.net/gnuflag"
86 gc "launchpad.net/gocheck"
87
88 "launchpad.net/juju-core/cmd"
89 "launchpad.net/juju-core/testing"
90- "launchpad.net/juju-core/testing/testbase"
91 "launchpad.net/juju-core/version"
92 )
93
94@@ -25,7 +25,7 @@
95 }
96
97 type SuperCommandSuite struct {
98- testbase.LoggingSuite
99+ gitjujutesting.IsolationSuite
100 }
101
102 var _ = gc.Suite(&SuperCommandSuite{})
103
104=== modified file 'dependencies.tsv'
105--- dependencies.tsv 2014-05-29 20:05:19 +0000
106+++ dependencies.tsv 2014-06-02 13:47:12 +0000
107@@ -11,7 +11,7 @@
108 github.com/juju/errors git 075df0417dbcc39d24ee18248d2f8d6e3eed598b
109 github.com/juju/loggo git 7e8c70b24b80b95b2284f09306aac0bd93588db8
110 github.com/juju/ratelimit git 0025ab75db6c6eaa4ffff0240c2c9e617ad1a0eb
111-github.com/juju/testing git 0f4fb4f667cdc8e1a6c763434f7b486e2256df6a
112+github.com/juju/testing git 77f66ce9a8a203fd6af74b38fb207666d5cdeae6
113 labix.org/v2/mgo bzr gustavo@niemeyer.net-20140331185009-fhnh3xzfdpicup0j 273
114 launchpad.net/gnuflag bzr roger.peppe@canonical.com-20121003093437-zcyyw0lpvj2nifpk 12
115 launchpad.net/goamz bzr roger.peppe@canonical.com-20131218155244-hbnkvlkkzy3vmlh9 44
116
117=== modified file 'environs/sync/sync_test.go'
118--- environs/sync/sync_test.go 2014-05-20 00:01:25 +0000
119+++ environs/sync/sync_test.go 2014-06-02 13:47:12 +0000
120@@ -14,6 +14,7 @@
121 "sort"
122 "testing"
123
124+ gitjujutesting "github.com/juju/testing"
125 jc "github.com/juju/testing/checkers"
126 gc "launchpad.net/gocheck"
127
128@@ -29,7 +30,6 @@
129 toolstesting "launchpad.net/juju-core/environs/tools/testing"
130 "launchpad.net/juju-core/provider/dummy"
131 coretesting "launchpad.net/juju-core/testing"
132- "launchpad.net/juju-core/testing/testbase"
133 coretools "launchpad.net/juju-core/tools"
134 "launchpad.net/juju-core/utils"
135 "launchpad.net/juju-core/version"
136@@ -408,7 +408,8 @@
137
138 type badBuildSuite struct {
139 env environs.Environ
140- testbase.LoggingSuite
141+ gitjujutesting.LoggingSuite
142+ gitjujutesting.CleanupSuite
143 envtesting.ToolsFixture
144 }
145
146@@ -417,7 +418,18 @@
147 exit 1
148 `[1:]
149
150+func (s *badBuildSuite) SetUpSuite(c *gc.C) {
151+ s.CleanupSuite.SetUpSuite(c)
152+ s.LoggingSuite.SetUpSuite(c)
153+}
154+
155+func (s *badBuildSuite) TearDownSuite(c *gc.C) {
156+ s.LoggingSuite.TearDownSuite(c)
157+ s.CleanupSuite.TearDownSuite(c)
158+}
159+
160 func (s *badBuildSuite) SetUpTest(c *gc.C) {
161+ s.CleanupSuite.SetUpTest(c)
162 s.LoggingSuite.SetUpTest(c)
163 s.ToolsFixture.SetUpTest(c)
164 // We only want to use simplestreams to find any synced tools.
165@@ -443,6 +455,7 @@
166 dummy.Reset()
167 s.ToolsFixture.TearDownTest(c)
168 s.LoggingSuite.TearDownTest(c)
169+ s.CleanupSuite.TearDownTest(c)
170 }
171
172 func (s *badBuildSuite) TestBundleToolsBadBuild(c *gc.C) {
173
174=== modified file 'juju/osenv/package_test.go'
175--- juju/osenv/package_test.go 2014-05-26 08:49:54 +0000
176+++ juju/osenv/package_test.go 2014-06-02 13:47:12 +0000
177@@ -9,7 +9,7 @@
178 "github.com/juju/testing"
179 gc "launchpad.net/gocheck"
180
181- "launchpad.net/juju-core/testing/testbase"
182+ coretesting "launchpad.net/juju-core/testing"
183 )
184
185 func Test(t *stdtesting.T) {
186@@ -24,6 +24,6 @@
187
188 // TODO (frankban): remove this test once juju-core/utils is on Github.
189 func (*importSuite) TestTemporaryDependencies(c *gc.C) {
190- c.Assert(testbase.FindJujuCoreImports(c, "launchpad.net/juju-core/juju/osenv"),
191+ c.Assert(coretesting.FindJujuCoreImports(c, "launchpad.net/juju-core/juju/osenv"),
192 gc.DeepEquals, []string{"utils"})
193 }
194
195=== modified file 'state/api/rsyslog/rsyslog_test.go'
196--- state/api/rsyslog/rsyslog_test.go 2014-05-22 15:23:46 +0000
197+++ state/api/rsyslog/rsyslog_test.go 2014-06-02 13:47:12 +0000
198@@ -5,12 +5,12 @@
199
200 import (
201 gc "launchpad.net/gocheck"
202+
203 "launchpad.net/juju-core/instance"
204 "launchpad.net/juju-core/juju/testing"
205 "launchpad.net/juju-core/state"
206 "launchpad.net/juju-core/state/api"
207 "launchpad.net/juju-core/state/api/rsyslog"
208-
209 statetesting "launchpad.net/juju-core/state/testing"
210 coretesting "launchpad.net/juju-core/testing"
211 )
212
213=== modified file 'testing/base.go'
214--- testing/base.go 2014-05-23 12:58:44 +0000
215+++ testing/base.go 2014-06-02 13:47:12 +0000
216@@ -8,10 +8,10 @@
217 "os"
218 "path/filepath"
219
220+ "github.com/juju/testing"
221 gc "launchpad.net/gocheck"
222
223 "launchpad.net/juju-core/juju/osenv"
224- "launchpad.net/juju-core/testing/testbase"
225 "launchpad.net/juju-core/utils"
226 )
227
228@@ -22,17 +22,26 @@
229 // - protection of user's home directory
230 // - scrubbing of env vars
231 type BaseSuite struct {
232- testbase.LoggingSuite
233+ testing.CleanupSuite
234+ testing.LoggingSuite
235 oldHomeEnv string
236 oldEnvironment map[string]string
237 }
238
239 func (t *BaseSuite) SetUpSuite(c *gc.C) {
240+ t.CleanupSuite.SetUpSuite(c)
241 t.LoggingSuite.SetUpSuite(c)
242 t.PatchValue(&utils.OutgoingAccessAllowed, false)
243 }
244
245+func (t *BaseSuite) TearDownSuite(c *gc.C) {
246+ t.LoggingSuite.TearDownSuite(c)
247+ t.CleanupSuite.TearDownSuite(c)
248+}
249+
250 func (t *BaseSuite) SetUpTest(c *gc.C) {
251+ t.CleanupSuite.SetUpTest(c)
252+ t.LoggingSuite.SetUpTest(c)
253 t.oldEnvironment = make(map[string]string)
254 for _, name := range []string{
255 osenv.JujuHomeEnvKey,
256@@ -46,15 +55,15 @@
257 os.Setenv(osenv.JujuHomeEnvKey, "")
258 os.Setenv(osenv.JujuEnvEnvKey, "")
259 os.Setenv(osenv.JujuLoggingConfigEnvKey, "")
260- t.LoggingSuite.SetUpTest(c)
261 }
262
263 func (t *BaseSuite) TearDownTest(c *gc.C) {
264- t.LoggingSuite.TearDownTest(c)
265 for name, value := range t.oldEnvironment {
266 os.Setenv(name, value)
267 }
268 utils.SetHome(t.oldHomeEnv)
269+ t.LoggingSuite.TearDownTest(c)
270+ t.CleanupSuite.TearDownTest(c)
271 }
272
273 type TestFile struct {
274
275=== renamed file 'testing/testbase/imports.go' => 'testing/imports.go'
276--- testing/testbase/imports.go 2014-01-21 21:29:02 +0000
277+++ testing/imports.go 2014-06-02 13:47:12 +0000
278@@ -1,14 +1,10 @@
279 // Copyright 2013 Canonical Ltd.
280 // Licensed under the AGPLv3, see LICENCE file for details.
281
282-package testbase
283+package testing
284
285 import (
286- "go/build"
287- "path/filepath"
288- "sort"
289- "strings"
290-
291+ "github.com/juju/testing"
292 gc "launchpad.net/gocheck"
293 )
294
295@@ -18,40 +14,7 @@
296 // imported by the packageName parameter. The resulting list removes the
297 // common prefix "launchpad.net/juju-core/" leaving just the short names.
298 func FindJujuCoreImports(c *gc.C, packageName string) []string {
299- var result []string
300- allpkgs := make(map[string]bool)
301-
302- findJujuCoreImports(c, packageName, allpkgs)
303- for name := range allpkgs {
304- result = append(result, name[len(jujuPkgPrefix):])
305- }
306- sort.Strings(result)
307- return result
308-}
309-
310-// findJujuCoreImports recursively adds all imported packages of given
311-// package (packageName) to allpkgs map.
312-func findJujuCoreImports(c *gc.C, packageName string, allpkgs map[string]bool) {
313-
314- var imports []string
315-
316- for _, root := range build.Default.SrcDirs() {
317- fullpath := filepath.Join(root, packageName)
318- pkg, err := build.ImportDir(fullpath, 0)
319- if err == nil {
320- imports = pkg.Imports
321- break
322- }
323- }
324- if imports == nil {
325- c.Fatalf(packageName + " not found")
326- }
327-
328- for _, name := range imports {
329- if strings.HasPrefix(name, jujuPkgPrefix) {
330- allpkgs[name] = true
331- findJujuCoreImports(c, name, allpkgs)
332- }
333- }
334-
335+ imps, err := testing.FindImports(packageName, jujuPkgPrefix)
336+ c.Assert(err, gc.IsNil)
337+ return imps
338 }
339
340=== removed directory 'testing/testbase'
341=== removed file 'testing/testbase/log.go'
342--- testing/testbase/log.go 2014-05-28 14:28:03 +0000
343+++ testing/testbase/log.go 1970-01-01 00:00:00 +0000
344@@ -1,39 +0,0 @@
345-// Copyright 2012, 2013 Canonical Ltd.
346-// Licensed under the AGPLv3, see LICENCE file for details.
347-
348-package testbase
349-
350-import (
351- "flag"
352-
353- "github.com/juju/loggo"
354- "github.com/juju/testing"
355- gc "launchpad.net/gocheck"
356-)
357-
358-// LoggingSuite redirects the juju logger to the test logger
359-// when embedded in a gocheck suite type.
360-type LoggingSuite struct {
361- testing.LoggingCleanupSuite
362-}
363-
364-func (t *LoggingSuite) SetUpSuite(c *gc.C) {
365- t.LoggingCleanupSuite.SetUpSuite(c)
366- t.setUp(c)
367-}
368-
369-func (t *LoggingSuite) SetUpTest(c *gc.C) {
370- t.LoggingCleanupSuite.SetUpTest(c)
371- t.PatchEnvironment("JUJU_LOGGING_CONFIG", "")
372- t.setUp(c)
373-}
374-
375-var logConfig = flag.String("juju.log", "DEBUG", "logging configuration (see http://godoc.org/github.com/juju/loggo#ConfigureLoggers; also accepts a bare log level to configure the log level of the root module")
376-
377-func (t *LoggingSuite) setUp(c *gc.C) {
378- if _, ok := loggo.ParseLevel(*logConfig); ok {
379- *logConfig = "<root>=" + *logConfig
380- }
381- err := loggo.ConfigureLoggers(*logConfig)
382- c.Assert(err, gc.IsNil)
383-}
384
385=== removed file 'testing/testbase/log_test.go'
386--- testing/testbase/log_test.go 2014-04-17 03:34:43 +0000
387+++ testing/testbase/log_test.go 1970-01-01 00:00:00 +0000
388@@ -1,53 +0,0 @@
389-// Copyright 2013 Canonical Ltd.
390-// Licensed under the AGPLv3, see LICENCE file for details.
391-
392-package testbase_test
393-
394-import (
395- "github.com/juju/loggo"
396- gc "launchpad.net/gocheck"
397-
398- "launchpad.net/juju-core/testing/testbase"
399-)
400-
401-var logger = loggo.GetLogger("juju.logsuite")
402-
403-var _ = gc.Suite(&logSuite{})
404-
405-type logSuite struct {
406- testbase.LoggingSuite
407-}
408-
409-func (s *logSuite) SetUpSuite(c *gc.C) {
410- s.LoggingSuite.SetUpSuite(c)
411- logger.Infof("testing-SetUpSuite")
412- c.Assert(c.GetTestLog(), gc.Matches, ".*INFO juju.logsuite testing-SetUpSuite\n")
413-}
414-
415-func (s *logSuite) TearDownSuite(c *gc.C) {
416- // Unfortunately there's no way of testing that the
417- // log output is printed, as the logger is printing
418- // a previously set up *gc.C. We print a message
419- // anyway so that we can manually verify it.
420- logger.Infof("testing-TearDownSuite")
421-}
422-
423-func (s *logSuite) SetUpTest(c *gc.C) {
424- s.LoggingSuite.SetUpTest(c)
425- logger.Infof("testing-SetUpTest")
426- c.Assert(c.GetTestLog(), gc.Matches, ".*INFO juju.logsuite testing-SetUpTest\n")
427-}
428-
429-func (s *logSuite) TearDownTest(c *gc.C) {
430- // The same applies here as to TearDownSuite.
431- logger.Infof("testing-TearDownTest")
432- s.LoggingSuite.TearDownTest(c)
433-}
434-
435-func (s *logSuite) TestLog(c *gc.C) {
436- logger.Infof("testing-Test")
437- c.Assert(c.GetTestLog(), gc.Matches,
438- ".*INFO juju.logsuite testing-SetUpTest\n"+
439- ".*INFO juju.logsuite testing-Test\n",
440- )
441-}
442
443=== removed file 'testing/testbase/package_test.go'
444--- testing/testbase/package_test.go 2013-09-20 02:10:46 +0000
445+++ testing/testbase/package_test.go 1970-01-01 00:00:00 +0000
446@@ -1,26 +0,0 @@
447-// Copyright 2013 Canonical Ltd.
448-// Licensed under the AGPLv3, see LICENCE file for details.
449-
450-package testbase_test
451-
452-import (
453- "testing"
454-
455- gc "launchpad.net/gocheck"
456-
457- "launchpad.net/juju-core/testing/testbase"
458-)
459-
460-func Test(t *testing.T) {
461- gc.TestingT(t)
462-}
463-
464-type DependencySuite struct{}
465-
466-var _ = gc.Suite(&DependencySuite{})
467-
468-func (*DependencySuite) TestPackageDependencies(c *gc.C) {
469- // This test is to ensure we don't bring in any juju-core dependencies.
470- c.Assert(testbase.FindJujuCoreImports(c, "launchpad.net/juju-core/testing/testbase"),
471- gc.HasLen, 0)
472-}

Subscribers

People subscribed via source and target branches

to status/vote changes: