This repository has been archived by the owner on Nov 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lndir_test.py
executable file
·152 lines (141 loc) · 4.04 KB
/
lndir_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright(c) 2013 Intel Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
from subprocess import call
import lndir
def make_it(tmpdir):
t = tmpdir.mkdir("sub")
t.chdir()
a_d = t.mkdir('a')
a_d.join('1').write('1')
a_d.join('2').write('2')
a_d.join('3').write('3')
a_d.mkdir('A')
b_d = t.mkdir('b')
b_d.join('1').write('1')
b_d.join('2').mksymlinkto(a_d.join('2'), absolute=0)
b_d.join('3').write('3')
c_d = t.mkdir('c')
c_d.join('1').write('1')
c_d.join('2').write('2')
c_d.join('3').write('3')
c_d.join('A').mksymlinkto(a_d.join('A'), absolute=0)
t.join('d').mksymlinkto('c')
e_d = t.mkdir('e')
e_d.join('1').write('1')
e_d.join('2').write('2')
e_d.join('3').mksymlinkto(a_d.join('3'), absolute=1)
e_d.join('A').mksymlinkto(a_d.join('A'), absolute=1)
return t
def test_create_abs(tmpdir):
src_dir = make_it(tmpdir)
tmpdir.chdir()
dst = tmpdir.mkdir("dest")
lndir.lndir(str(src_dir), str(dst))
call(["tree", "-Ffin"])
call(["diff", "--brief", "-r", str(src_dir), str(dst)])
# ./dest/
# ./dest/a/
# ./dest/a/1 -> /tmp/pytest-60/test_create_abs0/sub/a/1
# ./dest/a/2 -> /tmp/pytest-60/test_create_abs0/sub/a/2
# ./dest/a/3 -> /tmp/pytest-60/test_create_abs0/sub/a/3
# ./dest/a/A/
# ./dest/b/
# ./dest/b/1 -> /tmp/pytest-60/test_create_abs0/sub/b/1
# ./dest/b/2 -> ../a/2
# ./dest/b/3 -> /tmp/pytest-60/test_create_abs0/sub/b/3
# ./dest/c/
# ./dest/c/1 -> /tmp/pytest-60/test_create_abs0/sub/c/1
# ./dest/c/2 -> /tmp/pytest-60/test_create_abs0/sub/c/2
# ./dest/c/3 -> /tmp/pytest-60/test_create_abs0/sub/c/3
# ./dest/c/A -> ../a/A/
# ./dest/d -> c/
# ./dest/e/
# ./dest/e/1 -> /tmp/pytest-60/test_create_abs0/sub/e/1
# ./dest/e/2 -> /tmp/pytest-60/test_create_abs0/sub/e/2
# ./dest/e/3 -> /tmp/pytest-60/test_create_abs0/sub/a/3
# ./dest/e/A -> /tmp/pytest-60/test_create_abs0/sub/a/A/
# ./sub/
# ./sub/a/
# ./sub/a/1
# ./sub/a/2
# ./sub/a/3
# ./sub/a/A/
# ./sub/b/
# ./sub/b/1
# ./sub/b/2 -> ../a/2
# ./sub/b/3
# ./sub/c/
# ./sub/c/1
# ./sub/c/2
# ./sub/c/3
# ./sub/c/A -> ../a/A/
# ./sub/d -> c/
# ./sub/e/
# ./sub/e/1
# ./sub/e/2
# ./sub/e/3 -> /tmp/pytest-60/test_create_abs0/sub/a/3
# ./sub/e/A -> /tmp/pytest-60/test_create_abs0/sub/a/A/
def test_create_rel(tmpdir):
src_dir = make_it(tmpdir)
tmpdir.chdir()
dst = tmpdir.mkdir("dest")
lndir.lndir("../sub", str(dst))
call(["tree", "-Ffin"])
call(["diff", "--brief", "-r", str(src_dir), str(dst)])
# ./dest/
# ./dest/a/
# ./dest/a/1 -> ../../sub/a/1
# ./dest/a/2 -> ../../sub/a/2
# ./dest/a/3 -> ../../sub/a/3
# ./dest/a/A/
# ./dest/b/
# ./dest/b/1 -> ../../sub/b/1
# ./dest/b/2 -> ../a/2
# ./dest/b/3 -> ../../sub/b/3
# ./dest/c/
# ./dest/c/1 -> ../../sub/c/1
# ./dest/c/2 -> ../../sub/c/2
# ./dest/c/3 -> ../../sub/c/3
# ./dest/c/A -> ../a/A/
# ./dest/d -> c/
# ./dest/e/
# ./dest/e/1 -> ../../sub/e/1
# ./dest/e/2 -> ../../sub/e/2
# ./dest/e/3 -> /tmp/pytest-60/test_create_rel0/sub/a/3
# ./dest/e/A -> /tmp/pytest-60/test_create_rel0/sub/a/A/
# ./sub/
# ./sub/a/
# ./sub/a/1
# ./sub/a/2
# ./sub/a/3
# ./sub/a/A/
# ./sub/b/
# ./sub/b/1
# ./sub/b/2 -> ../a/2
# ./sub/b/3
# ./sub/c/
# ./sub/c/1
# ./sub/c/2
# ./sub/c/3
# ./sub/c/A -> ../a/A/
# ./sub/d -> c/
# ./sub/e/
# ./sub/e/1
# ./sub/e/2
# ./sub/e/3 -> /tmp/pytest-60/test_create_rel0/sub/a/3
# ./sub/e/A -> /tmp/pytest-60/test_create_rel0/sub/a/A/