Merge lp:~tvansteenburgh/charmtester/bundletester into lp:~bcsaller/charmtester/bundletester

Proposed by Tim Van Steenburgh
Status: Needs review
Proposed branch: lp:~tvansteenburgh/charmtester/bundletester
Merge into: lp:~bcsaller/charmtester/bundletester
Diff against target: 157 lines (+32/-26)
7 files modified
bundletester/builder.py (+1/-1)
bundletester/config.py (+3/-3)
bundletester/runner.py (+6/-3)
bundletester/spec.py (+15/-13)
bundletester/tester.py (+2/-1)
tests/test_config.py (+4/-4)
tests/test_spec.py (+1/-1)
To merge this branch: bzr merge lp:~tvansteenburgh/charmtester/bundletester
Reviewer Review Type Date Requested Status
Benjamin Saller Pending
Review via email: mp+227265@code.launchpad.net

Description of the change

Bugfix for charm and bundle tests not being executed if no .bzr directory present.

To post a comment you must log in.
47. By Tim Van Steenburgh

More accurate bundle detection

Make sure 'services' key is not actually a Charm config option

48. By Tim Van Steenburgh

Unique exit code to signify 'No tests found'

Also make exit msg more accurate - 'No tests found' does not necessarily
imply that test target was not a bundle or charm.

49. By Tim Van Steenburgh

Use --force when destroying env

50. By Tim Van Steenburgh

Change default test search pattern

- Find all executable tests in the tests/ dir by default,
  instead of just those that begin with a number
- cd to the testdir when running tests in order to play
  nicely with amulet's charm lookup machinery
- Fix failing tests caused by new defaults

Unmerged revisions

50. By Tim Van Steenburgh

Change default test search pattern

- Find all executable tests in the tests/ dir by default,
  instead of just those that begin with a number
- cd to the testdir when running tests in order to play
  nicely with amulet's charm lookup machinery
- Fix failing tests caused by new defaults

49. By Tim Van Steenburgh

Use --force when destroying env

48. By Tim Van Steenburgh

Unique exit code to signify 'No tests found'

Also make exit msg more accurate - 'No tests found' does not necessarily
imply that test target was not a bundle or charm.

47. By Tim Van Steenburgh

More accurate bundle detection

Make sure 'services' key is not actually a Charm config option

46. By Tim Van Steenburgh

Run successfully even if no .bzr dir

45. By Tim Van Steenburgh

