Chapter 08Lesson 05240–320 min

Checkpoint Lab — Collections, String, DateTime, OperatingSystem, Process, and XML Libraries

Build and operate a guarded local artifact-processing workflow, predict every important state transition, verify structured process/XML evidence, inject one reversible failure, and prove that cleanup removes only lab-owned resources.

Checkpoint labArtifact workflowEvidence packetFailure injectionCleanup proof

Learning objectives

  • Plan the source/value/filesystem/process/XML/result state changes before execution.
  • Implement one local workflow using all six standard libraries with explicit ownership and verification.
  • Capture a reproducible evidence packet containing transformed values, timestamps, directory/process/XML observations and Robot results.
  • Inject and diagnose a controlled child-process failure without hiding the original evidence.
  • Demonstrate guarded cleanup and document the production operating rules learned in Chapter 08.

Current compatibility baseline. Verified 2026-08-31: Robot Framework 7.4.2 is the current stable release and requires Python 3.8+. The six libraries in this chapter ship with Robot Framework core. BuiltIn is available automatically, while Collections, String, DateTime, OperatingSystem, Process, and XML must be imported explicitly. Robot Framework 7.4 added type hints across standard libraries, expanded bytes support, and Secret-aware arguments in relevant APIs. This chapter does not require pre-release syntax or third-party libraries.

1. Checkpoint charter

Your team receives a synthetic XML artifact manifest and a short text note. The Robot task must normalize component data, attach a UTC observation time, write only to a unique temporary workspace, launch a local verifier, inspect its rc/stdout/stderr, query XML fields, produce a summary text file, and clean the workspace. Robot result artifacts must remain outside the scratch directory.

Scope: localhost only, synthetic content only, no real secrets, no network, no privileged commands, no production filesystem paths. Recursive removal is permitted only after the lab’s normalized-path guard passes.

2. Predict before execution

Prediction Expected state change How you will verify
P1 Scratch directory changes absent → present during setup Directory Should Exist + log
P2 Original component list remains unchanged; copied list gains one item Collections equality assertions
P3 Child process exists only during Run Process and returns rc=0 Process result object
P4 Parsed XML exposes artifact id/name/count XML element/text/attribute assertions
P5 Summary file exists before teardown and workspace is absent after teardown OperatingSystem assertions
P6 output.xml/log/report survive cleanup Explicit output directory outside workspace

3. Checkpoint files

rf08-checkpoint/
├── suites/
│   └── checkpoint.robot
├── fixtures/
│   └── manifest.xml
└── evidence/
<manifest>
  <artifact id="RF08-001">
    <name>synthetic-package</name>
    <count>2</count>
  </artifact>
</manifest>

4. Implement the checkpoint suite

*** Settings ***
Library    Collections
Library    String
Library    DateTime
Library    OperatingSystem
Library    Process
Library    XML

Suite Setup       Create Checkpoint Workspace
Suite Teardown    Remove Checkpoint Workspace

*** Variables ***
${RUN_ID}       checkpoint-001
${PYTHON}       python
${WORKSPACE}    ${TEMPDIR}/rf08-checkpoint-${RUN_ID}
${MANIFEST}     ${CURDIR}/../fixtures/manifest.xml

*** Test Cases ***
Build Evidence Summary
    ${original}=     Create List    api    worker
    ${expected}=     Create List    api    worker
    ${working}=      Copy List    ${original}
    Append To List    ${working}    verifier
    Lists Should Be Equal    ${original}    ${expected}

    ${joined}=       Catenate    SEPARATOR=|    @{working}
    ${joined}=       Convert To Lower Case    ${joined}
    Should Be Equal    ${joined}    api|worker|verifier

    ${observed}=     Get Current Date    time_zone=UTC    result_format=%Y-%m-%dT%H:%M:%S
    ${observed}=     Catenate    SEPARATOR=    ${observed}    Z

    ${root}=         Parse XML    ${MANIFEST}
    ${name}=         Get Element Text    ${root}    artifact/name
    ${count}=        Get Element Text    ${root}    artifact/count
    ${artifact_id}=  Get Element Attribute    ${root}    id    xpath=artifact
    Should Be Equal    ${name}    synthetic-package
    Should Be Equal    ${count}    2
    Should Be Equal    ${artifact_id}    RF08-001

    ${proc}=         Run Process
    ...    ${PYTHON}
    ...    -c
    ...    import sys; print("artifact-ok"); print("no-errors", file=sys.stderr)
    ...    timeout=10 seconds
    Should Be Equal As Integers    ${proc.rc}    0
    Should Be Equal    ${proc.stdout}    artifact-ok
    Should Be Equal    ${proc.stderr}    no-errors

    ${summary}=      Join Path    ${WORKSPACE}    summary.txt
    Create File      ${summary}    id=${artifact_id}\nname=${name}\ncomponents=${joined}\nobserved=${observed}\nrc=${proc.rc}\n
    File Should Exist    ${summary}
    ${saved}=         Get File    ${summary}    encoding=UTF-8
    Should Contain    ${saved}    id=RF08-001
    Should Contain    ${saved}    rc=0

    ${items}=         List Directory    ${WORKSPACE}
    List Should Contain Value    ${items}    summary.txt

