【发布时间】:2013-04-25 06:27:30
【问题描述】:
我正在用 perl 编写一个测试自动化软件,但遇到了我定义的配置文件的问题。 自动化软件接收以 perl 哈希编写的输入 CFG 文件,其中定义了要构建的图像。 现在需要在不同的测试场景中构建相同的图像,例如每晚构建,每小时构建和周末回归。 目前我们必须在 3 个不同的文件中定义相同的图像,并且任何时候我们想要更新它们(比如更新 git 分支)我们需要在 3 个文件中进行。 我正在寻找一种解决方案,我可以创建一个定义构建的文件并让其他文件继承它。 我正在寻找 perl/xml/json/etc 中的内置语言功能。不是我需要在测试软件中实现自己的东西。
例如
夜间配置文件:
builds => {
smp_be => {
name => image_smp
branch => 2011.12
compiler => little_endian
}
up_be => {
name => image_up
branch => 2011.12
compiler => big_endian
}
}
some other ** night ** specific stuff...
周末cfg文件
builds => {
smp_be => {
name => image_smp
branch => 2011.12
compiler => little_endian
}
up_be => {
name => image_up
branch => 2011.12
compiler => big_endian
}
}
some other ** weekend ** specific stuff...
相反,我想要类似的东西
夜间配置文件
builds {
# im inventing this syntax up
# common_builds.cfg contains the previous files
include common_builds.cfg
}
some other ** night ** specific stuff...
请指教
提前致谢
【问题讨论】:
-
经过更多搜索后,我相信我找到了使用 xml 执行此操作的选项。 xml 中有 2 个不同的特性支持这一点:外部实体和 xinlcude。生病试试这个并更新,如果它做的工作
标签: xml json perl configuration-files perl-hash