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
=== modified file 'docs/source/development.rst'
--- docs/source/development.rst 2012-10-19 16:44:08 +0000
+++ docs/source/development.rst 2012-10-25 20:49:18 +0000
@@ -91,7 +91,7 @@
91 - st491 - st4
92 - st592 - st5
9393
94The 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. 94The 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.
9595
96One 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.96One 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.
9797
9898
=== modified file 'utah/client/README'
--- utah/client/README 2012-10-17 15:18:53 +0000
+++ utah/client/README 2012-10-25 20:49:18 +0000
@@ -25,7 +25,7 @@
25######################################################################25######################################################################
2626
27- name: <test suite name>27- name: <test suite name>
28 fetch_method: <'bzr', 'bzr-export', or 'git'>28 fetch_method: <'bzr', 'bzr-export', 'dev' or 'git'>
29 fetch_location: <repo location>29 fetch_location: <repo location>
30 [runlist: <test suite runlist>]30 [runlist: <test suite runlist>]
31 [include_tests: 31 [include_tests:
3232
=== modified file 'utah/client/common.py'
--- utah/client/common.py 2012-10-22 08:15:08 +0000
+++ utah/client/common.py 2012-10-25 20:49:18 +0000
@@ -449,3 +449,17 @@
449 )449 )
450450
451 self.rev_command = "git rev-parse HEAD"451 self.rev_command = "git rev-parse HEAD"
452
453class DevHandler(VCSHandler):
454 """ Copy from a local directory for development. """
455
456 def __init__(self, repo, destination="."):
457 self.repo = repo
458 self.destination = destination
459
460 self.get_command = "cp -r {} {}".format(
461 self.repo,
462 destination,
463 )
464
465 self.rev_command = "echo 'DEVELOPMENT'"
452466
=== modified file 'utah/client/phoenix.py'
--- utah/client/phoenix.py 2012-10-25 14:29:42 +0000
+++ utah/client/phoenix.py 2012-10-25 20:49:18 +0000
@@ -62,7 +62,7 @@
6262
63 self.FILE_CONTENT[MASTER_NAME] += " - name: {}\n".format(testsuite)63 self.FILE_CONTENT[MASTER_NAME] += " - name: {}\n".format(testsuite)
64 self.FILE_CONTENT[MASTER_NAME] += \64 self.FILE_CONTENT[MASTER_NAME] += \
65 " fetch_method: {} # one of 'bzr', 'bzr-export', 'git'\n".format(CHANGEME)65 " fetch_method: {} # one of 'bzr', 'bzr-export', 'dev', 'git'\n".format(CHANGEME)
66 self.FILE_CONTENT[MASTER_NAME] += \66 self.FILE_CONTENT[MASTER_NAME] += \
67 " fetch_location: {}\n".format(CHANGEME)67 " fetch_location: {}\n".format(CHANGEME)
6868
6969
=== modified file 'utah/client/runner.py'
--- utah/client/runner.py 2012-10-22 08:15:08 +0000
+++ utah/client/runner.py 2012-10-25 20:49:18 +0000
@@ -17,6 +17,7 @@
17 RETURN_CODES,17 RETURN_CODES,
18 parse_yaml_file,18 parse_yaml_file,
19 BzrHandler,19 BzrHandler,
20 DevHandler,
20 GitHandler,21 GitHandler,
21 )22 )
2223
@@ -50,7 +51,7 @@
50 },51 },
51 'fetch_method': {52 'fetch_method': {
52 'type': 'string',53 'type': 'string',
53 'enum': ['bzr', 'bzr-export', 'git'],54 'enum': ['bzr', 'bzr-export', 'dev', 'git'],
54 'required': True,55 'required': True,
55 },56 },
56 'fetch_location': {57 'fetch_location': {
@@ -410,6 +411,8 @@
410 elif fetch_method == 'bzr-export':411 elif fetch_method == 'bzr-export':
411 vcs_handler = BzrHandler(branch=False,412 vcs_handler = BzrHandler(branch=False,
412 repo=fetch_location, destination=name)413 repo=fetch_location, destination=name)
414 elif fetch_method == 'dev':
415 vcs_handler = DevHandler(repo=fetch_location, destination=name)
413 else:416 else:
414 vcs_handler = GitHandler(repo=fetch_location, destination=name)417 vcs_handler = GitHandler(repo=fetch_location, destination=name)
415418
416419
=== added file 'utah/client/tests/test_vcs_dev.py'
--- utah/client/tests/test_vcs_dev.py 1970-01-01 00:00:00 +0000
+++ utah/client/tests/test_vcs_dev.py 2012-10-25 20:49:18 +0000
@@ -0,0 +1,78 @@
1import os
2import shutil
3import unittest
4
5from utah.client.common import DevHandler, run_cmd
6
7DEV_TEST_REPO = "/tmp/utahdevtest"
8
9
10def setUp():
11 """
12 Create a local directory to test on.
13 """
14
15 # should fail if the repo already exists.
16 os.mkdir(DEV_TEST_REPO)
17
18 run_cmd("touch test.py", cwd=DEV_TEST_REPO)
19
20
21def tearDown():
22 """
23 Remove the test repo.
24 """
25
26 # We should only ever get here if the repo was created in setUp().
27 shutil.rmtree(DEV_TEST_REPO)
28
29
30class TestDevHandler(unittest.TestCase):
31 """
32 Test the bazaar VCS handler.
33 """
34
35 def test_init(self):
36 """
37 Test the initial setup.
38 """
39
40 repo = DEV_TEST_REPO
41 dev = DevHandler(repo=repo)
42
43 self.assertIsNotNone(dev)
44 self.assertEqual(dev.repo, repo)
45 self.assertEqual(dev.get_command, "cp -r {} .".format(repo))
46 self.assertEqual(dev.rev_command, "echo 'DEVELOPMENT'")
47
48 def test_dev_get(self):
49 repo = DEV_TEST_REPO
50 dest = "utah-dev"
51 dev = DevHandler(repo=repo, destination=dest)
52 directory = "/tmp"
53 path = os.path.join(directory, dest)
54
55 self.assertFalse(os.path.exists(path), path)
56
57 result = dev.get(directory=directory)
58 self.assertEqual(result['returncode'], 0)
59
60 self.assertTrue(os.path.exists(path), path)
61 shutil.rmtree(path)
62
63 def test_dev_revision(self):
64 repo = DEV_TEST_REPO
65 dest = "utah-dev"
66 dev = DevHandler(repo=repo, destination=dest)
67 directory = "/tmp"
68 path = os.path.join(directory, dest)
69
70 self.assertFalse(os.path.exists(path))
71 result = dev.get(directory=directory)
72 self.assertEqual(result['returncode'], 0)
73 self.assertTrue(os.path.exists(path))
74
75 result = dev.get_revision(directory=path)
76
77 shutil.rmtree(path)
78 self.assertEqual(type(result), str)

Subscribers

People subscribed via source and target branches