-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_test.py
More file actions
37 lines (27 loc) · 1.11 KB
/
file_test.py
File metadata and controls
37 lines (27 loc) · 1.11 KB
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
import ldiff_test_common as tcommon
tcommon.init()
work_folder = tcommon.create_random_folder()
source = tcommon.generate_random_file(parent=work_folder)
target = tcommon.generate_random_file(source['filename'], parent=work_folder)
print('source info : ', source)
print('target info :', target)
patch_info = tcommon.generate_patch(source, target, parent_folder=work_folder)
print('diff result : ', patch_info)
if patch_info['code'] != 0:
tcommon.failed(patch_info['code'])
# multi times will do nothing
for i in range(2):
apply_info = tcommon.apply_patch(source, patch_info)
print('apply result : ', apply_info)
if apply_info['code'] != 0:
tcommon.failed(apply_info['code'])
if apply_info['filehash'] != target['filehash']:
tcommon.failed(tcommon.ExitCode.ApplyFailed)
if apply_info['backupsize'] == 0:
tcommon.failed(tcommon.ExitCode.BackupFailed)
# diff again
patch_info = tcommon.generate_patch(source, target, parent_folder=work_folder)
if patch_info['code'] != 2: # 2 -> needless
tcommon.failed(patch_info['code'])
tcommon.remove_dirs([work_folder])
tcommon.success()