-
Notifications
You must be signed in to change notification settings - Fork 11
/
Test.py
61 lines (56 loc) · 2.32 KB
/
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
# -*- coding: utf-8 -*-
# Copyright (c) 2022-2023, Harry Huang
# @ BSD 3-Clause License
import os, sys, json, shutil
from src import ResolveAB
from src import CombineRGBwithA
from src import DecodeTextAsset
from src.utils.AnalyUtils import TestRT
from src.utils.GlobalMethods import print, stacktrace
def __count_files(path):
count = 0
for _, _, files in os.walk(path):
count += len(files)
return count
if __name__ == '__main__':
for i in range(int(sys.argv[1]) if len(sys.argv) > 1 else 1):
try:
print(f"[#{i}] Preparing...", c=0, bg=6)
DIR_UPK = 'test/upk'
DIR_CMB = 'test/cmb'
DIR_DTA = 'test/dta'
shutil.rmtree(DIR_UPK, ignore_errors=True)
shutil.rmtree(DIR_CMB, ignore_errors=True)
shutil.rmtree(DIR_DTA, ignore_errors=True)
print(f"[#{i}] Testing...", c=0, bg=6)
with TestRT('unit_1'):
ResolveAB.main('test/res',
DIR_UPK,
do_del=False,
do_img=True,
do_txt=True,
do_aud=True,
do_spine=False
)
with TestRT('unit_2'):
CombineRGBwithA.main(DIR_UPK,
DIR_CMB,
do_del=False
)
with TestRT('unit_3'):
DecodeTextAsset.main(DIR_UPK,
DIR_DTA,
do_del=False
)
print(f"[#{i}] Analysing...", c=0, bg=6)
if __count_files(DIR_UPK) != 1262:
raise AssertionError("Unpacked files count mismatch")
if __count_files(DIR_CMB) != 139:
raise AssertionError("Combined images count mismatch")
if __count_files(DIR_DTA) != 2:
raise AssertionError("Decoded textassets count mismatch")
print(f"[#{i}] Test success!", c=0, bg=2)
except BaseException as arg:
print(f"[#{i}] Test failed because an error occurred!", c=7, bg=1)
print(stacktrace(), c=3)
json.dump(TestRT.get_avg_time_all(), open('test/rt.json', 'w', encoding='UTF-8'), indent=4)