Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
13316ac5
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
13316ac5
编写于
5月 28, 2019
作者:
E
Ebrahim Byagowi
提交者:
GitHub
5月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[test] minor style improve
上级
d64fb9db
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
19 deletion
+19
-19
test/subset/run-tests.py
test/subset/run-tests.py
+19
-19
未找到文件。
test/subset/run-tests.py
浏览文件 @
13316ac5
#!/usr/bin/env python
# Runs a subsetting test suite. Compares the results of subsetting via harfbuz
# Runs a subsetting test suite. Compares the results of subsetting via harfbuz
z
# to subsetting via fonttools.
from
__future__
import
print_function
,
division
,
absolute_import
...
...
@@ -16,18 +16,18 @@ import tempfile
from
subset_test_suite
import
SubsetTestSuite
# https://stackoverflow.com/a/377028
def
which
(
program
):
def
is_exe
(
fpath
):
return
os
.
path
.
isfile
(
fpath
)
and
os
.
access
(
fpath
,
os
.
X_OK
)
def
which
(
program
):
def
is_exe
(
fpath
):
return
os
.
path
.
isfile
(
fpath
)
and
os
.
access
(
fpath
,
os
.
X_OK
)
fpath
,
_
=
os
.
path
.
split
(
program
)
fpath
,
_
=
os
.
path
.
split
(
program
)
if
fpath
:
if
is_exe
(
program
):
if
is_exe
(
program
):
return
program
else
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
exe_file
=
os
.
path
.
join
(
path
,
program
)
if
is_exe
(
exe_file
):
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
exe_file
=
os
.
path
.
join
(
path
,
program
)
if
is_exe
(
exe_file
):
return
exe_file
return
None
...
...
@@ -36,7 +36,7 @@ fonttools = which ("fonttools")
ots_sanitize
=
which
(
"ots-sanitize"
)
if
not
fonttools
:
print
(
"fonttools is not present, skipping test."
)
print
(
"fonttools is not present, skipping test."
)
sys
.
exit
(
77
)
def
cmd
(
command
):
...
...
@@ -50,7 +50,7 @@ def read_binary (file_path):
with
open
(
file_path
,
'rb'
)
as
f
:
return
f
.
read
()
def
fail_test
(
test
,
cli_args
,
message
):
def
fail_test
(
test
,
cli_args
,
message
):
print
(
'ERROR: %s'
%
message
)
print
(
'Test State:'
)
print
(
' test.font_path %s'
%
os
.
path
.
abspath
(
test
.
font_path
))
...
...
@@ -61,8 +61,8 @@ def fail_test(test, cli_args, message):
print
(
' expected_file %s'
%
os
.
path
.
abspath
(
expected_file
))
return
1
def
run_test
(
test
,
should_check_ots
):
out_file
=
os
.
path
.
join
(
tempfile
.
mkdtemp
(),
test
.
get_font_name
()
+
'-subset'
+
test
.
get_font_extension
())
def
run_test
(
test
,
should_check_ots
):
out_file
=
os
.
path
.
join
(
tempfile
.
mkdtemp
(),
test
.
get_font_name
()
+
'-subset'
+
test
.
get_font_extension
())
cli_args
=
[
hb_subset
,
"--font-file="
+
test
.
font_path
,
"--output-file="
+
out_file
,
...
...
@@ -76,11 +76,11 @@ def run_test(test, should_check_ots):
return
fail_test
(
test
,
cli_args
,
"%s returned %d"
%
(
' '
.
join
(
cli_args
),
return_code
))
expected_ttx
,
return_code
=
run_ttx
(
os
.
path
.
join
(
test_suite
.
get_output_directory
(),
test
.
get_font_name
()))
test
.
get_font_name
()))
if
return_code
:
return
fail_test
(
test
,
cli_args
,
"ttx (expected) returned %d"
%
(
return_code
))
actual_ttx
,
return_code
=
run_ttx
(
out_file
)
actual_ttx
,
return_code
=
run_ttx
(
out_file
)
if
return_code
:
return
fail_test
(
test
,
cli_args
,
"ttx (actual) returned %d"
%
(
return_code
))
...
...
@@ -92,7 +92,7 @@ def run_test(test, should_check_ots):
for
line
in
unified_diff
(
expected_ttx
.
splitlines
(
1
),
actual_ttx
.
splitlines
(
1
)):
sys
.
stdout
.
write
(
line
)
sys
.
stdout
.
flush
()
return
fail_test
(
test
,
cli_args
,
'ttx for expected and actual does not match.'
)
return
fail_test
(
test
,
cli_args
,
'ttx for expected and actual does not match.'
)
if
should_check_ots
:
print
(
"Checking output with ots-sanitize."
)
...
...
@@ -103,7 +103,7 @@ def run_test(test, should_check_ots):
def
run_ttx
(
file
):
print
(
"fonttools ttx %s"
%
file
)
return
cmd
([
fonttools
,
"ttx"
,
"-q"
,
"-o-"
,
file
])
return
cmd
([
fonttools
,
"ttx"
,
"-q"
,
"-o-"
,
file
])
def
strip_check_sum
(
ttx_string
):
return
re
.
sub
(
'checkSumAdjustment value=["]0x([0-9a-fA-F])+["]'
,
...
...
@@ -124,7 +124,7 @@ def check_ots (path):
return
True
args
=
sys
.
argv
[
1
:]
if
not
args
or
sys
.
argv
[
1
].
find
(
'hb-subset'
)
==
-
1
or
not
os
.
path
.
exists
(
sys
.
argv
[
1
]):
if
not
args
or
sys
.
argv
[
1
].
find
(
'hb-subset'
)
==
-
1
or
not
os
.
path
.
exists
(
sys
.
argv
[
1
]):
print
(
"First argument does not seem to point to usable hb-subset."
)
sys
.
exit
(
1
)
hb_subset
,
args
=
args
[
0
],
args
[
1
:]
...
...
@@ -139,7 +139,7 @@ fails = 0
for
path
in
args
:
with
io
.
open
(
path
,
mode
=
"r"
,
encoding
=
"utf-8"
)
as
f
:
print
(
"Running tests in "
+
path
)
test_suite
=
SubsetTestSuite
(
path
,
f
.
read
())
test_suite
=
SubsetTestSuite
(
path
,
f
.
read
())
for
test
in
test_suite
.
tests
():
fails
+=
run_test
(
test
,
has_ots
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录