-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathftests.py
94 lines (80 loc) · 3.63 KB
/
ftests.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
from os import sys, mkdir, path, system, chdir, remove, rename
from subprocess import check_call
from sys import exit, stdout, stderr
import lzma
import wget
from filecmp import cmp
def test(name, ext, code_page, lenient=False):
print('{}.{}'.format(name, ext))
if path.exists('{}.{}.yaml'.format(name, ext)):
remove('{}.{}.yaml'.format(name, ext))
if path.exists('{}.test.{}'.format(name, ext)):
remove('{}.test.{}'.format(name, ext))
if path.exists('{}.test.{}.yaml'.format(name, ext)):
remove('{}.test.{}.yaml'.format(name, ext))
if lenient:
check_call(['cargo', 'run', '--release', '--', '-p', code_page, '-kvdf',
'{}.{}'.format(name, ext)], stdout=stdout, stderr=stderr)
rename('{}.{}.yaml'.format(name, ext), '{}.fit.{}.yaml'.format(name, ext))
check_call(['cargo', 'run', '--release', '--', '-p', code_page, '-vf',
'{}.fit.{}.yaml'.format(name, ext)], stdout=stdout, stderr=stderr)
source = '{}.fit.{}'.format(name, ext)
else:
source = '{}.{}'.format(name, ext)
check_call(['cargo', 'run', '--release', '--', '-p', code_page, '-kvdo' if ext == 'omwsave' else '-kvd',
source], stdout=stdout, stderr=stderr)
rename('{}.yaml'.format(source), '{}.test.{}.yaml'.format(name, ext))
check_call(['cargo', 'run', '--release', '--', '-p', code_page, '-kvo' if ext == 'omwsave' else '-kv',
'{}.test.{}.yaml'.format(name, ext)], stdout=stdout, stderr=stderr)
if not cmp(source, '{}.test.{}'.format(name, ext)):
exit(1)
cd = path.dirname(path.realpath(__file__))
chdir(cd)
if not path.exists('test_data'):
mkdir('test_data')
chdir('test_data')
if not path.exists('Data Files/Aleanne Armor and Clothes 1+2.esp'):
wget.download('http://www.fullrest.ru/files/ale-clothing-v1-1c/files?fid=2379', 'ale-clothing-v1-1c.7z')
system('7za x ale-clothing-v1-1c.7z')
if not path.exists('Data Files/TravelingMerchants-1.2_1C.esp'):
wget.download('http://www.fullrest.ru/uploads/files/TravelingMerchants-1.2_1C.rar', 'TravelingMerchants-1.2_1C.rar')
system('unrar x -y TravelingMerchants-1.2_1C.rar')
if not path.exists('Data Files/Animal Behaviour.esp'):
wget.download('https://www.fullrest.ru/uploads/files/AnimalRealism.rar', 'AnimalRealism.rar')
system('unrar x -y AnimalRealism.rar')
if not path.exists('Data Files/Morrowind.esm'):
print('Put Morrowind.esm into test_data/Data Files')
exit(1)
if not path.exists('Data Files/Tribunal.esm'):
print('Put Tribunal.esm into test_data/Data Files')
exit(1)
if not path.exists('Data Files/Bloodmoon.esm'):
print('Put Bloodmoon.esm into test_data/Data Files')
exit(1)
if not path.exists('Saves/Quicksave.omwsave'):
with lzma.open('Saves/Quicksave.omwsave.xz') as f:
content = f.read()
with open('Saves/Quicksave.omwsave', 'wb') as f:
f.write(content)
if not path.exists('Saves/164.omwsave'):
with lzma.open('Saves/164.omwsave.xz') as f:
content = f.read()
with open('Saves/164.omwsave', 'wb') as f:
f.write(content)
if not path.exists('Saves/test.omwsave'):
with lzma.open('Saves/test.omwsave.xz') as f:
content = f.read()
with open('Saves/test.omwsave', 'wb') as f:
f.write(content)
test('Saves/test', 'omwsave', 'un')
test('Saves/164', 'omwsave', 'un')
test('Saves/Quicksave', 'omwsave', 'un')
test('Saves/Alchemy0000', 'ess', 'ru')
test('Saves/F0000', 'ess', 'ru')
test('Data Files/Animal Behaviour', 'esp', 'ru', lenient=True)
test('Data Files/Aleanne Armor and Clothes 1+2', 'esp', 'ru')
test('Data Files/TravelingMerchants-1.2_1C', 'esp', 'ru')
test('Data Files/Morrowind', 'esm', 'ru')
test('Data Files/Tribunal', 'esm', 'ru')
test('Data Files/Bloodmoon', 'esm', 'ru')
print('All tests passed.')