diff --git a/suite2cases/tidy.json b/suite2cases/tidy.json new file mode 100644 index 0000000000000000000000000000000000000000..88c662d36a1e30a9440d09e3a8f044da95e21715 --- /dev/null +++ b/suite2cases/tidy.json @@ -0,0 +1,53 @@ +{ + "path": "$OET_PATH/testcases/cli-test/tidy", + "cases": [ + { + "name": "oe_test_tidy_file_manipulation" + }, + { + "name": "oe_test_tidy_processing_directives" + }, + { + "name": "oe_test_tidy_character_encodings" + }, + { + "name": "oe_test_tidy_miscellaneous" + }, + { + "name": "oe_test_tidy_xml" + }, + { + "name": "oe_test_tidy_document_display_options" + }, + { + "name": "oe_test_tidy_document_in_and_out_options" + }, + { + "name": "oe_test_tidy_file_input-output_options" + }, + { + "name": "oe_test_tidy_diagnostics_options" + }, + { + "name": "oe_test_tidy_encoding_options" + }, + { + "name": "oe_test_tidy_cleanup_options" + }, + { + "name": "oe_test_tidy_entities_options" + }, + { + "name": "oe_test_tidy_repair_options" + }, + { + "name": "oe_test_tidy_transformation_options" + }, + { + "name": "oe_test_tidy_teaching_tidy_options" + }, + { + "name": "oe_test_tidy_pretty_print_options" + } + ] +} diff --git a/testcases/cli-test/tidy/oe_test_tidy_character_encodings.sh b/testcases/cli-test/tidy/oe_test_tidy_character_encodings.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5a141a5329b672a082e468a11c100b6cc198986 --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_character_encodings.sh @@ -0,0 +1,107 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/4 +# @License : Mulan PSL v2 +# @Desc : Test tidy character encodings +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + DNF_INSTALL uchardet + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # -raw + # 不转换为实体而直接输出 + # For raw, Tidy will output values above 127 without translating them into entities. + echo '¥' | tidy -raw | grep '¥' + CHECK_RESULT $? 1 0 "Failed to use option: -raw" + # -ascii + # 用 ISO-8859-1 作为输入编码,用 US-ASCII 输出 + # 用 US-ASCII 输出,其实就是以实体标签名的形式进行输出 + # 通过 iconv 将字符转换为 ISO-8859-1 编码格式,再通过 tidy 处理 + echo '½' | iconv -f UTF-8 -t ISO-8859-1 | tidy -ascii | grep '½' + CHECK_RESULT $? 0 0 "Failed to use option: -ascii" + # -latin0 + # 用 ISO-8859-15 作为输入编码, US-ASCII 作为输出 + echo 'Š' | iconv -f UTF-8 -t ISO-8859-15 | tidy -latin0 | grep 'Š' + CHECK_RESULT $? 0 0 "Failed to use option: -latin0" + # -latin1 + # 将 ISO-8859-1 作为输入和输出编码 + # 使用 uchardet 对输出结果的编码格式进行检查,ISO-8859-1 会被检出 WINDOWS-1252 的结果 + echo '½' | iconv -f UTF-8 -t ISO-8859-1 | tidy -f /dev/null -latin1 | grep '' -A 1 --text | uchardet | grep 'WINDOWS-1252' + CHECK_RESULT $? 0 0 "Failed to use option: -latin1" + # -iso2022 + # 将 ISO-2022 作为输入和输出编码 + # 选用遵从 ISO 2022 规范的 ISO-2022-KR 作为编码 + echo '도깨비' | iconv -t ISO-2022-KR | tidy -iso2022 -f /dev/null | grep '' -A 1 | uchardet | grep 'ISO-2022-KR' + CHECK_RESULT $? 0 0 "Failed to use option: -iso2022" + # -utf8 + # 将 UTF-8 作为输入和输出编码 + echo 'ε' | iconv -t UTF-8 | tidy -utf8 -f /dev/null | grep '' -A 1 | uchardet | grep 'UTF-8' + CHECK_RESULT $? 0 0 "Failed to use option: -utf8" + # -mac + # 用 MacRoman 作为输入编码, US-ASCII 作为输出编码 + echo '¶' | iconv -t MAC-CENTRALEUROPE | tidy -mac | grep '¶' + CHECK_RESULT $? 0 0 "Failed to use option: -mac" + # -win1252 + # 用 Windows-1252 作为输入编码, US-ASCII 作为输出编码 + echo '§' | iconv -f UTF-8 -t WINDOWS-1252 | tidy -win1252 | grep '' -A 1 | grep '§' + CHECK_RESULT $? 0 0 "Failed to use option: -win1252" + # -ibm858 + # 用 IBM-858 作为输入编码, US-ASCII 作为输出编码 + echo '║' | iconv -f UTF-8 -t IBM858 | tidy -ibm858 | grep '' -A 1 | grep '║' + CHECK_RESULT $? 0 0 "Failed to use option: -ibm858" + # -utf16le + # 用 UTF-16LE 作为输入和输出编码 + echo 'Σ' | iconv -f UTF-8 -t UTF-16LE | tidy -utf16le -o ./tidied.html + encguess ./tidied.html | grep 'UTF-16LE' + CHECK_RESULT $? 0 0 "Failed to use option: -utf16le" + # -utf16be + # 用 UTF-16BE 作为输入和输出编码 + echo 'Σ' | iconv -f UTF-8 -t UTF-16BE | tidy -utf16be -o ./tidied.html + encguess ./tidied.html | grep 'UTF-16BE' + CHECK_RESULT $? 0 0 "Failed to use option: -utf16be" + # -utf16 + # 用 UTF-16 作为输入和输出编码 + echo 'Σ' | iconv -f UTF-8 -t UTF-16 | tidy -utf16 -o ./tidied.html + encguess ./tidied.html | grep 'UTF-16' + CHECK_RESULT $? 0 0 "Failed to use option: -utf16" + # -big5 + # 用 BIG-5 作为输入和输出编码 + # 使用 uchardet 检出结果为 WINDOWS-1252 + echo '好' | iconv -f UTF-8 -t BIG-5 | tidy -big5 | uchardet | grep 'WINDOWS-1252' + CHECK_RESULT $? 0 0 "Failed to use option: -big5" + # -shiftjis + # 用 SHITFT-JIS 作为输入和输出编码 + # 使用 uchardet 检出结果为 WINDOWS-1252 + echo 'ヲ' | iconv -f UTF-8 -t SHIFT-JIS | tidy -shiftjis | uchardet | grep 'WINDOWS-1252' + CHECK_RESULT $? 0 0 "Failed to use option: -shiftjis" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidied.html + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_cleanup_options.sh b/testcases/cli-test/tidy/oe_test_tidy_cleanup_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ef2dad3f534b602421652018120d34ba0f3e3dc --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_cleanup_options.sh @@ -0,0 +1,111 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/8 +# @License : Mulan PSL v2 +# @Desc : Test tidy clean options +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --bare + # strip out smart quotes and em dashes, etc. + echo '—' | tidy --bare true | grep '-' + CHECK_RESULT $? 0 0 "Failed to use option: --bare" + echo 'bare: true' >./tidyrc + echo '—' | tidy -config ./tidyrc | grep '-' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: bare" + # --clean + # 清理已弃用的标签 + echo '
hello
' | tidy --clean true | grep 'text-align: center' + CHECK_RESULT $? 0 0 "Failed to use option: --clean" + echo 'clean: true' >./tidyrc + echo '
hello
' | tidy -config ./tidyrc | grep 'text-align: center' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: clean" + # --drop-empty-elements + # 移除空元素,默认开启 + echo '

