You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should be able add support for extracting line when applying regular expression check in status check for file_regex and regex.
So take for example the following example, we have introduced linenum that can be applied to extract a line from file or stream. In this example we will extract the 1st and last line of count.txt which should evaluate to the correct expression which is 1, and 10 from the file. The regex check will pass for first test the expression 'Line\s\d+' should match any of the lines regardless of the line number we pick
In the next test, we should get a failure since we will extracting last line of stream which is ******** therefore the expression should fail.
buildspecs:
extract_line_from_file_and_regex:
type: scriptexecutor: generic.local.bashdescription: "Extract line from file and stream and apply regular expression"run: | for i in {1..10}; do echo "Line $i" donestatus:
file_regex:
- file: count.txtexp: '^1$'linenum: 0
- file: count.txtexp: '^10$'linenum: -1regex:
stream: stdoutexp: 'Line\s\d+'extract_line_failure:
type: scriptexecutor: generic.local.bashdescription: Regular expression failure due to incorrect linerun: | for i in {1..10}; do echo "Line $i" >> count.txt echo "Line $i" done echo "*********"status:
regex:
stream: stdoutexp: 'Line\s\d+'linenum: -1
I ran this example without adding linenum to give you idea the 2nd test output should have ****** at end
(buildtest) ☁ general_tests [devel] ⚡ buildtest it query -o extract_line_failure
──────────────────────────────────────────────────────────────────────────────────── extract_line_failure/5e3dbd09-4fb2-4d23-b628-b508108e04c6 ────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Regular expression failure due to incorrect line
State: PASS
Returncode: 0
Runtime: 0.012094 sec
Starttime: 2024/04/26 12:45:15
Endtime: 2024/04/26 12:45:15
Command: bash extract_line_failure_build.sh
Test Script: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/a/extract_line_failure/5e3dbd09/extract_line_failure.sh
Build Script: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/a/extract_line_failure/5e3dbd09/extract_line_failure_build.sh
Output File: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/a/extract_line_failure/5e3dbd09/extract_line_failure.out
Error File: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/a/extract_line_failure/5e3dbd09/extract_line_failure.err
Log File: /Users/siddiq90/Documents/buildtest/var/logs/buildtest_t68eidr1.log
───────────────────────────────────────────── Output File: /Users/siddiq90/Documents/buildtest/var/tests/generic.local.bash/a/extract_line_failure/5e3dbd09/extract_line_failure.out ──────────────────────────────────────────────
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
*********
Please describe your feature
We should be able add support for extracting line when applying regular expression check in status check for
file_regex
andregex
.So take for example the following example, we have introduced
linenum
that can be applied to extract a line from file or stream. In this example we will extract the 1st and last line ofcount.txt
which should evaluate to the correct expression which is1,
and10
from the file. Theregex
check will pass for first test the expression'Line\s\d+'
should match any of the lines regardless of the line number we pickIn the next test, we should get a failure since we will extracting last line of stream which is
********
therefore the expression should fail.I ran this example without adding
linenum
to give you idea the 2nd test output should have ****** at endTODO
regex_check
andfile_regex
buildtest/buildtest/buildsystem/checks.py
Line 97 in 140aabd
buildtest/buildtest/buildsystem/checks.py
Line 161 in 140aabd
check_test_state
seebuildtest/buildtest/builders/base.py
Line 1080 in 140aabd
linenum
such as specifying a floating point value or using a list so you can do something likelinenum: 1.0
orlinenum: [1, 3]
. Anything that makes the schema fail.Suggest potential solution
No response
Additional Information
No response
Post question in Slack
Is there an existing issue
The text was updated successfully, but these errors were encountered: