Under certain circumstances, the test suite can misconstruct the 'actual' tree
in an expected<->actual comparison. Specifically, it can build a node as a file
when it should have built it as a directory.
For example:
In r7825 (resolving issue #1609) we added a new test in schedule_tests.py,
'status_replaced_directory'. That test passes an expected_status tree to
run_and_verify_status(). Inside run_and_verify_status(), we do
output, errput = main.run_svn (None, 'status', '-v', '-u', '-q', wc_dir_name)
mytree = tree.build_tree_from_status (output)
It happens that wc_dir_name is a greek tree in which 'A' has been 'R'eplaced, as in:
$ svn rm wc_dir_name/A
$ rm -rf wc_dir_name/A
$ svn ci -m "Commit deletion of A" wc_dir_name
$ svn mkdir wc_dir_name/A
The 'output' passed to build_tree_from_status() therefore looks like this:
$ svn st -v -u -q wc_dir_name
R 0 ? ? wc_dir_name/A
1 1 jrandom wc_dir_name/iota
1 1 jrandom wc_dir_name
Status against revision: 2
$
The returned tree ought to include a node for 'A' as a directory, since that's
what it is:
$ ls -l wc_dir_name
total 8
drwxr-xr-x 3 kfogel kfogel 4096 Nov 21 07:03 A/
-rw-r--r-- 1 kfogel kfogel 24 Nov 21 07:03 iota
$ svn info working_copies/schedule_tests-22/A
Path: working_copies/schedule_tests-22/A
URL: file:///blah/blah/blah
Revision: 0
Node Kind: directory
Schedule: replace
$
But it does not. For some reason, it builds 'A' as a file, resulting in this
test failure:
=============================================================
Expected A and actual A are different!
=============================================================
EXPECTED NODE TO BE:
=============================================================
* Node name: A
Path: working_copies/schedule_tests-22/A
Contents: None
Properties: {}
Attributes: {'status': 'R ', 'repos_rev': '2', 'wc_rev': '0'}
Children: 4
=============================================================
ACTUAL NODE FOUND:
=============================================================
* Node name: A
Path: working_copies/schedule_tests-22/A
Contents: None
Properties: {}
Attributes: {'status': 'R ', 'repos_rev': '2', 'wc_rev': '0'}
Children: is a file.
Unequal Types: one Node is a file, the other is a directory
Unequal at node schedule_tests-22
Unequal at node working_copies
(Golly, I hope IssueZilla doesn't wrap that in an ugly way...)
I believe the problem is in tree.py:
build_tree_from_status()
==> calls create_from_path()
==> calls add_elements_as_path()
==> calls SVNTreeNode() constructor with children=None
Since children=None, the node starts out life as a file, not a dir.
I don't see any point along the call chain where someone could indicate that
this node is a directory, even if they knew it, which they don't. It's not
given in the status output, and no one's calling os.path.isdir() to discover it.
How in the heck have we gotten this far with such a bug? :-)