blob: 4e1dbb0642d7b59847bae9763137fc289961e0b0 [file]
############################################################################
# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
############################################################################
"""Test sbatch --parsable output format."""
import re
import pytest
import atf
@pytest.fixture(scope="module", autouse=True)
def setup():
atf.require_slurm_running()
def test_sbatch_parsable():
"""sbatch --parsable writes only the job id (or jobid;cluster) to stdout."""
result = atf.run_command(
"sbatch --parsable -t1 --job-name=test_sbatch_parsable -o /dev/null --wrap 'true'",
fatal=True,
)
match = re.match(r"^(\d+)(?:;.+)?\s*$", result["stdout"])
assert match, (
f"expected bare jobid (or jobid;cluster) on stdout, "
f"got: {result['stdout']!r}"
)
atf.properties["submitted-jobs"].append(int(match.group(1)))