Merge lp:~clint-fewbar/pyjuju/add-testrunner into lp:pyjuju

Proposed by Clint Byrum
Status: Needs review
Proposed branch: lp:~clint-fewbar/pyjuju/add-testrunner
Merge into: lp:pyjuju
Diff against target: 29 lines (+25/-0)
1 file modified
misc/devel-tools/test-watcher (+25/-0)
To merge this branch: bzr merge lp:~clint-fewbar/pyjuju/add-testrunner
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+128356@code.launchpad.net

Description of the change

Add a tool to run tests automatically on change

While developing, its quite helpful to have relevant tests run automatically on
any changes. The script proposed here will do exactly that, using iwatch
(so it will only work on Linux systems).

https://codereview.appspot.com/6624055/

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Reviewers: mp+128356_code.launchpad.net,

Message:
Please take a look.

Description:
Add a tool to run tests automatically on change

While developing, its quite helpful to have relevant run automatically
on
any changes. The script proposed here will do exactly that, using iwatch
(so it will only work on Linux systems).

https://code.launchpad.net/~clint-fewbar/juju/add-testrunner/+merge/128356

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   A misc/devel-tools/test-watcher

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: misc/devel-tools/test-watcher
=== added file 'misc/devel-tools/test-watcher'
--- misc/devel-tools/test-watcher 1970-01-01 00:00:00 +0000
+++ misc/devel-tools/test-watcher 2012-10-06 15:46:21 +0000
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Author: Clint Byrum <email address hidden>
+# Run this script in a window and it will continuously monitor the
+# files in the current directory, and run the tests associated with
+# a change whenever they are written. It will also use notify-send
+# to let you know if tests passed or failed.
+#
+if [ -z "$1" ] ; then
+ exec iwatch -r -t .*\.py$ -c "$0 %f" -x .bzr -e modify -v .
+fi
+file=$1
+dir=`dirname $file`
+if [ "`basename $dir`" = "tests" ] ; then
+ testmod=${file//\//.}
+ testmod=${testmod%%.py}
+else
+ testmod=${dir//\//.}
+fi
+testmod=${testmod##..}
+echo $file changed, Running tests ... $testmod
+if eatmydata ./test $testmod ; then
+ exec notify-send -i terminal "$testmod PASSED"
+else
+ exec notify-send -u critical -i terminal "$testmod FAILED"
+fi

Revision history for this message
Jim Baker (jimbaker) wrote :

Some minor issues I observed in trying this useful utility out:

1) eatmydata and iwatch need to be installed in advance; this issue is
more pronounced for eatmydata since it will fail in the test phase. I'm
not certain what the best approach is for this juju package. Perhaps
just test installation of both tools before running, as opposed to
making this a requirement of juju itself.

2) At least on my desktop, the test is always run twice, because iwatch
seems to pick up the file change twice.

3) Users need to remember they have this utility running and not attempt
to run more tests simultaneously, otherwise both test runs will now
fail.

https://codereview.appspot.com/6624055/

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

eat my data should be unesc. the data store for tests is a effectively a
ram store.

On Thu, Oct 25, 2012 at 6:28 PM, Jim Baker <email address hidden> wrote:

> Some minor issues I observed in trying this useful utility out:
>
> 1) eatmydata and iwatch need to be installed in advance; this issue is
> more pronounced for eatmydata since it will fail in the test phase. I'm
> not certain what the best approach is for this juju package. Perhaps
> just test installation of both tools before running, as opposed to
> making this a requirement of juju itself.
>
> 2) At least on my desktop, the test is always run twice, because iwatch
> seems to pick up the file change twice.
>
>
ugh.

> 3) Users need to remember they have this utility running and not attempt
> to run more tests simultaneously, otherwise both test runs will now
> fail.
>
>
perhaps as part of a parellizations effort, or minimally the iwatch test
addr,the get zk test address could return chroot address per test.

i'm curious though what error were encountered as a result of running tests
in this manner, afaics each run should have a separate zk anyways (test zk
enclosure/context manager).

-k

> https://codereview.appspot.com/6624055/
>
> --
> https://code.launchpad.net/~clint-fewbar/juju/add-testrunner/+merge/128356
> You are subscribed to branch lp:juju.
>

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

I still see a small gain in speed (under 10%) over not using eatmydata. I think this is due to tmp file handling and maybe writing .pyc's. If it bothers anybody, I can certainly make it opportunistic.

Anyway, I don't get the double-iwatch events... doesn't make much sense to me at all, and I don't see that here.

Unmerged revisions

593. By Clint Byrum

adding helper tool to run tests on changes of .py files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'misc/devel-tools/test-watcher'
--- misc/devel-tools/test-watcher 1970-01-01 00:00:00 +0000
+++ misc/devel-tools/test-watcher 2012-10-06 15:50:28 +0000
@@ -0,0 +1,25 @@
1#!/bin/bash
2# Author: Clint Byrum <clint.byrum@canonical.com>
3# Run this script in a window and it will continuously monitor the
4# files in the current directory, and run the tests associated with
5# a change whenever they are written. It will also use notify-send
6# to let you know if tests passed or failed.
7#
8if [ -z "$1" ] ; then
9 exec iwatch -r -t .*\.py$ -c "$0 %f" -x .bzr -e modify -v .
10fi
11file=$1
12dir=`dirname $file`
13if [ "`basename $dir`" = "tests" ] ; then
14 testmod=${file//\//.}
15 testmod=${testmod%%.py}
16else
17 testmod=${dir//\//.}
18fi
19testmod=${testmod##..}
20echo $file changed, Running tests ... $testmod
21if eatmydata ./test $testmod ; then
22 exec notify-send -i terminal "$testmod PASSED"
23else
24 exec notify-send -u critical -i terminal "$testmod FAILED"
25fi

Subscribers

People subscribed via source and target branches

to status/vote changes: