blob: c05fd4e37b6a6e9808933f98b4941758bd7dfc0e [file] [log] [blame]
import os
import pexpect
from buildstream import _yaml
from buildstream import utils
from tests.testutils.constants import PEXPECT_TIMEOUT_SHORT
def test_init(tmpdir):
session = pexpect.spawn("bst", ["--no-colors", "init", str(tmpdir)], timeout=PEXPECT_TIMEOUT_SHORT)
name = "test-project"
min_version = "2.0"
element_path = "my-elements"
bst_major, bst_minor = utils.get_bst_version()
# For the version check, artificially set the version to at least
# version 2.0
# TODO: Remove this code block after releasing 2.0
if bst_major < 2:
bst_major = 2
bst_minor = 0
session.expect_exact("Project name:")
session.expect_exact("Minimum version [{}.{}]:".format(bst_major, bst_minor))
session.expect_exact("Element path [elements]:")
session.expect_exact("Created project.conf")
# Now assert that a project.conf got created with expected values
project_conf = _yaml.load(os.path.join(str(tmpdir), "project.conf"), shortname=None)
assert project_conf.get_str("name") == name
assert project_conf.get_str("min-version") == min_version
assert project_conf.get_str("element-path") == element_path