' | tidy --drop-empty-elements false | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option: --drop-empty-elements" + echo 'drop-empty-elements: false' >./tidyrc + echo '

' | tidy -config ./tidyrc | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: drop-empty-elements" + # --drop-empty-paras + # 移除空段落(

标签),默认开启 + echo '

' | tidy --drop-empty-paras false | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option: --drop-empty-paras" + echo 'drop-empty-paras: false' >./tidyrc + echo '

' | tidy -config ./tidyrc | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: drop-empty-paras" + # --drop-proprietary-attributes + # 丢弃专有特性 + echo '

hi

' | tidy --drop-proprietary-attributes true | grep 'what' + CHECK_RESULT $? 1 0 "Failed to use option: --drop-proprietary-attributes" + echo 'drop-proprietary-attributes: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'what' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: drop-proprietary-attributes" + # --gdoc + # 对比清理前后,文件的代码量,判断清理的效果 + source_code='

Hello World

' + # 原始 gdoc 文本的代码数量 + gdoc_char_num=$(echo "${source_code}" | wc -m) + # 经过 tidy 后的代码数量 + tidied_char_num=$(echo "${source_code}" | tidy --gdoc true | wc -m) + [[ $tidied_char_num -lt $gdoc_char_num ]] + CHECK_RESULT $? 0 0 "Failed to use option: --gdoc" + echo 'gdoc: true' >./tidyrc + tidied_char_num=$(echo "${source_code}" | tidy -config ./tidyrc | wc -m) + [[ $tidied_char_num -lt $gdoc_char_num ]] + CHECK_RESULT $? 0 0 "Failed to use option in configuration: gdoc" + # --logical-emphasis + # 将 标签替换为 标签 + echo 'hi' | tidy --logical-emphasis true | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --logical-emphasis" + echo 'logical-emphasis: true' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: logical-emphasis" + # --merge-divs + # 与 -clean 搭配使用,默认开启,用于清理嵌套的
标签 + echo '
hi
' | tidy -clean --merge-divs no | grep -c '/div' | grep '2' + CHECK_RESULT $? 0 0 "Failed to use option: --merge-divs" + echo 'merge-divs: no' >./tidyrc + echo '
hi
' | tidy -config ./tidyrc | grep -c '/div' | grep '2' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: merge-divs" + # -merge-spans + # 与 -clean 搭配使用,默认开启,用于清理嵌套的 标签 + echo 'hi' | tidy -clean --merge-spans false | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --merge-spans" + echo 'merge-spans: false' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: merge-spans" + # --word-2000 + # 无法使用 + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_diagnostics_options.sh b/testcases/cli-test/tidy/oe_test_tidy_diagnostics_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..128eb0edd57be9c20c4231314a59c49f4ba6e088 --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_diagnostics_options.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/7 +# @License : Mulan PSL v2 +# @Desc : Test iftop text mode +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --accessibility-check + # 可访问性检查 + # 在等级一中,有一项是对图片是否包含 alt 信息的检查 + echo '' | tidy --accessibility-check 1 2>&1 | grep " missing 'alt' text" + CHECK_RESULT $? 0 0 "Failed to use option: --accessibility-check" + echo 'accessibility-check: 1' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep " missing 'alt' text" + CHECK_RESULT $? 0 0 "Failed to use option in configuration: accessibility-check" + # --force-output + # 遇到错误时强制输出 + echo '' | tidy --force-output true | grep 'body' + CHECK_RESULT $? 0 0 "Failed to use option: --force-output" + echo 'force-output: true' >./tidyrc + echo '' | tidy -config ./tidyrc | grep 'body' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: force-output" + # --show-meta-change + # 当 Tidy 改变文档所用的字符集时输出提示 + echo '' | tidy --show-meta-change true 2>&1 | grep 'charset' | grep 'replaced' + CHECK_RESULT $? 0 0 "Failed to use option: --show-meta-change" + echo 'show-meta-change: true' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep 'charset' | grep 'replaced' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: show-meta-change" + # --warn-proprietary-attributes + # 指定是否对专有特性进行警告,默认开启 + echo '

