taucmdr.tests package

Unit test initializations and utility functions.

class taucmdr.tests.DarwinTestCase(methodName='runTest')[source]

Bases: TestCase

Base class for tests that run in processes which take this host for a Mac.

Each test gets a new user prefix and an empty project directory.

_classSetupFailed = False
_class_cleanups = []
python(code)[source]

Run Python code as on a Mac and return its output, see run_python_as_darwin.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tau(*args)[source]

Run tau as on a Mac, see run_tau_as_darwin.

taucmdr.tests.REPO_DIR = '/home/runner/work/taucmdr/taucmdr'

Absolute path to the TAU Commander source checkout.

It comes from the environment variable __TAUCMDR_REPO_DIR__, which scripts/run_tests.py defines. Without it, this is the checkout containing this file.

Type:

str

taucmdr.tests.RESULTS_DIR = '/home/runner/work/taucmdr/taucmdr/build/test-results'

Directory for JUnit XML and timings.

It comes from the environment variable __TAUCMDR_TEST_RESULTS_DIR__, which scripts/run_tests.py defines.

Type:

str

taucmdr.tests.TIMING_FILE = '/home/runner/work/taucmdr/taucmdr/build/test-results/test-timings.csv'

CSV file to which each test appends its run time.

Type:

str

class taucmdr.tests.TestCase(methodName='runTest')[source]

Bases: TestCase

Base class for unit tests.

Performs tests in a temporary directory and reconfigures taucmdr.logger to work with unittest.

_classSetupFailed = False
_class_cleanups = []
assertCleanExit(proc)[source]

Check that a process from run_python_subprocess printed no Python traceback.

TAU Commander’s own report of an unexpected exception goes to stdout, so both streams are checked.

assertCommandReturnValue(return_value, cmd, argv)[source]
assertCompiler(role, target_name='targ1')[source]
assertInLastTrialData(value, data_type='tau')[source]
assertManagedBuild(return_value, compiler_role, compiler_args, src)[source]
assertNotCommandReturnValue(return_value, cmd, argv)[source]
assertSucceeded(proc)[source]

Check that a process from run_python_subprocess exited with status 0 and no traceback.

copy_testfile(src, dst=None)[source]
destroy_project_storage()[source]

Delete project storage.

Effectively the same as:

> rm -rf .tau
exec_command(cmd, argv)[source]

Execute a tau command’s main() routine and return the exit code, stdout, and stderr data.

Parameters:
  • cmd (type) – A command instance that has a main callable attribute.

  • argv (list) – Arguments to pass to cmd.main()

Returns:

(retval, stdout, stderr) results of running the command.

Return type:

tuple

getCompiler(role, target_name='targ1')[source]
reset_project_storage(init_args=None)[source]

Delete and recreate project storage.

Effectively the same as:

> rm -rf .tau
> tau initialize [init_args]
Parameters:

init_args (list) – Command line arguments to tau initialize.

run(result=None)[source]
setUp() → None[source]

Hook method for setting up the test fixture before exercising it.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

taucmdr.tests._destroy_test_workdir(path)[source]
taucmdr.tests._null_decorator(_)[source]
taucmdr.tests._report_cleanup_error(_, path, exc)[source]
taucmdr.tests.cleanup()[source]

Checks that any files or directories created during testing have been removed.

taucmdr.tests.get_test_workdir()[source]

Return the current unit test’s working directory.

taucmdr.tests.not_implemented(cls)[source]

Decorator for TestCase classes to indicate that the tests have not been written (yet).

taucmdr.tests.pop_test_workdir()[source]

Recursively deletes the most recently created unit test working directory.

Restores the current working directory and tempfile.tempdir to their values before push_test_workdir was called.

taucmdr.tests.push_test_workdir()[source]

Create a new working directory for a unit test.

Sets the current working directory and tempfile.tempdir to the newly created test directory.

Directories created via this method are tracked. If any of them exist when the program exits then an error message is shown for each.

taucmdr.tests.run_python_as_darwin(code, cwd, user_prefix, backend=None)[source]

Run Python code in a new process that TAU Commander will identify as an Apple silicon Mac.

Parameters:
  • code (str) – Source to run after the platform is patched and before anything is imported.

  • cwd (str) – Working directory of the new process.

  • user_prefix (str) – User-level storage prefix.

  • backend (str) – Value for __TAUCMDR_DB_BACKEND__, or None to use the current one.

Returns:

The finished process, with text output captured.

Return type:

subprocess.CompletedProcess

taucmdr.tests.run_python_subprocess(args, env=None, cwd=None, isolated=True)[source]

Run this Python interpreter in a new process.

Parameters:
  • args (list) – Arguments to the interpreter.

  • env (dict) – Changes to the environment. A value of None unsets the variable.

  • cwd (str) – Working directory of the new process.

  • isolated (bool) – If True, run in isolated mode (-I), as the tau launcher does. Otherwise PYTHONPATH is set to this interpreter’s sys.path, so the new process imports the same taucmdr.

Returns:

The finished process, with text output captured.

Return type:

subprocess.CompletedProcess

taucmdr.tests.run_tau_as_darwin(args, cwd, user_prefix, backend=None)[source]

Run tau in a new process that takes this host for an Apple silicon Mac.

Building TAU is skipped: Experiment.configure does nothing.

taucmdr.tests.run_tau_subprocess(args, backend, cwd, user_prefix, system_prefix=None, env=None)[source]

Run tau in a new process with the given storage.

Parameters:
  • args (list) – Arguments to tau.

  • backend (str) – Value for __TAUCMDR_DB_BACKEND__, or None to leave it unset.

  • cwd (str) – Working directory of the new process.

  • user_prefix (str) – User-level storage prefix.

  • system_prefix (str) – System-level storage prefix, or None for no system level.

  • env (dict) – Further changes to the environment, as for run_python_subprocess.

Returns:

The finished process, with text output captured.

Return type:

subprocess.CompletedProcess

taucmdr.tests.skipUnlessHaveCompiler(role)[source]

Decorator to skip test functions when no compiler fills the given role.

If no installed compiler can fill this role then skip the test and report “<role> compiler not found”.

Parameters:

role (_CompilerRole) – A compiler role.

taucmdr.tests.storage_env(backend, user_prefix, system_prefix=None)[source]

Return environment changes that give a new TAU Commander process the given storage.

Parameters:
  • backend (str) – Value for __TAUCMDR_DB_BACKEND__, or None to leave it unset.

  • user_prefix (str) – User-level storage prefix. HOME is set to it too, so nothing reaches the real one.

  • system_prefix (str) – System-level storage prefix, or None for no system level.

Returns:

Changes for run_python_subprocess’s env.

Return type:

dict

Submodules