Merge lp:~joetalbott/utah/add_dev_method into lp:utah

Proposed by Joe Talbott
Status: Merged
Approved by: Javier Collado
Approved revision: 725
Merged at revision: 727
Proposed branch: lp:~joetalbott/utah/add_dev_method
Merge into: lp:utah
Diff against target: 173 lines (+99/-4)
6 files modified
docs/source/development.rst (+1/-1)
utah/client/README (+1/-1)
utah/client/common.py (+14/-0)
utah/client/phoenix.py (+1/-1)
utah/client/runner.py (+4/-1)
utah/client/tests/test_vcs_dev.py (+78/-0)
To merge this branch: bzr merge lp:~joetalbott/utah/add_dev_method
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Max Brustkern (community) Approve
Review via email: mp+131485@code.launchpad.net

Description of the change

Add 'dev' as a fetch_method option.

Copies 'fetch_location' to $TESTSUITE_NAME.

* tests added.
* documentation updated.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks good to me, but you and Javier have worked on these pieces more than I have, so if he has a chance to comment, that would be good.

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for the update Joe.

I'm merging this with an update to `pass.run` to use `dev` as `fetch_method`
since it currently doesn't work with `bzr` as `fetch_method` since it currently
doesn't work with `bzr`.

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

In any case, I'd like to comment that it looks a little bit weird that:

- test cases use VCSHandler.get_revision and code in runner module uses VCSHandler.revision
(even if the former wraps the latter).

