comparison tests/test-tools.t @ 23860:bead0c7b4f68

tests: add 'f' tool for cross platform file operations in the tests This tool is like the collection of tools found in a unix environment but are cross platform and stable and suitable for our needs in the test suite. The main reason it is "needed" now is for hexdump of revision branch cache to keep an eye on how it changes and make sure the format is stable. It is a very generic tool that can end up being used a lot in tests, so I gave it very generic name.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 14 Jan 2015 01:15:26 +0100
parents
children 049a9e3a078d
comparison
equal deleted inserted replaced
23859:661b246bf1c4 23860:bead0c7b4f68
1 Tests of the file helper tool
2
3 $ f -h
4 Usage: f [options] [filenames]
5
6 Options:
7 -h, --help show this help message and exit
8 -t, --type show file type (file or directory)
9 -m, --mode show file mode
10 -l, --links show number of links
11 -s, --size show size of file
12 -n NEWER, --newer=NEWER
13 check if file is newer (or same)
14 -r, --recurse recurse into directories
15 -S, --sha1 show sha1 hash of the content
16 -M, --md5 show md5 hash of the content
17 -D, --dump dump file content
18 -H, --hexdump hexdump file content
19 -B BYTES, --bytes=BYTES
20 number of characters to dump
21 -L LINES, --lines=LINES
22 number of lines to dump
23 -q, --quiet no default output
24
25 $ mkdir dir
26 $ cd dir
27
28 $ f --size
29 size=0
30
31 $ echo hello | f --md5 --size
32 size=6, md5=b1946ac92492d2347c6235b4d2611184
33
34 $ f foo
35 foo: file not found
36
37 $ echo foo > foo
38 $ f foo
39 foo:
40
41 $ f foo --mode
42 foo: mode=644
43
44 $ seq 10 > bar
45 $ chmod +x bar
46 $ f bar --newer foo --mode --type --size --dump --links --bytes 7
47 bar: file, size=21, mode=755, links=1, newer than foo
48 >>>
49 1
50 2
51 3
52 4
53 <<< no trailing newline
54
55 $ ln bar baz
56 $ f bar -n baz -l --hexdump -t --sha1 --lines=9 -B 20
57 bar: file, links=2, newer than baz, sha1=612ca68d0305c821750a
58 0000: 31 0a 32 0a 33 0a 34 0a 35 0a 36 0a 37 0a 38 0a |1.2.3.4.5.6.7.8.|
59 0010: 39 0a |9.|
60
61 $ ln -s yadda l
62 $ f . --recurse -MStmsB4
63 .: directory with 4 files, size=120, mode=755
64 ./bar: file, size=21, mode=755, md5=3b03, sha1=612c
65 ./baz: file, size=21, mode=755, md5=3b03, sha1=612c
66 ./foo: file, size=4, mode=644, md5=d3b0, sha1=f1d2
67 ./l: link, size=5, mode=777, md5=2faa, sha1=af93
68
69 $ f --quiet bar -DL 3
70 1
71 2
72 3
73
74 $ cd ..
75
76 $ f -qr dir -HB 17
77 dir: directory with 4 files
78 dir/bar:
79 0000: 31 0a 32 0a 33 0a 34 0a 35 0a 36 0a 37 0a 38 0a |1.2.3.4.5.6.7.8.|
80 0010: 39 |9|
81 dir/baz:
82 0000: 31 0a 32 0a 33 0a 34 0a 35 0a 36 0a 37 0a 38 0a |1.2.3.4.5.6.7.8.|
83 0010: 39 |9|
84 dir/foo:
85 0000: 66 6f 6f 0a |foo.|
86 dir/l:
87 0000: 79 61 64 64 61 |yadda|