summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-06 16:47:07 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-07 15:35:15 -0500
commit766683f318900a6ae44e9544b3aeb108b6f4c0ab (patch)
tree1612858a0a0d686aa963df2af9f027a67e5bcc0d /tests
parent5d83d6b7045dc275aaeac8f76a5426d78287831b (diff)
downloadbuildstream-766683f318900a6ae44e9544b3aeb108b6f4c0ab.tar.gz
tests/variables/variables.py: New variable tests
o Test loading of default element configurations o Test overriding command output via variable settings
Diffstat (limited to 'tests')
-rw-r--r--tests/variables/defaults/autotools.bst2
-rw-r--r--tests/variables/defaults/cmake.bst2
-rw-r--r--tests/variables/defaults/distutils.bst2
-rw-r--r--tests/variables/defaults/makemaker.bst2
-rw-r--r--tests/variables/defaults/modulebuild.bst2
-rw-r--r--tests/variables/defaults/project.conf3
-rw-r--r--tests/variables/defaults/qmake.bst2
-rw-r--r--tests/variables/overrides/autotools.bst6
-rw-r--r--tests/variables/overrides/cmake.bst6
-rw-r--r--tests/variables/overrides/distutils.bst6
-rw-r--r--tests/variables/overrides/makemaker.bst6
-rw-r--r--tests/variables/overrides/modulebuild.bst6
-rw-r--r--tests/variables/overrides/project.conf3
-rw-r--r--tests/variables/overrides/qmake.bst6
-rw-r--r--tests/variables/variables.py72
15 files changed, 126 insertions, 0 deletions
diff --git a/tests/variables/defaults/autotools.bst b/tests/variables/defaults/autotools.bst
new file mode 100644
index 000000000..1fdbc5cd8
--- /dev/null
+++ b/tests/variables/defaults/autotools.bst
@@ -0,0 +1,2 @@
+kind: autotools
+description: Some kinda autotools element
diff --git a/tests/variables/defaults/cmake.bst b/tests/variables/defaults/cmake.bst
new file mode 100644
index 000000000..4e7db662c
--- /dev/null
+++ b/tests/variables/defaults/cmake.bst
@@ -0,0 +1,2 @@
+kind: cmake
+description: Some kinda cmake element
diff --git a/tests/variables/defaults/distutils.bst b/tests/variables/defaults/distutils.bst
new file mode 100644
index 000000000..2354bea39
--- /dev/null
+++ b/tests/variables/defaults/distutils.bst
@@ -0,0 +1,2 @@
+kind: distutils
+description: Some kinda distutils element
diff --git a/tests/variables/defaults/makemaker.bst b/tests/variables/defaults/makemaker.bst
new file mode 100644
index 000000000..2205cece1
--- /dev/null
+++ b/tests/variables/defaults/makemaker.bst
@@ -0,0 +1,2 @@
+kind: makemaker
+description: Some kinda makemaker element
diff --git a/tests/variables/defaults/modulebuild.bst b/tests/variables/defaults/modulebuild.bst
new file mode 100644
index 000000000..5b5e9b91a
--- /dev/null
+++ b/tests/variables/defaults/modulebuild.bst
@@ -0,0 +1,2 @@
+kind: modulebuild
+description: Some kinda modulebuild element
diff --git a/tests/variables/defaults/project.conf b/tests/variables/defaults/project.conf
new file mode 100644
index 000000000..2027cc27a
--- /dev/null
+++ b/tests/variables/defaults/project.conf
@@ -0,0 +1,3 @@
+# Basic project configuration that doesnt override anything
+#
+name: pony
diff --git a/tests/variables/defaults/qmake.bst b/tests/variables/defaults/qmake.bst
new file mode 100644
index 000000000..53209760d
--- /dev/null
+++ b/tests/variables/defaults/qmake.bst
@@ -0,0 +1,2 @@
+kind: qmake
+description: Some kinda qmake element
diff --git a/tests/variables/overrides/autotools.bst b/tests/variables/overrides/autotools.bst
new file mode 100644
index 000000000..35c62ce8e
--- /dev/null
+++ b/tests/variables/overrides/autotools.bst
@@ -0,0 +1,6 @@
+kind: autotools
+description: Some kinda autotools element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/overrides/cmake.bst b/tests/variables/overrides/cmake.bst
new file mode 100644
index 000000000..e7fadc42a
--- /dev/null
+++ b/tests/variables/overrides/cmake.bst
@@ -0,0 +1,6 @@
+kind: cmake
+description: Some kinda cmake element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/overrides/distutils.bst b/tests/variables/overrides/distutils.bst
new file mode 100644
index 000000000..624f775a5
--- /dev/null
+++ b/tests/variables/overrides/distutils.bst
@@ -0,0 +1,6 @@
+kind: distutils
+description: Some kinda distutils element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/overrides/makemaker.bst b/tests/variables/overrides/makemaker.bst
new file mode 100644
index 000000000..faa5f365f
--- /dev/null
+++ b/tests/variables/overrides/makemaker.bst
@@ -0,0 +1,6 @@
+kind: makemaker
+description: Some kinda makemaker element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/overrides/modulebuild.bst b/tests/variables/overrides/modulebuild.bst
new file mode 100644
index 000000000..db50057e2
--- /dev/null
+++ b/tests/variables/overrides/modulebuild.bst
@@ -0,0 +1,6 @@
+kind: modulebuild
+description: Some kinda modulebuild element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/overrides/project.conf b/tests/variables/overrides/project.conf
new file mode 100644
index 000000000..2027cc27a
--- /dev/null
+++ b/tests/variables/overrides/project.conf
@@ -0,0 +1,3 @@
+# Basic project configuration that doesnt override anything
+#
+name: pony
diff --git a/tests/variables/overrides/qmake.bst b/tests/variables/overrides/qmake.bst
new file mode 100644
index 000000000..5dff2c944
--- /dev/null
+++ b/tests/variables/overrides/qmake.bst
@@ -0,0 +1,6 @@
+kind: qmake
+description: Some kinda qmake element
+
+variables:
+ install-root: /custom/install/root
+ prefix: /opt
diff --git a/tests/variables/variables.py b/tests/variables/variables.py
new file mode 100644
index 000000000..724d64786
--- /dev/null
+++ b/tests/variables/variables.py
@@ -0,0 +1,72 @@
+import os
+import pytest
+
+from buildstream import Context, Project, BuildElement
+from buildstream._pipeline import Pipeline
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+)
+
+
+def create_pipeline(tmpdir, basedir, target, variant):
+ context = Context('x86_64')
+ project = Project(basedir)
+
+ context.deploydir = os.path.join(str(tmpdir), 'deploy')
+ context.artifactdir = os.path.join(str(tmpdir), 'artifact')
+
+ return Pipeline(context, project, target, variant)
+
+
+def assert_command(datafiles, tmpdir, target, command, expected):
+ basedir = os.path.join(datafiles.dirname, datafiles.basename)
+ pipeline = create_pipeline(tmpdir, basedir, target, None)
+ assert(isinstance(pipeline.target, BuildElement))
+
+ commands = pipeline.target.commands
+ assert(commands.get(command) is not None)
+ assert(len(commands[command]) > 0)
+
+ print("Commands:\n%s" % commands[command][0])
+ print("Expected:\n%s" % expected)
+
+ assert(commands[command][0] == expected)
+
+
+###############################################################
+# Test proper loading of some default commands from plugins #
+###############################################################
+@pytest.mark.parametrize("target,command,expected", [
+ ('autotools.bst', 'install-commands', "make DESTDIR=\"/buildstream/install\" install"),
+ ('cmake.bst', 'configure-commands', "cmake -DCMAKE_INSTALL_PREFIX=\"/usr\""),
+ ('distutils.bst', 'install-commands',
+ "python3 setup.py install \\\n" +
+ " --prefix \"/usr\" \\\n" +
+ " --root \"/buildstream/install\""),
+ ('makemaker.bst', 'configure-commands', "perl Makefile.PL PREFIX=/buildstream/install/usr"),
+ ('modulebuild.bst', 'configure-commands', "perl Build.PL --prefix \"/buildstream/install/usr\""),
+ ('qmake.bst', 'install-commands', "make INSTALL_ROOT=\"/buildstream/install\" install"),
+])
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
+def test_defaults(datafiles, tmpdir, target, command, expected):
+ assert_command(datafiles, tmpdir, target, command, expected)
+
+
+################################################################
+# Test overriding of variables to produce different commands #
+################################################################
+@pytest.mark.parametrize("target,command,expected", [
+ ('autotools.bst', 'install-commands', "make DESTDIR=\"/custom/install/root\" install"),
+ ('cmake.bst', 'configure-commands', "cmake -DCMAKE_INSTALL_PREFIX=\"/opt\""),
+ ('distutils.bst', 'install-commands',
+ "python3 setup.py install \\\n" +
+ " --prefix \"/opt\" \\\n" +
+ " --root \"/custom/install/root\""),
+ ('makemaker.bst', 'configure-commands', "perl Makefile.PL PREFIX=/custom/install/root/opt"),
+ ('modulebuild.bst', 'configure-commands', "perl Build.PL --prefix \"/custom/install/root/opt\""),
+ ('qmake.bst', 'install-commands', "make INSTALL_ROOT=\"/custom/install/root\" install"),
+])
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'overrides'))
+def test_overrides(datafiles, tmpdir, target, command, expected):
+ assert_command(datafiles, tmpdir, target, command, expected)