*** Keywords ***
Create Checkpoint Workspace
    Guard Checkpoint Path
    Directory Should Not Exist    ${WORKSPACE}
    Create Directory    ${WORKSPACE}
    Directory Should Exist    ${WORKSPACE}

Remove Checkpoint Workspace
    Guard Checkpoint Path
    Remove Directory    ${WORKSPACE}    recursive=True
    Directory Should Not Exist    ${WORKSPACE}

Guard Checkpoint Path
    ${candidate}=    Normalize Path    ${WORKSPACE}    case_normalize=True
    ${temp}=         Normalize Path    ${TEMPDIR}    case_normalize=True
    Should Start With    ${candidate}    ${temp}${/}
    Should Contain       ${candidate}    rf08-checkpoint-

5. Preflight and clean run

python --version
robot --version
robot --dryrun --outputdir evidence/dryrun suites/checkpoint.robot
robot --variable RUN_ID:clean-001 --variable PYTHON:python --outputdir evidence/clean suites/checkpoint.robot

After the clean run, confirm that evidence/clean/ still contains Robot artifacts but ${TEMPDIR}/rf08-checkpoint-clean-001 no longer exists.

6. Controlled failure injection

Copy the suite to checkpoint_broken.robot. Change the Python child to import sys; print("artifact-bad"); sys.exit(7) and keep the assertion ${proc.rc} == 0. Run into a separate evidence directory.

robot --variable RUN_ID:fail-001 --outputdir evidence/failure suites/checkpoint_broken.robot

Expected: FAIL with preserved process evidence. Teardown should still remove only the guarded workspace. Do not immediately rerun over evidence/failure; inspect log.html and output.xml first.

7. Diagnose the failure without hiding it

  1. Confirm Robot/Python versions and executed file.
  2. Find the Run Process keyword in log.html.
  3. Confirm the child produced rc=7 and expected synthetic output.
  4. Confirm the assertion—not parsing, XML, or cleanup—caused the failure.
  5. Confirm teardown still proved workspace absence.
  6. Restore the child to exit 0 and run into evidence/repaired.

Do not wrap the failed process assertion in Run Keyword And Ignore Error or add retries. The injected failure is deterministic and should remain visible.

8. Evidence packet

Item Required evidence
Versions python --version, robot --version
Inputs RUN_ID, interpreter override, fixture path; no secrets
Transformed data Original and working list observations; joined component string
Time UTC observation timestamp
Filesystem Workspace present during run, summary file present, workspace absent after teardown
Process Command/args, rc, stdout, stderr, timeout
XML artifact id/name/count queries
Robot evidence clean/failure/repaired output.xml, log.html, report.html
Decision record Why Process, path guard, copied collection, UTC, structural XML were chosen

9. Final verification checklist

  • All six standard libraries are imported explicitly and each is used for its own capability.
  • No OperatingSystem deprecated process-running keyword is used.
  • No shell command is built by concatenating untrusted data.
  • Scratch state has a unique run ID and normalized deletion guard.
  • Mutable data is copied before intentional test-local mutation.
  • Text encoding and UTC timestamp convention are explicit.
  • Process rc/stdout/stderr are asserted separately.
  • XML fields are queried structurally.
  • First-failure evidence is preserved.
  • Cleanup removes only the lab-owned workspace.

10. Production operating model added by Chapter 08

Chapter 08 adds a concrete side-effect discipline to the Robot Framework operating model: every standard-library capability has an owner, every mutable/external state change is bounded, process commands and outputs are structured, path/time/encoding conventions are explicit, and evidence survives cleanup. These are prerequisites for the lifecycle controls in Chapter 09, where setup, teardown, tags, timeouts, and suite-level execution policy become first-class design concerns.

11. Knowledge check

Why must the failure run use a separate output directory?

What proves cleanup was correctly scoped?

Why is a process return code assertion necessary even if stdout looks correct?

What would change if the XML requirement were exact signed bytes rather than semantic fields?

Which Chapter 09 concept naturally follows from this checkpoint?

12. Checkpoint complete

You can now use Robot Framework’s standard libraries without blurring in-memory data, host filesystem state, child processes, XML models, and Robot result evidence. The chapter’s core production rule is simple: prefer explicit capability boundaries, verify every side effect, and clean only what the run owns.

Next lesson

Setups, Teardowns, Tags, Timeouts, and Suite Lifecycle: Core Concepts and Mental Model

Continue with Setups, Teardowns, Tags, Timeouts, and Suite Lifecycle: Core Concepts and Mental Model. It builds directly on the state, evidence, and operating assumptions established here, so carry those constraints forward rather than treating the next page as an isolated topic.

Further reading

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.