所以我需要运行一堆(maven)测试,测试文件作为参数提供给maven任务。脚本从给定目录输入运行某个程序
事情是这样的:
mvn clean test -Dtest=<filename>
而且测试文件通常被组织成不同的目录。所以我试图编写一个脚本来执行上述'命令',并自动将给定目录中的所有文件的名称提供给-Dtest
。
于是我开始了一个名为“RUN_TEST”的shell:
#!/bin/sh
if test $# -lt 2; then
echo "$0: insufficient arguments on the command line." >&1
echo "usage: $0 run_test dirctory" >&1
exit 1
fi
for file in allFiles <<<<<<< what should I put here? Can I somehow iterate thru the list of all files' name in the given directory put the file name here?
do mvn clean test -Dtest= $file
exit $?
的部分在哪里卡住了是如何得到的文件名列表。 谢谢,
如果什么<目录名>参数只给我的目录的名称,而不是位置。换句话说,我肯定知道给定的目录在'/'中。但它可能在任何地方。那么我应该使用$ for $(find $ 1 -type d)'(d for directory?)? –
'[[-f $ file]]'是什么意思? –
将上面的代码换成'for $(find。-type d -name $ 1)中的for dir。做...内部循环...完成' –