从测试套件中删除大量测试

时间:2014-11-27 17:40:44

标签: shell replace scripting editing

我有一个大约8000个测试的列表,我想从中删除一些现在正在通过但不再需要的测试子集(其中有432个)。

测试条目采用以下格式

  [img.hidden: setAttribute() to "" followed by IDL get]
    expected: FAIL

  [img.hidden: setAttribute() to " foo " followed by IDL get]
    expected: FAIL

我想要删除的测试列表以下列格式提供给我

img.hidden: setAttribute() to "" followed by IDL get
img.hidden: setAttribute() to " foo " followed by IDL get

搜索和删除所有这些测试的条目的快速方法是什么?

编辑: 请求示例。输入:

  [img.hidden: IDL set to undefined followed by hasAttribute()]
    expected: FAIL

  [img.hidden: IDL set to undefined followed by IDL get]
    expected: FAIL

  [img.hidden: IDL set to null followed by hasAttribute()]
    expected: FAIL

  [img.hidden: IDL set to null followed by IDL get]
    expected: FAIL

  [img.hidden: IDL set to 7 followed by IDL get]
    expected: FAIL

删除清单:

img.hidden: IDL set to undefined followed by IDL get
img.hidden: IDL set to null followed by IDL get
img.hidden: IDL set to 7 followed by IDL get

预期产出:

  [img.hidden: IDL set to undefined followed by hasAttribute()]
    expected: FAIL

  [img.hidden: IDL set to null followed by hasAttribute()]
    expected: FAIL

1 个答案:

答案 0 :(得分:0)

您可以将sed用作

while read pattern
do 
sed -i "/$pattern/, +1 d" inputFile
done < test

<强>测试

$ cat input
[img.hidden: IDL set to undefined followed by hasAttribute()]
    expected: FAIL

[img.hidden: IDL set to undefined followed by IDL get]
    expected: FAIL

[img.hidden: IDL set to null followed by hasAttribute()]
    expected: FAIL

[img.hidden: IDL set to null followed by IDL get]
    expected: FAIL

[img.hidden: IDL set to 7 followed by IDL get]
    expected: FAIL

$ cat test
img.hidden: IDL set to undefined followed by IDL get
img.hidden: IDL set to null followed by IDL get
img.hidden: IDL set to 7 followed by IDL get

$ while read pattern; do sed -i "/$pattern/, +1 d" input ; done < test

$ cat input
[img.hidden: IDL set to undefined followed by hasAttribute()]
    expected: FAIL


[img.hidden: IDL set to null followed by hasAttribute()]
    expected: FAIL