Deleting a large number of tests from a test suite

39 Views Asked by At

I have a list of about 8000 tests from which I want to remove a certain subset of tests (a whopping 432 of them) that are now passing and no longer required.

The tests entries are in the following format

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

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

The list of tests I want to remove are available to me in the following format

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

What would be a fast way to search and remove the entries for all these tests?

EDIT: Example as requested. Entries:

  [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

Removal list:

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

Expected output:

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

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

There are 1 best solutions below

5
On BEST ANSWER

You can use sed as

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

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