Back to commands

Hosting Operations

Read-only, can be slow

List Failed Tests from JUnit XML

A test log is long, but the JUnit report contains structured failure records that can identify failed test cases quickly.

Command

grep -RIn '<failure\|<error' artifacts/test/*.xml

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not use simple grep as a full XML parser when exact structured extraction is required.

Expected output

JUnit XML lines containing failure or error elements.

System impact

Read-only, can be slow. Nothing changes. grep prints failure and error records from XML reports.

Scope this to the smallest useful path or service on busy systems.

Recovery / rollback: no state is changed.

When to use it

Use when test logs are noisy but XML reports are available.

When not to use it

Do not use simple grep as a full XML parser when exact structured extraction is required.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ cd /work/ci-artifacts && find artifacts/test -name '*.xml' -print

artifacts/test/junit.xml

$ cd /work/ci-artifacts && grep -RIn '<failure\|<error' artifacts/test/*.xml

4:    <failure message="expected 201 got 500">AssertionError</failure>

$ cd /work/ci-artifacts && sed -n '1,80p' artifacts/test/junit.xml

<testsuite name="api" tests="4" failures="1" errors="0" skipped="1">
  <testcase classname="tests.test_api" name="test_health"/>
  <testcase classname="tests.test_api" name="test_create_user">
    <failure message="expected 201 got 500">AssertionError</failure>
  </testcase>
  <testcase classname="tests.test_billing" name="test_invoice"/>
  <testcase classname="tests.test_slow" name="test_report"><skipped message="slow"/></testcase>
</testsuite>
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. cd /lab/ci-artifacts && find artifacts/test -name '*.xml' -print
  2. cd /lab/ci-artifacts && grep -RIn '<failure\|<error' artifacts/test/*.xml
  3. cd /lab/ci-artifacts && sed -n '1,80p' artifacts/test/junit.xml

next steps

Related commands

Hosting Operations Can be slow

Scan Every CI Log for Error Lines

One grep pass can turn a log pile into a failure list.

grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50
Hosting Operations Can be slow

Summarize Test Counts from Reports

Before debugging a test failure, measure the blast radius.

grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml | sort | uniq -c
Hosting Operations Can be slow

Find Tests That Passed After Rerun

A green retry can still hide a flaky test.

grep -RInE 'rerun|retry|flaky|passed on retry|failed attempt' artifacts logs
Hosting Operations Can be slow

Tail the Failing CI Lines

Skip the full CI log and jump straight to lines that usually explain the failure.

grep -RInE 'error|failed|exception|traceback|fatal' logs/ | tail -50
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:103-gnu-unix-commands
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • lfcs:services-logs
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.