예제 #1
0
def test_discover_buildspec():
    # this should raise an error since no buildspecs are specified
    with pytest.raises(SystemExit):
        discover_buildspecs()

    bp = [os.path.join(BUILDTEST_ROOT, "README.rst")]

    with pytest.raises(SystemExit):
        discover_buildspecs(buildspec=bp)

    # this should raise AssertionError if we pass a string for buildspec argument, it expects a list
    with pytest.raises(AssertionError):
        discover_buildspecs(buildspec=bp[0])

    input_buildspec = [os.path.join(valid_buildspecs, "environment.yml")]
    # this should raise AssertionError if we pass a string for exclude_buildspec it expects a list
    with pytest.raises(AssertionError):
        discover_buildspecs(
            buildspec=input_buildspec, exclude_buildspec=input_buildspec[0]
        )

    # The test below will discover and negate all buildspecs which raises an exception of type SystemExit
    with pytest.raises(SystemExit):
        discover_buildspecs(
            buildspec=[valid_buildspecs], exclude_buildspec=[valid_buildspecs]
        )

    input_bps = [
        os.path.join(BUILDTEST_ROOT, "README.rst"),
        os.path.join(BUILDTEST_ROOT, "tutorials"),
    ]
    exclude_bps = [os.path.join(BUILDTEST_ROOT, "tutorials", "compilers")]

    discovered_bp, excluded_bp = discover_buildspecs(
        buildspec=input_bps, exclude_buildspec=exclude_bps
    )
    print("discovered:", discovered_bp)
    print("excluded:", exclude_bps)
    # assert both discovered_bp and excluded_bp are not None
    assert discovered_bp
    assert excluded_bp

    # testing by tags and input buildspecs but not excluding any buildspecs
    discovered_bp, exclude_bps = discover_buildspecs(
        tags=["tutorials"], buildspec=input_bps
    )
    # ensure that discovered buildspec is not None and exclude_bps should be empty list
    assert discovered_bp
    assert not exclude_bps

    # the tags field expect a list when searching in cache, passing a string will raise AssertionError
    with pytest.raises(AssertionError):
        discover_buildspecs(tags="tutorials")
예제 #2
0
import os
from buildtest.config import load_settings
from buildtest.defaults import BUILDTEST_ROOT
from buildtest.executors.setup import BuildExecutor
from buildtest.menu.build import (
    build_phase,
    discover_buildspecs,
    parse_buildspecs,
    resolve_testdirectory,
    run_phase,
)

input_buildspecs = [
    os.path.join(BUILDTEST_ROOT, "tutorials", "pass_returncode.yml")
]
included_bp, excluded_bp = discover_buildspecs(buildspec=input_buildspecs,
                                               debug=True)

configuration = load_settings()
testdir = resolve_testdirectory(configuration)
executor = BuildExecutor(configuration)

print("List of executors: ", executor.executors)
bp_filters = {"tags": None}
builders = parse_buildspecs(included_bp,
                            test_directory=testdir,
                            executor=executor,
                            filters=bp_filters,
                            rebuild=1,
                            printTable=True)

build_phase(builders, printTable=True)
예제 #3
0
파일: ex1.py 프로젝트: yamiacat/buildtest
import os
from buildtest.defaults import BUILDTEST_ROOT
from buildtest.menu.build import discover_buildspecs

included_bp, excluded_bp = discover_buildspecs(
    buildspec=[os.path.join(BUILDTEST_ROOT, "tutorials")])
print("\n Discovered buildspecs: \n")
[print(f) for f in included_bp]

print("\n Excluded buildspecs: \n")
[print(f) for f in excluded_bp]
예제 #4
0
파일: ex2.py 프로젝트: yamiacat/buildtest
from buildtest.menu.build import discover_buildspecs

tagname = ["tutorials"]
print(f"Searching by tagname: {tagname}")
included_bp, excluded_bp = discover_buildspecs(tags=tagname)
print("\n Discovered buildspecs: \n")
[print(f) for f in included_bp]
예제 #5
0
from buildtest.config import load_settings
from buildtest.menu.build import discover_buildspecs, resolve_testdirectory, build_phase
from buildtest.menu.build import parse_buildspecs
from buildtest.executors.setup import BuildExecutor

tagname = ["pass"]
print(f"Searching by tagname: {tagname}")
included_bp, excluded_bp = discover_buildspecs(tags=tagname, debug=True)

configuration = load_settings()
testdir = resolve_testdirectory(configuration)

executor = BuildExecutor(configuration)
buildspec_filters = {"tags": None}
builders = parse_buildspecs(
    buildspecs=included_bp,
    executor=executor,
    test_directory=testdir,
    filters=buildspec_filters,
    rebuild=1,
    printTable=True,
)

build_phase(builders, printTable=True)