update testcase for testsuite perl-Test-Specio

This commit is contained in:
2026-04-17 19:45:29 +08:00
parent 543ffcb3df
commit 4c508784d1
2 changed files with 0 additions and 95 deletions

View File

@@ -14,10 +14,6 @@
"name": "test_perl-Test-Specio_function_use_module",
"desc": "测试能否成功加载并导入 perl-Test-Specio 模块。"
},
{
"name": "test_perl-Test-Specio_function_export_type",
"desc": "测试 perl-Test-Specio 是否能成功导出和定义类型约束。"
},
{
"name": "test_perl-Test-Specio_function_uninstall",
"desc": "测试 perl-Test-Specio 软件包能否正确卸载。"

View File

@@ -1,91 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .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 details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-27
# @License : Mulan PSL v2
# @Desc : 测试 perl-Test-Specio 是否能成功导出和定义类型约束。
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试 perl-Test-Specio 是否能成功导出和定义类型约束。"
# 定义软件包名称
PACKAGE_NAME="perl-Test-Specio"
# 检查yum源中是否有该软件包
LOG_INFO "检查yum源中是否有 $PACKAGE_NAME 软件包。"
dnf list available "$PACKAGE_NAME" > /dev/null 2>&1
if [ $? -ne 0 ]; then
LOG_ERROR "yum源中没有找到 $PACKAGE_NAME 软件包。"
exit 255
fi
# 判断环境是否已经安装
LOG_INFO "检查当前环境是否已安装 $PACKAGE_NAME"
if rpm -q "$PACKAGE_NAME" > /dev/null 2>&1; then
LOG_INFO "环境已安装 $PACKAGE_NAME,测试结束后保持安装状态。"
INSTALLED_BEFORE=true
else
LOG_INFO "环境未安装 $PACKAGE_NAME,将进行安装。"
INSTALLED_BEFORE=false
fi
# 如果未安装,则安装软件包
if [ "$INSTALLED_BEFORE" = false ]; then
LOG_INFO "安装 $PACKAGE_NAME 软件包。"
dnf install -y "$PACKAGE_NAME"
CHECK_RESULT $? 0 0 "安装 $PACKAGE_NAME 失败。"
fi
# 测试 perl-Test-Specio 是否能成功导出和定义类型约束
LOG_INFO "测试 perl-Test-Specio 导出和定义类型约束功能。"
perl -MTest::Specio -e "print "Test::Specio loaded successfully\n"" 2>&1
CHECK_RESULT $? 0 0 "加载 Test::Specio 模块失败。"
# 执行具体的类型约束测试
LOG_INFO "执行类型约束定义测试。"
cat > test_specio_type.tmp << "EOF"
use strict;
use warnings;
use Test::More tests => 2;
use Test::Specio;
my $type = Specio::Library::Builtins->new("Int");
ok( defined $type, "Int type constraint defined" );
my $constraint = $type->constraint;
ok( $constraint->(42), "Int constraint works for integer" );
EOF
perl test_specio_type.tmp
CHECK_RESULT $? 0 0 "类型约束定义测试失败。"
# 清理临时文件
rm -f test_specio_type.tmp
# 如果测试前未安装,则卸载软件包
if [ "$INSTALLED_BEFORE" = false ]; then
LOG_INFO "卸载 $PACKAGE_NAME 软件包。"
dnf remove -y "$PACKAGE_NAME"
CHECK_RESULT $? 0 0 "卸载 $PACKAGE_NAME 失败。"
else
LOG_INFO "保持 $PACKAGE_NAME 软件包安装状态。"
fi
LOG_INFO "测试完成,环境已恢复。"
}
main "$@"