Skip to content

Running Component Tests Locally

CI Component Tests / python-unit-tests (.gitea/workflows/ci-component-tests.yaml) runs every components/**/test_*.py on ubuntu-latest, one directory at a time. To run the same locally:

for d in $(find components -name 'test_*.py' -exec dirname {} \; | sort -u); do
  python3 -m unittest discover -s "$d" -p 'test_*.py'
done

The tests use the standard library only, but some run the component's shell scripts, and those need a Linux-like environment. Linux CI meets every prerequisite below; on macOS, or in a sandboxed agent run, check them before reading a failure as a bug.

Prerequisite Suites Without it
Python 3.9 or later all syntax and attribute errors (str.removeprefix, dict \| dict)
GNU tar and coreutils. On macOS: brew install gnu-tar coreutils; the tests use the g-prefixed tools when they are on PATH mattermost/backup/scripts files.sh dump exits 2
TMPDIR without spaces. The tests write the temporary paths unquoted into a copy of the script mattermost/backup/scripts, object-storage-exporter the tests fail at once with "set TMPDIR to a path without spaces"
Permission to set the setgid bit on a directory you own mattermost/backup/scripts (test_restore_leaves_the_mode_of_data_alone) the test fails with "cannot set setgid on a directory here"

A macOS agent whose TMPDIR is under ~/Library/Application Support can run them with TMPDIR=/var/tmp. Its sandbox may still refuse the setgid bit (chmod 2775 fails with "Operation not permitted"), so that one test only passes on Linux CI; the CI result is the one that counts.