hi

' | tidy --warn-proprietary-attributes false | grep 'Warning' | grep 'what' + CHECK_RESULT $? 1 0 "Failed to use option: --warn-proprietary-attributes" + echo 'warn-proprietary-attributes: false' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'Warning' | grep 'what' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: warn-proprietary-attributes" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_document_display_options.sh b/testcases/cli-test/tidy/oe_test_tidy_document_display_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..00ce4c240ae676d353239d06e0619bb571c5b887 --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_document_display_options.sh @@ -0,0 +1,123 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/5 +# @License : Mulan PSL v2 +# @Desc : Test iftop text mode +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --gnu-emacs + # 默认报错格式 + # line column - (Error|Warning): + # gnu-emacs 开启后的报错格式 + # ::: (Error|Warning): + echo '

hi' >./sample.html + tidy --gnu-emacs true ./sample.html 2>&1 | grep 'sample.html' | grep 'Warning' + CHECK_RESULT $? 0 0 "Failed to use option: --gnu-emacs" + echo 'gnu-emacs: true' >./tidyrc + tidy -config ./tidyrc sample.html 2>&1 | grep 'sample.html' | grep 'Warning' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: gnu-emacs" + # --show-filename + # 在报告中展示文件名 + tidy --show-filename true sample.html 2>&1 | grep 'sample.html' + CHECK_RESULT $? 0 0 "Failed to use option: show-filename" + echo 'show-filename: true' >./tidyrc + tidy -config ./tidyrc sample.html 2>&1 | grep 'sample.html' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: show-filename" + # --markup + # 指定是否要生成格式化后的标记代码,若检测的目标中存在错误,则不生成 + # 该选项默认开启,则在此测试中,检验其关闭后的效果,即不输出处理后的结果 + echo 'hi' | tidy --markup false | grep 'hi' + CHECK_RESULT $? 1 0 "Failed to use option: --markup" + echo 'markup: false' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: markup" + # --mute + # 根据 ID 关闭特定错误信息的提示 + echo '' | tidy --mute 'MISSING_TITLE_ELEMENT' 2>&1 | grep "missing 'title' element" + CHECK_RESULT $? 1 0 "Failed to use option: --mute" + echo 'mute: MISSING_TITLE_ELEMENT' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep "missing 'title' element" + CHECK_RESULT $? 1 0 "Failed to use option in configuration: mute" + # --mute-id + # 指定是否要在输出的错误提示中包含其对应的 ID + echo '' | tidy --mute-id true 2>&1 | grep 'title' | grep 'MISSING_TITLE_ELEMENT' + CHECK_RESULT $? 0 0 "Failed to use option: --mute-id" + echo 'mute-id: true' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep 'title' | grep 'MISSING_TITLE_ELEMENT' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: mute-id" + # --quiet + # 对非文档内容的输出做限制,只输出错误和警告,即不输出 Info 等信息 + echo '' | tidy --quiet true 2>&1 | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option:--quiet" + echo 'quiet: true' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: quiet" + # --show-body-only + # 指定是否只输出 body 标签内的内容 + echo '123

