'bzr rm' leaves directories behind?
Robert Collins
robertc at robertcollins.net
Tue Jun 26 23:23:44 BST 2007
On Mon, 2007-06-25 at 19:49 +0200, Marius Kruger wrote:
> I find it annoying to quote every single parameter for black box
> tests.
> I think it should ALWAYS be splitting.
> In the above case, the test should rather be
> "bzr rm file\ with\ spaces" or
> "bzr rm 'file with spaces'" or
> 'bzr rm "file with spaces"'
> which my `run_bzr_captured` is catering for since it uses shlex,
> this is constent with how it is used from the commandline.
> My `run_bzr_captured` only splits if you give it a single string,
> so it doesn't break existing tests.
The pros I see for explicit lists are:
- the underlying interface we are testing is argv (a list of strings)
based. Its clearer to use an interface directly when it can be done so
easily - and [''] is pretty easy to type and put in. The underlying
interface to make a new process on unix is also an argv rather than a
string-which-gets-split.
- all our internal library interfaces work with lists of paths, or
lists of fileids, or lists of revision_ids etc. Most of the parameters
to blackbox tests are filepaths and passing them in in the same way is
consistent and requires less thought and manipulation when converting
tests to test lower down or higher up.
- if you don't split/join argv you are immune to double-splitting bugs
which plague ambiguous interfaces.
- lists are structured, they are more amenable to manipulation from
within python, so its possible to e.g. have a test that takes 3 paths
and throws all permutations at the command to be sure the UI doesn't do
anything daft with them.
The cons I see for explicit lists are:
- somewhat more typing (maybe 10% ?)
You can invert these to get the cons/pros for using strings to represent
commands.
I recognise that some folk may really prefer using strings, and I won't
try to prevent us having a interface for testing that they can enjoy;
however magic interfaces are a bit of a bad smell, as are uses of
isinstance that are not needed, so I'd *really* prefer that it be a
different interface, not magic deep in the core: lets keep the core
clean and focused, and that to me means keeping it aligned with the
underlying operation that is occuring.
Add to this that I think we are nearly ready to split out the command
parsing tests from the command logic tests, which would really remove
the need to string split ever as you could talk straight to the command
class, and I hope it all makes sense.
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070627/68d615b9/attachment.pgp
More information about the bazaar
mailing list