Change config default values

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bundletester/builder.py'
2--- bundletester/builder.py 2014-06-04 16:33:24 +0000
3+++ bundletester/builder.py 2014-09-07 22:41:37 +0000
4@@ -68,7 +68,7 @@
5 def destroy(self):
6 if self.options.no_destroy is not True:
7 subprocess.check_call(['juju', 'destroy-environment',
8- '-y', self.env_name])
9+ '-y', self.env_name, '--force'])
10
11 def reset(self):
12 if self.environment:
13
14=== modified file 'bundletester/config.py'
15--- bundletester/config.py 2014-06-03 06:54:39 +0000
16+++ bundletester/config.py 2014-09-07 22:41:37 +0000
17@@ -4,11 +4,11 @@
18 class Parser(dict):
19 def __defaults__(self):
20 return {
21- 'bootstrap': False,
22- 'reset': False,
23+ 'bootstrap': True,
24+ 'reset': True,
25 'bundle': None,
26 'virtualenv': True,
27- 'tests': "[0-9]*",
28+ 'tests': "*",
29 'excludes': [],
30 'sources': [],
31 'packages': [],
32
33=== modified file 'bundletester/runner.py'
34--- bundletester/runner.py 2014-06-05 03:09:55 +0000
35+++ bundletester/runner.py 2014-09-07 22:41:37 +0000
36@@ -49,9 +49,12 @@
37 if self.options.dryrun:
38 return 0, ""
39
40- p = subprocess.Popen(executable,
41- stdout=subprocess.PIPE,
42- stderr=subprocess.STDOUT)
43+ p = subprocess.Popen(
44+ executable,
45+ stdout=subprocess.PIPE,
46+ stderr=subprocess.STDOUT,
47+ cwd=self.options.testdir,
48+ )
49 retcode = p.wait()
50 output = p.stdout.read()
51 log.debug("\n%s" % output)
52
53=== modified file 'bundletester/spec.py'
54--- bundletester/spec.py 2014-06-05 03:09:55 +0000
55+++ bundletester/spec.py 2014-09-07 22:41:37 +0000
56@@ -173,6 +173,10 @@
57 continue
58 for possible in data.values():
59 if isinstance(possible, dict) and 'services' in possible:
60+ keys = sorted(possible['services'].keys())
61+ if keys == ['default', 'description', 'type']:
62+ # looks like a charm, not a bundle
63+ continue
64 result.append(yamlfn)
65 break
66 return result
67@@ -196,13 +200,12 @@
68 result = {'bundle': bundle,
69 'testdir': utils.find_testdir(directory)}
70 lp = vcs.Launchpad()
71- data = lp.infer_bundle(directory)
72- if data:
73- result.update(data)
74- if 'name' not in data:
75- metadata = yaml.safe_load(bundle)
76- # XXX: ambiguous
77- result['name'] = metadata.keys(0)
78+ data = lp.infer_bundle(directory) or {}
79+ result.update(data)
80+ if 'name' not in data:
81+ metadata = yaml.safe_load(open(bundle))
82+ # XXX: ambiguous
83+ result['name'] = metadata.keys()[0]
84 return models.Bundle(**result)
85
86
87@@ -213,12 +216,11 @@
88 lp = vcs.Launchpad()
89 data = lp.infer_charm(directory) or {}
90 testdir = utils.find_testdir(directory)
91- metadata = yaml.safe_load(metadata)
92- if data:
93- data['metadata'] = metadata
94- data['testdir'] = testdir
95- if 'name' not in data:
96- data['name'] = metadata['name']
97+ metadata = yaml.safe_load(open(metadata))
98+ data['metadata'] = metadata
99+ data['testdir'] = testdir
100+ if 'name' not in data:
101+ data['name'] = metadata['name']
102 return models.Charm(**data)
103
104
105
106=== modified file 'bundletester/tester.py'
107--- bundletester/tester.py 2014-06-04 16:33:24 +0000
108+++ bundletester/tester.py 2014-09-07 22:41:37 +0000
109@@ -61,7 +61,8 @@
110
111 suite = spec.SuiteFactory(options, options.testdir)
112 if not suite:
113- raise SystemExit("No Tests Found: Not a bundle or charm.")
114+ sys.stderr.write("No Tests Found\n")
115+ sys.exit(3)
116
117 report = reporter.get_reporter(options.reporter, options.output, options)
118 report.set_suite(suite)
119
120=== modified file 'tests/test_config.py'
121--- tests/test_config.py 2014-05-07 19:11:10 +0000
122+++ tests/test_config.py 2014-09-07 22:41:37 +0000
123@@ -15,8 +15,8 @@
124
125 def test_parser_defaults(self):
126 parser = config.Parser()
127- self.assertFalse(parser.bootstrap)
128- self.assertFalse(parser.reset)
129+ self.assertTrue(parser.bootstrap)
130+ self.assertTrue(parser.reset)
131 self.assertTrue(parser.virtualenv)
132 self.assertEqual(parser.sources, [])
133 self.assertEqual(parser.packages, [])
134@@ -25,8 +25,8 @@
135
136 def test_config_parse(self):
137 parser = config.Parser(locate('sample.yaml'))
138- self.assertFalse(parser.bootstrap)
139- self.assertFalse(parser.reset)
140+ self.assertTrue(parser.bootstrap)
141+ self.assertTrue(parser.reset)
142 self.assertTrue(parser.virtualenv)
143 self.assertEqual(parser.sources, [])
144 self.assertEqual(parser.packages, [])
145
146=== modified file 'tests/test_spec.py'
147--- tests/test_spec.py 2014-05-23 09:46:18 +0000
148+++ tests/test_spec.py 2014-09-07 22:41:37 +0000
149@@ -44,7 +44,7 @@
150 self.assertEqual(test.executable, [os.path.abspath(locate('test02'))])
151 self.assertEqual(test.setup, ['setup02'])
152 self.assertEqual(test.bootstrap, False)
153- self.assertEqual(test.reset, False)
154+ self.assertEqual(test.reset, True)
155
156 def test_spec_init(self):
157 parent = config.Parser()

Subscribers

People subscribed via source and target branches