hi

' | tidy --show-body-only yes | grep '' + CHECK_RESULT $? 1 0 "Failed to use option: --show-body-only" + echo 'show-body-only: yes' >./tidyrc + echo '123

hi

' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: show-body-only" + # --show-errors + # 指定输出几个错误 + echo 'hi' | tidy --show-errors 0 | grep 'Error: ' + CHECK_RESULT $? 1 0 "Failed to use option: --show-errors" + echo 'show-errors: 0' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'Error: ' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: show-errors" + # --show-filename + # 输出文件名 + echo '

' >./sample.html + tidy --show-filename true ./sample.html 2>&1 | grep 'sample.html' + CHECK_RESULT $? 0 0 "Failed to use option: --show-filename" + echo 'show-filename: true' >./tidyrc + tidy -config ./tidyrc ./sample.html 2>&1 | grep 'sample.html' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: show-filename" + # --show-info + # 指定是否输出 Info 级别的信息,默认开启 + echo '' | tidy --show-info false 2>&1 | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option: --show-info" + echo 'show-info: false' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: show-info" + # --show-warnings + # 指定是否输出警告信息 + echo '' | tidy --show-warnings false 2>&1 | grep 'Warning' + CHECK_RESULT $? 1 0 "Failed to use option: --show-warnings" + echo 'show-warnings: false' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep 'Warning' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: show-warnings" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_document_in_and_out_options.sh b/testcases/cli-test/tidy/oe_test_tidy_document_in_and_out_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..0df016b1cedd8995719a692a2daebb3b86af7630 --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_document_in_and_out_options.sh @@ -0,0 +1,96 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/6 +# @License : Mulan PSL v2 +# @Desc : Test tidy document in and output +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --add-meta-charset + # 添加一个内容为文档的编码格式的 meta 标签 + echo '' | tidy --add-meta-charset yes | grep '' + CHECK_RESULT $? 0 0 "Failed to use option: --add-meta-charset" + echo 'add-meta-charset: yes' >./tidyrc + echo '' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: add-meta-charset" + # --add-xml-decl + # 添加 XML 文档声明 + echo '' | tidy -asxml --add-xml-decl true | grep 'xml version' + CHECK_RESULT $? 0 0 "Failed to use option: --add-xml-decl" + echo 'add-xml-decl: true' >./tidyrc + echo '' | tidy -asxml -config ./tidyrc | grep 'xml version' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: add-xml-decl" + # --add-xml-space + # 给诸如
' | tidy -asxml --add-xml-space true | grep '' | tidy -asxml -config ./tidyrc | grep '