- to implement a fake version command a call to a real command (echo DEVELOPMENT) is needed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/source/development.rst'
2--- docs/source/development.rst 2012-10-19 16:44:08 +0000
3+++ docs/source/development.rst 2012-10-25 20:49:18 +0000
4@@ -91,7 +91,7 @@
5 - st4
6 - st5
7
8-The only required fields are ``name``, ``fetch_method`` and ``fetch_location``. ``name`` must correspond to the name of the top-level testsuite directory. ``fetch_method`` should be one of ``bzr``, ``bzr-export``, or ``git``. ``fetch_location`` should be a valid location for the supplied ``fetch_method``. If ``bzr`` is selected as the fetch method then ``fetch_location`` should point to a repository that is a valid testsuite, i.e. has a tslist.run, ts_control (if needed), and test case directories. While ``bzr`` does a ``bzr branch`` in the implementation, ``bzr-export`` does a ``bzr export`` and accepts a bzr location that can point to a sub-directory within a repository that is a valid testsuite.
9+The only required fields are ``name``, ``fetch_method`` and ``fetch_location``. ``name`` must correspond to the name of the top-level testsuite directory. ``fetch_method`` should be one of ``bzr``, ``bzr-export``, ``dev``, or ``git``. ``fetch_location`` should be a valid location for the supplied ``fetch_method``. If ``bzr`` is selected as the fetch method then ``fetch_location`` should point to a repository that is a valid testsuite, i.e. has a tslist.run, ts_control (if needed), and test case directories. While ``bzr`` does a ``bzr branch`` in the implementation, ``bzr-export`` does a ``bzr export`` and accepts a bzr location that can point to a sub-directory within a repository that is a valid testsuite. If ``dev`` is selected as the fetch method then ``fetch_location`` should point to a valid testsuite directory. The utah client will run ``cp -r <fetch_location> <testsuite_name>``. This method is provided to allow testsuite/testcase authors to run the client on a development tree without needing to push changes each time to a repository.
10
11 One caveat to note is that a ``fetch_method`` of ``bzr`` will get the revision information from the local copy of the branched repository but ``bzr-export`` will have a small race condition between the ``get`` and ``revision`` calls since the actual bzr repository must be queried for the revision.
12
13
14=== modified file 'utah/client/README'
15--- utah/client/README 2012-10-17 15:18:53 +0000
16+++ utah/client/README 2012-10-25 20:49:18 +0000
17@@ -25,7 +25,7 @@
18 ######################################################################
19
20 - name: <test suite name>
21- fetch_method: <'bzr', 'bzr-export', or 'git'>
22+ fetch_method: <'bzr', 'bzr-export', 'dev' or 'git'>
23 fetch_location: <repo location>
24 [runlist: <test suite runlist>]
25 [include_tests:
26
27=== modified file 'utah/client/common.py'
28--- utah/client/common.py 2012-10-22 08:15:08 +0000
29+++ utah/client/common.py 2012-10-25 20:49:18 +0000
30@@ -449,3 +449,17 @@
31 )
32
33 self.rev_command = "git rev-parse HEAD"
34+
35+class DevHandler(VCSHandler):
36+ """ Copy from a local directory for development. """
37+
38+ def __init__(self, repo, destination="."):
39+ self.repo = repo
40+ self.destination = destination
41+
42+ self.get_command = "cp -r {} {}".format(
43+ self.repo,
44+ destination,
45+ )
46+
47+ self.rev_command = "echo 'DEVELOPMENT'"
48
49=== modified file 'utah/client/phoenix.py'
50--- utah/client/phoenix.py 2012-10-25 14:29:42 +0000
51+++ utah/client/phoenix.py 2012-10-25 20:49:18 +0000
52@@ -62,7 +62,7 @@
53
54 self.FILE_CONTENT[MASTER_NAME] += " - name: {}\n".format(testsuite)
55 self.FILE_CONTENT[MASTER_NAME] += \
56- " fetch_method: {} # one of 'bzr', 'bzr-export', 'git'\n".format(CHANGEME)
57+ " fetch_method: {} # one of 'bzr', 'bzr-export', 'dev', 'git'\n".format(CHANGEME)
58 self.FILE_CONTENT[MASTER_NAME] += \
59 " fetch_location: {}\n".format(CHANGEME)
60
61
62=== modified file 'utah/client/runner.py'
63--- utah/client/runner.py 2012-10-22 08:15:08 +0000
64+++ utah/client/runner.py 2012-10-25 20:49:18 +0000
65@@ -17,6 +17,7 @@
66 RETURN_CODES,
67 parse_yaml_file,
68 BzrHandler,
69+ DevHandler,
70 GitHandler,
71 )
72
73@@ -50,7 +51,7 @@
74 },
75 'fetch_method': {
76 'type': 'string',
77- 'enum': ['bzr', 'bzr-export', 'git'],
78+ 'enum': ['bzr', 'bzr-export', 'dev', 'git'],
79 'required': True,
80 },
81 'fetch_location': {
82@@ -410,6 +411,8 @@
83 elif fetch_method == 'bzr-export':
84 vcs_handler = BzrHandler(branch=False,
85 repo=fetch_location, destination=name)
86+ elif fetch_method == 'dev':
87+ vcs_handler = DevHandler(repo=fetch_location, destination=name)
88 else:
89 vcs_handler = GitHandler(repo=fetch_location, destination=name)
90
91
92=== added file 'utah/client/tests/test_vcs_dev.py'
93--- utah/client/tests/test_vcs_dev.py 1970-01-01 00:00:00 +0000
94+++ utah/client/tests/test_vcs_dev.py 2012-10-25 20:49:18 +0000
95@@ -0,0 +1,78 @@
96+import os
97+import shutil
98+import unittest
99+
100+from utah.client.common import DevHandler, run_cmd
101+
102+DEV_TEST_REPO = "/tmp/utahdevtest"
103+
104+
105+def setUp():
106+ """
107+ Create a local directory to test on.
108+ """
109+
110+ # should fail if the repo already exists.
111+ os.mkdir(DEV_TEST_REPO)
112+
113+ run_cmd("touch test.py", cwd=DEV_TEST_REPO)
114+
115+
116+def tearDown():
117+ """
118+ Remove the test repo.
119+ """
120+
121+ # We should only ever get here if the repo was created in setUp().
122+ shutil.rmtree(DEV_TEST_REPO)
123+
124+
125+class TestDevHandler(unittest.TestCase):
126+ """
127+ Test the bazaar VCS handler.
128+ """
129+
130+ def test_init(self):
131+ """
132+ Test the initial setup.
133+ """
134+
135+ repo = DEV_TEST_REPO
136+ dev = DevHandler(repo=repo)
137+
138+ self.assertIsNotNone(dev)
139+ self.assertEqual(dev.repo, repo)
140+ self.assertEqual(dev.get_command, "cp -r {} .".format(repo))
141+ self.assertEqual(dev.rev_command, "echo 'DEVELOPMENT'")
142+
143+ def test_dev_get(self):
144+ repo = DEV_TEST_REPO
145+ dest = "utah-dev"
146+ dev = DevHandler(repo=repo, destination=dest)
147+ directory = "/tmp"
148+ path = os.path.join(directory, dest)
149+
150+ self.assertFalse(os.path.exists(path), path)
151+
152+ result = dev.get(directory=directory)
153+ self.assertEqual(result['returncode'], 0)
154+
155+ self.assertTrue(os.path.exists(path), path)
156+ shutil.rmtree(path)
157+
158+ def test_dev_revision(self):
159+ repo = DEV_TEST_REPO
160+ dest = "utah-dev"
161+ dev = DevHandler(repo=repo, destination=dest)
162+ directory = "/tmp"
163+ path = os.path.join(directory, dest)
164+
165+ self.assertFalse(os.path.exists(path))
166+ result = dev.get(directory=directory)
167+ self.assertEqual(result['returncode'], 0)
168+ self.assertTrue(os.path.exists(path))
169+
170+ result = dev.get_revision(directory=path)
171+
172+ shutil.rmtree(path)
173+ self.assertEqual(type(result), str)

Subscribers

People subscribed via source and target branches