diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-14 18:17:54 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-14 18:17:54 +0900 |
commit | 3944b2d1debba6cc3e2cfdb18cd611cef7b8434d (patch) | |
tree | 900d864d604c3df5f52a0b74c880c1f39b82b184 /tests | |
parent | e59802de35eaae0da2ee17bf191b98a8c7d2c581 (diff) | |
download | buildstream-3944b2d1debba6cc3e2cfdb18cd611cef7b8434d.tar.gz |
tests/format/optionexports.py: Testing variable exports for base option types
Diffstat (limited to 'tests')
-rw-r--r-- | tests/format/option-exports/element.bst | 1 | ||||
-rw-r--r-- | tests/format/option-exports/project.conf | 31 | ||||
-rw-r--r-- | tests/format/optionexports.py | 37 |
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/format/option-exports/element.bst b/tests/format/option-exports/element.bst new file mode 100644 index 000000000..3c29b4ea1 --- /dev/null +++ b/tests/format/option-exports/element.bst @@ -0,0 +1 @@ +kind: autotools diff --git a/tests/format/option-exports/project.conf b/tests/format/option-exports/project.conf new file mode 100644 index 000000000..e81a31347 --- /dev/null +++ b/tests/format/option-exports/project.conf @@ -0,0 +1,31 @@ +name: test + +options: + + bool_export: + type: bool + description: Exported boolean option + default: False + variable: exported-bool + + enum_export: + type: enum + description: Exported enum option + values: + - pony + - horsy + - zebry + default: pony + variable: exported-enum + + flags_export: + type: flags + description: Exported flags option + values: + - pony + - horsy + - zebry + default: + - pony + - horsy + variable: exported-flags diff --git a/tests/format/optionexports.py b/tests/format/optionexports.py new file mode 100644 index 000000000..849c9148e --- /dev/null +++ b/tests/format/optionexports.py @@ -0,0 +1,37 @@ +import os +import pytest +from buildstream import _yaml +from buildstream import LoadError, LoadErrorReason +from tests.testutils.runcli import cli + +# Project directory +DATA_DIR = os.path.dirname(os.path.realpath(__file__)) + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("option_name,option_value,var_name,var_value", [ + + # Test boolean + ('bool_export', 'False', 'exported-bool', '0'), + ('bool_export', 'True', 'exported-bool', '1'), + + # Enum + ('enum_export', 'pony', 'exported-enum', 'pony'), + ('enum_export', 'horsy', 'exported-enum', 'horsy'), + + # Flags + ('flags_export', 'pony', 'exported-flags', 'pony'), + ('flags_export', 'pony, horsy', 'exported-flags', 'horsy,pony'), +]) +def test_export(cli, datafiles, option_name, option_value, var_name, var_value): + project = os.path.join(datafiles.dirname, datafiles.basename, 'option-exports') + result = cli.run(project=project, silent=True, args=[ + '--option', option_name, option_value, + 'show', + '--deps', 'none', + '--format', '%{vars}', + 'element.bst']) + + assert result.exit_code == 0 + loaded = _yaml.load_data(result.output) + assert loaded[var_name] == var_value |