Hello World

' + # 原始 gdoc 文本的代码数量 + gdoc_char_num=$(echo "${source_code}" | wc -m) + # 经过 tidy 后的代码数量 + tidied_char_num=$(echo "${source_code}" | tidy -g | wc -m) + [[ $tidied_char_num -lt $gdoc_char_num ]] + CHECK_RESULT $? 0 0 "Failed to use option: -g" + tidied_char_num=$(echo "${source_code}" | tidy -gdoc | wc -m) + [[ $tidied_char_num -lt $gdoc_char_num ]] + CHECK_RESULT $? 0 0 "Failed to use option: -gdoc" + echo 'gdoc: yes' >./tidyrc + tidied_char_num=$(echo "${source_code}" | tidy -config ./tidyrc | wc -m) + [[ $tidied_char_num -lt $gdoc_char_num ]] + CHECK_RESULT $? 0 0 "Failed to use option in configuration: gdoc" + # -n, -numeric, numeric-entities + # 是否以数字而非名字输出 HTML 实体 + echo ' ' | tidy -n | grep ' ' + CHECK_RESULT $? 0 0 "Failed to use option: -n" + echo ' ' | tidy -numeric | grep ' ' + CHECK_RESULT $? 0 0 "Failed to use option: -numeric" + echo 'numeric-entities: yes' >./tidyrc + echo ' ' | tidy -config ./tidyrc | grep ' ' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: numeric-entities" + # -e, -errors, markup + # 只输出错误信息 + echo '' | tidy -e | grep '' + CHECK_RESULT $? 1 0 "Failed to use option: -e" + echo '' | tidy -errors | grep '' + CHECK_RESULT $? 1 0 "Failed to use option: -errors" + echo 'markup: no' >./tidyrc + echo '' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: markup" + # -q, -quiet, quiet + # 关闭不重要的信息 + echo '' | tidy -q | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option: -q" + echo '' | tidy -quiet | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option: -quiet" + echo 'quiet: yes' >./tidyrc + echo '' | tidy -config ./tidyrc | grep 'Info' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: quiet" + # -omit, omit-optional-tags + # 在输出中省略标签: , , ,

, , , , , , , and . + # 测试输出结果中是否不存在 标签,若不存在,则 grep 匹配不到,故 CHECK_RESULT $? 1 0 + echo '' | tidy -omit | grep '' + CHECK_RESULT $? 1 0 "Failed to use option: -omit" + echo 'omit-optional-tags: yes' >./tidyrc + echo '' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: omit-optional-tags" + # -xml, input-xml + # 指定输入的内容是格式良好的 XML + echo 'hello' | tidy -xml 2>&1 | grep 'No warnings or errors were found.' + CHECK_RESULT $? 0 0 "Failed to use option: -xml" + echo 'input-xml: yes' >./tidyrc + echo 'hello' | tidy -config ./tidyrc 2>&1 | grep 'No warnings or errors were found.' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: input-xml" + # -asxml, -asxhtml (output-xhtml: yes) + # 输出为 XML + # 让 tidy 将标签格式化为大写,XML 标准中严格规定元素名必须为小写,则最后的结果为小写 + echo '

hello

