Commit 05a81755 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Added tests with pipeline to check element iteration and scope

parent a4b0c408
import os
import pytest
from buildstream import Context, Project
from buildstream import Context, Project, Scope
from buildstream._pipeline import Pipeline
DATA_DIR = os.path.join(
......@@ -32,3 +32,106 @@ def test_load_simple(datafiles, tmpdir):
command_list = pipeline.target.commands['configure-commands']
assert(len(command_list) == 1)
assert(command_list[0] == 'pony')
###############################################################
# Testing Element.dependencies() iteration #
###############################################################
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'iterate'))
def test_iterate_scope_all(datafiles, tmpdir):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
pipeline = create_pipeline(tmpdir, basedir, 'target.bst', None)
assert(pipeline.target.get_kind() == "autotools")
assert(isinstance(pipeline.target.commands['configure-commands'], list))
command_list = pipeline.target.commands['configure-commands']
assert(len(command_list) == 1)
assert(command_list[0] == 'pony')
element_list = pipeline.target.dependencies(Scope.ALL)
element_list = list(element_list)
assert(len(element_list) == 7)
assert(element_list[0].name == "build-build")
assert(element_list[1].name == "run-build")
assert(element_list[2].name == "build")
assert(element_list[3].name == "dep-one")
assert(element_list[4].name == "run")
assert(element_list[5].name == "dep-two")
assert(element_list[6].name == "target")
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'iterate'))
def test_iterate_scope_run(datafiles, tmpdir):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
pipeline = create_pipeline(tmpdir, basedir, 'target.bst', None)
assert(pipeline.target.get_kind() == "autotools")
assert(isinstance(pipeline.target.commands['configure-commands'], list))
command_list = pipeline.target.commands['configure-commands']
assert(len(command_list) == 1)
assert(command_list[0] == 'pony')
element_list = pipeline.target.dependencies(Scope.RUN)
element_list = list(element_list)
assert(len(element_list) == 4)
assert(element_list[0].name == "dep-one")
assert(element_list[1].name == "run")
assert(element_list[2].name == "dep-two")
assert(element_list[3].name == "target")
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'iterate'))
def test_iterate_scope_build(datafiles, tmpdir):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
pipeline = create_pipeline(tmpdir, basedir, 'target.bst', None)
assert(pipeline.target.get_kind() == "autotools")
assert(isinstance(pipeline.target.commands['configure-commands'], list))
command_list = pipeline.target.commands['configure-commands']
assert(len(command_list) == 1)
assert(command_list[0] == 'pony')
element_list = pipeline.target.dependencies(Scope.BUILD)
element_list = list(element_list)
assert(len(element_list) == 3)
assert(element_list[0].name == "dep-one")
assert(element_list[1].name == "run")
assert(element_list[2].name == "dep-two")
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'iterate'))
def test_iterate_scope_build_of_child(datafiles, tmpdir):
basedir = os.path.join(datafiles.dirname, datafiles.basename)
pipeline = create_pipeline(tmpdir, basedir, 'target.bst', None)
assert(pipeline.target.get_kind() == "autotools")
assert(isinstance(pipeline.target.commands['configure-commands'], list))
command_list = pipeline.target.commands['configure-commands']
assert(len(command_list) == 1)
assert(command_list[0] == 'pony')
# First pass, lets check dep-two
element_list = pipeline.target.dependencies(Scope.BUILD)
element_list = list(element_list)
element = element_list[2]
# Pass two, let's look at these
element_list = element.dependencies(Scope.BUILD)
element_list = list(element_list)
assert(len(element_list) == 2)
assert(element_list[0].name == "run-build")
assert(element_list[1].name == "build")
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
depends:
- filename: build-build.bst
type: build
- filename: run-build.bst
type: runtime
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
depends:
- filename: build.bst
type: build
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
depends:
- filename: build.bst
type: build
- filename: run.bst
type: runtime
# Basic project configuration that doesnt override anything
#
name: pony
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
kind: autotools
description: Some kinda autotools element
config:
configure-commands:
- pony
depends:
- dep-one.bst
- dep-two.bst
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment