So, I have a file called "test.log" with multiple entries like this:
2022-09-30T11:37:54 START_TEST_CASE Start 'tst_T01-TC02' Test 'tst_T01-TC02' started (tst_T01-TC02)
2022-09-30T11:38:01 PASS shared/scripts/Project/LoginWindow.py:39: Comparison 'True' and 'True' are equal
2022-09-30T11:38:16 END_TEST_CASE End 'tst_T01-TC02' End of test 'tst_T01-TC02'<br>
2022-09-30T11:37:54 START_TEST_CASE Start 'tst_T01-TC01' Test 'tst_T01-TC01' started (tst_T01-TC01)
2022-09-30T11:38:01 PASS shared/scripts/Project/LoginWindow.py:39: Comparison 'True' and 'True' are equal
2022-09-30T11:38:16 END_TEST_CASE End 'tst_T01-TC01' End of test 'tst_T01-TC01'<br>
2022-09-30T11:37:54 START_TEST_CASE Start 'tst_T02-TC01' Test 'tst_T02-TC01' started (tst_T02-TC01)
2022-09-30T11:38:01 FAIL shared/scripts/Project/LoginWindow.py:39: Comparison 'True' and 'True' are equal
2022-09-30T11:38:16 END_TEST_CASE End 'tst_T02-TC01' End of test 'tst_T02-TC01'
What I want is to create X files, each file must contain a single TestCase. I archive this by using the following command:
sed '/START_TEST_CASE/,/END_TEST_CASE/!d' $LOG_FILE_NAME | \
csplit -z --suffix-format="%d.log" - '/END_TEST_CASE/1' '{*}'
Now, the files that I create using this method are called xx5.log
or xx0.log
or similar wording.
What I want is to modify this script in order to call, each created file, by its relevant test case name (this name is written inside the text, in the same row of START_TEST_CASE
)
For example, the first file created, containing the first TestCase by line, must be named tst_T01-TC02.log
, the second tst_T01-TC01.log
, the third tst_T02-TC01.log
, ecc.
How can I achieve this?