' | tidy -upper -asxml | grep '

hello

' + CHECK_RESULT $? 0 0 "Failed to use option: -asxml" + echo '

hello

' | tidy -upper -asxhtml | grep '

hello

' + CHECK_RESULT $? 0 0 "Failed to use option: -asxhtml" + echo 'output-xhtml: yes' >./tidyrc + echo '

hello

' | tidy -upper -config ./tidyrc | grep '

hello

' + CHECK_RESULT $? 0 0 "Failed to use option: output-xhtml" + # -ashtml, output-html + # 将 XHTML 转换为 HTML + # 此功能疑似有问题 + # https://github.com/htacg/tidy-html5/issues/767 + # -access, accessibility-check + # 可访问性检查 + # 在等级一中,有一项是对图片是否包含 alt 信息的检查 + echo '' | tidy -access 1 2>&1 | grep " missing 'alt' text" + CHECK_RESULT $? 0 0 "Failed to use option: -access" + echo 'accessibility-check: 1' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep " missing 'alt' text" + CHECK_RESULT $? 0 0 "Failed to use option in configuration: accessibility-check" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_repair_options.sh b/testcases/cli-test/tidy/oe_test_tidy_repair_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..e49b8c0eb5eba684a36ad92562b1a45f7ef6235f --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_repair_options.sh @@ -0,0 +1,152 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/8 +# @License : Mulan PSL v2 +# @Desc : Test tidy repair options +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --alt-text + # 当 标签的 alt 特性为空时,设置默认的填充内容 + echo '' | tidy --alt-text 'description' | grep 'description' + echo '' | tidy --alt-text true | grep '' + CHECK_RESULT $? 0 0 "Failed to use option: --alt-text" + echo 'alt-text: description' >./tidyrc + echo '' | tidy -config ./tidyrc | grep 'description' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: alt-text" + # --anchor-as-name + # 对于 标签,有 name 属性,没有 id 属性,则添加 + echo 'hi' | tidy --anchor-as-name true | grep 'id="2"' + CHECK_RESULT $? 0 0 "Failed to use option: --anchor-as-name" + echo 'anchor-as-name: true' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'id="2"' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: anchor-as-name" + # --assume-xml-procins + # 在解析“处理指令”时,使用 ?> 作为结尾,而非 > + # 测试时没有明显效果 + # --coerce-endtags + # 若一个开始标签看起来像结束标签则强制将其转换,默认开启 + # 测试中未成功将此功能关闭,但是输出的信息中额外包含了相关提示 + echo 'bar' | tidy --coerce-endtags false 2>&1 | grep 'trimming empty ' + CHECK_RESULT $? 0 0 "Failed to use option: --coerce-endtags" + echo 'coerce-endtags: false' >./tidyrc + echo 'bar' | tidy -config ./tidyrc 2>&1 | grep 'trimming empty ' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: coerce-endtags" + # --css-prefix + # 将 inline 改写,添加对应的类,用于指定类名,需要与 -clean 搭配 + echo 'blue' | tidy -clean --css-prefix hi | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --css-prefix" + echo 'css-prefix: hi' >./tidyrc + echo 'blue' | tidy -clean -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: css-prefix" + # --custom-tags + # --enclose-block-text + # 插入

标签用以闭合所有符合混合 HTML 过渡的文段 + echo '' | tidy --enclose-block-text true | grep '' + CHECK_RESULT $? 0 0 "Failed to use option: --enclose-block-text" + echo 'enclose-block-text: true' >./tidyrc + echo '' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: enclose-block-text" + # --enclose-text + # 指定是否应将在 body 元素中找到的任何文本包含在

