Skip to main content
Ctrl+K

canary 26.4.16.dev0

  • User's guide
  • API reference
  • Developer's guide
  • Release notes
  • Tutorial
  • GitHub
  • User's guide
  • API reference
  • Developer's guide
  • Release notes
  • Tutorial
  • GitHub

Section Navigation

  • Introduction
    • What is canary?
    • Installing canary
    • Getting the examples
  • Getting started
    • A first test
    • A second test
    • Other test file types
  • Parameterizing tests
    • Getting started
    • Multiple parameters
    • Combining multiple parameter sets
    • Special parameter names
    • Different types of parameterization
  • Test asset management
    • Copy files into the test's working directory
    • Link files into the test's working directory
  • Test dependencies
    • Basic test dependencies
    • Controlling test execution based on dependency results
    • Establishing dependencies on specific test parameterizations
    • Multiple dependencies
    • Generating the base case
  • Resource allocation
    • The resource pool
    • Defining the resource pool
    • Defining resources required by a test case
    • Environment variables
  • Batched execution
    • Running tests in a batch scheduler
    • Batch specification
    • Sending options to the batch scheduler
  • Extending canary
    • Job generators
    • Worked example: a YAML jobspec generator
      • Registering the generator
      • The generator class
      • Building JobSpec objects
  • canary: Accelerating Application Testing Across Platforms
  • Test asset management
  • Link files into the test working directory

Link files into the test working directory#

The canary.directives.link() directive links files into the test’s working directory:

# Copyright NTESS. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: MIT

import os

import canary

canary.directives.copy("copy.txt")
canary.directives.link("link.txt")
canary.directives.copy("${NAME}.*.txt")


def test():
    assert os.path.exists("copy.txt") and not os.path.islink("copy.txt")
    assert os.path.exists("link.txt") and os.path.islink("link.txt")
    assert os.path.exists("copy_and_link.1.txt") and not os.path.islink("copy_and_link.1.txt")
    assert os.path.exists("copy_and_link.2.txt") and not os.path.islink("copy_and_link.2.txt")


if __name__ == "__main__":
    test()

Relative paths are assumed relative to the test file’s source directory.

previous

Copy files into the test working directory

next

Test dependencies

© Copyright 2024, National Technology & Engineering Solutions of Sandia, LLC (NTESS).

Created using Sphinx 9.1.0.

Built with the PyData Sphinx Theme 0.18.0.