元素中 + echo 'hi' | tidy --enclose-text true | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option: --enclose-text" + echo 'enclose-text: true' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: enclose-text" + # --escape-scripts + # --fix-backslash + # 是否修正 URL 中的反斜杠为正斜杠,默认开启 + echo '' | tidy --fix-backslash false 2>&1 | grep '\\openeuler.org' + CHECK_RESULT $? 0 0 "Failed to use option: --fix-backslash" + echo 'fix-backslash: false' >./tidyrc + echo '' | tidy -config ./tidyrc 2>&1 | grep '\\openeuler.org' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: fix-backslash" + # --fix-bad-comments + # 是否替换相连的非预期的连字符为“=” + echo '' | tidy --fix-bad-comments true | grep '' + CHECK_RESULT $? 0 0 "Failed to use option: --fix-bad-comments" + echo 'fix-bad-comments: true' >./tidyrc + echo '' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: fix-bad-comments" + # --fix-style-tags + # 是否将所有样式标签移动至 部分中 + echo '' >sample.html + tidy --fix-style-tags false sample.html | grep 'body' -A 1 | grep 'style' + CHECK_RESULT $? 0 0 "Failed to use option: --fix-style-tags" + echo 'fix-style-tags: false' >./tidyrc + tidy -config ./tidyrc sample.html | grep 'body' -A 1 | grep 'style' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: fix-style-tags" + # --fix-uri + # 是否应检查包含 URI 的属性值是否存在非法字符,默认开启 + echo 'yeah' | tidy --fix-uri false | grep '拥抱开源' + CHECK_RESULT $? 0 0 "Failed to use option: --fix-uri" + echo 'fix-uri: false' >./tidyrc + echo 'yeah' | tidy -config ./tidyrc | grep '拥抱开源' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: fix-uri" + # --literal-attributes + # 不忽略除 title、alt、value 之外的所有内容的前导和尾随空格 + echo '

hi

' | tidy -q --literal-attributes true | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option: --literal-attributes" + echo 'literal-attributes: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep '

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: literal-attributes" + # --lower-literals + # --repeated-attributes + # 保留重复特性中的哪个,第一个或最后一个 + echo '

hi

' | tidy --repeated-attributes keep-first | grep 'align="left"' + CHECK_RESULT $? 0 0 "Failed to use option: --repeated-attributes" + echo 'repeated-attributes: keep-first' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'align="left"' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: repeated-attributes" + # --join-classes, + # --join-styles + # --skip-nested + # --strict-tags-attributes + # --uppercase-attributes + # 将特性大写输出 + echo '

hi

' | tidy --uppercase-attributes true | grep 'ALIGN="left"' + CHECK_RESULT $? 0 0 "Failed to use option: --uppercase-attributes" + echo 'uppercase-attributes: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'ALIGN="left"' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: uppercase-attributes" + # --uppercase-tags + # 将标签大写输出 + echo '

hi

' | tidy --uppercase-tags true | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option: --uppercase-tags" + echo 'uppercase-tags: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: uppercase-tags" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + rm -f ./tidied.html + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_teaching_tidy_options.sh b/testcases/cli-test/tidy/oe_test_tidy_teaching_tidy_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..b2ac87a7594f97fd42d9432c39545ea9132eb648 --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_teaching_tidy_options.sh @@ -0,0 +1,68 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/17 +# @License : Mulan PSL v2 +# @Desc : Test iftop text mode +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --new-blocklevel-tags + # 定义新的块级标签 + echo 'hi' | tidy --new-blocklevel-tags what | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --new-blocklevel-tags" + echo 'new-blocklevel-tags: what' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: new-blocklevel-tags" + # --new-empty-tags + # 定义新的空内联标签 + echo '

hi

' | tidy --new-empty-tags what | grep '' + CHECK_RESULT $? 0 0 "Failed to use option: --new-empty-tags" + echo 'new-empty-tags: what' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep '' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: new-empty-tags" + # --new-inline-tags + # 定义新的内联标签 + echo '

hi

' | tidy --new-inline-tags what | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option: --new-inline-tags" + echo 'new-inline-tags: what' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep '

hi

' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: new-inline-tags" + # --new-pre-tags + # 定义新的与格式化标签 + echo 'hi' | tidy --new-pre-tags what_pre | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --new-pre-tags" + echo 'new-pre-tags: what_pre' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: new-pre-tags" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_transformation_options.sh b/testcases/cli-test/tidy/oe_test_tidy_transformation_options.sh new file mode 100644 index 0000000000000000000000000000000000000000..531b9a061ba8317490eb1ebe3ad769b1ab27b06d --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_transformation_options.sh @@ -0,0 +1,88 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/2/17 +# @License : Mulan PSL v2 +# @Desc : Test iftop text mode +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # --decorate-inferred-ul + # --escape-cdata + # 讲 的内容转换为普通文本 + echo '' | tidy --escape-cdata true | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --escape-cdata" + echo 'escape-cdata: true' >./tidyrc + echo '' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: escape-cdata" + # --hide-comments + # 不打印注释 + echo '' | tidy --hide-comments true | grep 'this is comment' + CHECK_RESULT $? 1 0 "Failed to use option: --hide-comments" + echo 'hide-comments: true' >./tidyrc + echo '' | tidy -config ./tidyrc | grep 'this is comment' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: hide-comments" + # --join-classes + # 将多个类名生成一个新类名 + echo '

hi

' | tidy --join-classes true | grep 'class="a b"' + CHECK_RESULT $? 0 0 "Failed to use option: --join-classes" + echo 'join-classes: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'class="a b"' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: join-classes" + # --join-styles + # 将多个样式合并为一个新样式 + echo '

hi

' | tidy --join-styles false | grep 'Warning:

dropping value "color:blue" for repeated attribute "style"' + CHECK_RESULT $? 1 0 "Failed to use option: --join-styles" + echo 'join-styles: false' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'Warning:

dropping value "color:blue" for repeated attribute "style"' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: join-styles" + echo '

hi

' | tidy --join-styles true | grep 'Warning:

joining values of repeated attribute "style"' + CHECK_RESULT $? 1 0 "Failed to use option: --join-styles" + echo 'join-styles: true' >./tidyrc + echo '

hi

' | tidy -config ./tidyrc | grep 'Warning:

joining values of repeated attribute "style"' + CHECK_RESULT $? 1 0 "Failed to use option in configuration: join-styles" + # --merge-emphasis + # 合并嵌套的 元素,默认开启 + echo 'hi' | tidy --merge-emphasis false | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option: --merge-emphasis" + echo 'merge-emphasis: false' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'hi' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: merge-emphasis" + # --replace-color + # 将颜色的数字表示转换为名字 + echo 'hi' | tidy --replace-color true | grep 'color="white"' + CHECK_RESULT $? 0 0 "Failed to use option: --replace-color" + echo 'replace-color: true' >./tidyrc + echo 'hi' | tidy -config ./tidyrc | grep 'color="white"' + CHECK_RESULT $? 0 0 "Failed to use option in configuration: replace-color" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + rm -f ./tidyrc + LOG_INFO "Finish environment cleanup!" +} + +main "$@" diff --git a/testcases/cli-test/tidy/oe_test_tidy_xml.sh b/testcases/cli-test/tidy/oe_test_tidy_xml.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd5543f6c3a96f4e528f4e14ea255866c3e9f30a --- /dev/null +++ b/testcases/cli-test/tidy/oe_test_tidy_xml.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : shangyingjie +# @Contact : yingjie@isrc.iscas.ac.cn +# @Date : 2022/1/24 +# @License : Mulan PSL v2 +# @Desc : Test iftop text mode +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL tidy + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + # -xml-help + # 以 XML 格式输出命令行选项 + tidy -xml-help | grep 'help' + CHECK_RESULT $? 0 0 "Failed to use option: -xml-help" + # -xml-config + # 以 XML 格式输出配置选项 + tidy -xml-config | grep 'option' + CHECK_RESULT $? 0 0 "Failed to use option: -xml-config" + # -xml-strings + # 以 XML 格式输出 Tidy 的字符串 + tidy -xml-strings | grep 'string' + CHECK_RESULT $? 0 0 "Failed to use option: -xml-strings" + # -xml-error-strings + # 以 XML 格式输出错误常熟和字符串 + tidy -xml-error-strings | grep 'error_string' + CHECK_RESULT $? 0 0 "Failed to use option: -xml-error-string" + # -xml-options-strings + # 以 XML 格式输出选项描述 + tidy -xml-options-strings | grep 'option' + CHECK_RESULT $? 0 0 "Failed to use option: -xml-options-strings" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} + +main "$@"