summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Smyth <phillip.smyth@codethink.co.uk>2018-11-07 13:04:03 +0000
committerJürg Billeter <j@bitron.ch>2019-01-24 14:38:50 +0100
commit774145187ffd9b3c81652e103886e22153055413 (patch)
tree345af142af6c0969032a5a91230de0957deb0819
parent5a351deeda89d32d1c8b559a5ebd55767ff97a22 (diff)
downloadbuildstream-774145187ffd9b3c81652e103886e22153055413.tar.gz
tests/frontend: Add default target tests for bst show and build
-rw-r--r--tests/frontend/buildcheckout.py30
-rw-r--r--tests/frontend/project_default/elements/target.bst4
-rw-r--r--tests/frontend/project_default/elements/target2.bst4
-rw-r--r--tests/frontend/project_default/project.conf11
-rw-r--r--tests/frontend/project_fail/elements/compose-all.bst10
-rw-r--r--tests/frontend/project_fail/elements/import-dev.bst4
-rw-r--r--tests/frontend/project_fail/elements/target.bst7
-rw-r--r--tests/frontend/project_fail/files/dev-files/usr/include/pony.h12
-rw-r--r--tests/frontend/project_fail/project.conf4
-rw-r--r--tests/frontend/project_world/elements/checkout-deps.bst7
-rw-r--r--tests/frontend/project_world/elements/compose-all.bst12
-rw-r--r--tests/frontend/project_world/elements/compose-exclude-dev.bst16
-rw-r--r--tests/frontend/project_world/elements/compose-include-bin.bst16
-rw-r--r--tests/frontend/project_world/elements/import-bin.bst1
-rw-r--r--tests/frontend/project_world/elements/import-dev.bst1
-rw-r--r--tests/frontend/project_world/elements/rebuild-target.bst4
-rw-r--r--tests/frontend/project_world/elements/target.bst8
-rw-r--r--tests/frontend/project_world/project.conf7
-rw-r--r--tests/frontend/show.py21
19 files changed, 179 insertions, 0 deletions
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 8c7e22a85..156fab990 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -2,6 +2,7 @@ import os
import tarfile
import hashlib
import pytest
+import subprocess
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
from tests.testutils.site import IS_WINDOWS
@@ -61,6 +62,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
assert os.path.exists(filename)
+@pytest.mark.datafiles(DATA_DIR + "_world")
+def test_build_default_all(datafiles, cli):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
+ output_dir = os.path.join(cli.directory, "logs", "test")
+
+ expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
+ expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
+
+ results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
+ results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
+
+ assert results == expected
+
+
+@pytest.mark.datafiles(DATA_DIR + "_default")
+def test_build_default(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ results = cli.get_element_state(project, "target2.bst")
+ expected = "cached"
+ assert results == expected
+
+
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("strict,hardlinks", [
("non-strict", "hardlinks"),
diff --git a/tests/frontend/project_default/elements/target.bst b/tests/frontend/project_default/elements/target.bst
new file mode 100644
index 000000000..d644c89ba
--- /dev/null
+++ b/tests/frontend/project_default/elements/target.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
diff --git a/tests/frontend/project_default/elements/target2.bst b/tests/frontend/project_default/elements/target2.bst
new file mode 100644
index 000000000..d644c89ba
--- /dev/null
+++ b/tests/frontend/project_default/elements/target2.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
diff --git a/tests/frontend/project_default/project.conf b/tests/frontend/project_default/project.conf
new file mode 100644
index 000000000..5987c82f1
--- /dev/null
+++ b/tests/frontend/project_default/project.conf
@@ -0,0 +1,11 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements
+
+fatal-warnings:
+- bad-element-suffix
+
+defaults:
+ targets:
+ - target2.bst
diff --git a/tests/frontend/project_fail/elements/compose-all.bst b/tests/frontend/project_fail/elements/compose-all.bst
new file mode 100644
index 000000000..9b981dd73
--- /dev/null
+++ b/tests/frontend/project_fail/elements/compose-all.bst
@@ -0,0 +1,10 @@
+kind: compose
+
+depends:
+- fileNAME: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
diff --git a/tests/frontend/project_fail/elements/import-dev.bst b/tests/frontend/project_fail/elements/import-dev.bst
new file mode 100644
index 000000000..152a54667
--- /dev/null
+++ b/tests/frontend/project_fail/elements/import-dev.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/dev-files
diff --git a/tests/frontend/project_fail/elements/target.bst b/tests/frontend/project_fail/elements/target.bst
new file mode 100644
index 000000000..154c477e6
--- /dev/null
+++ b/tests/frontend/project_fail/elements/target.bst
@@ -0,0 +1,7 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
+
+depends:
+- compose-all.bst
diff --git a/tests/frontend/project_fail/files/dev-files/usr/include/pony.h b/tests/frontend/project_fail/files/dev-files/usr/include/pony.h
new file mode 100644
index 000000000..40bd0c2e7
--- /dev/null
+++ b/tests/frontend/project_fail/files/dev-files/usr/include/pony.h
@@ -0,0 +1,12 @@
+#ifndef __PONY_H__
+#define __PONY_H__
+
+#define PONY_BEGIN "Once upon a time, there was a pony."
+#define PONY_END "And they lived happily ever after, the end."
+
+#define MAKE_PONY(story) \
+ PONY_BEGIN \
+ story \
+ PONY_END
+
+#endif /* __PONY_H__ */
diff --git a/tests/frontend/project_fail/project.conf b/tests/frontend/project_fail/project.conf
new file mode 100644
index 000000000..854e38693
--- /dev/null
+++ b/tests/frontend/project_fail/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements
diff --git a/tests/frontend/project_world/elements/checkout-deps.bst b/tests/frontend/project_world/elements/checkout-deps.bst
new file mode 100644
index 000000000..e3a548690
--- /dev/null
+++ b/tests/frontend/project_world/elements/checkout-deps.bst
@@ -0,0 +1,7 @@
+kind: stack
+description: It is important for this element to have both build and runtime dependencies
+depends:
+- filename: import-dev.bst
+ type: build
+- filename: import-bin.bst
+ type: runtime
diff --git a/tests/frontend/project_world/elements/compose-all.bst b/tests/frontend/project_world/elements/compose-all.bst
new file mode 100644
index 000000000..ba47081b3
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-all.bst
@@ -0,0 +1,12 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
diff --git a/tests/frontend/project_world/elements/compose-exclude-dev.bst b/tests/frontend/project_world/elements/compose-exclude-dev.bst
new file mode 100644
index 000000000..75c14378c
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-exclude-dev.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Exclude the dev domain
+ exclude:
+ - devel
diff --git a/tests/frontend/project_world/elements/compose-include-bin.bst b/tests/frontend/project_world/elements/compose-include-bin.bst
new file mode 100644
index 000000000..9571203c6
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-include-bin.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Only include the runtim
+ include:
+ - runtime
diff --git a/tests/frontend/project_world/elements/import-bin.bst b/tests/frontend/project_world/elements/import-bin.bst
new file mode 100644
index 000000000..066a03328
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-bin.bst
@@ -0,0 +1 @@
+kind: stack
diff --git a/tests/frontend/project_world/elements/import-dev.bst b/tests/frontend/project_world/elements/import-dev.bst
new file mode 100644
index 000000000..066a03328
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-dev.bst
@@ -0,0 +1 @@
+kind: stack
diff --git a/tests/frontend/project_world/elements/rebuild-target.bst b/tests/frontend/project_world/elements/rebuild-target.bst
new file mode 100644
index 000000000..49a02c217
--- /dev/null
+++ b/tests/frontend/project_world/elements/rebuild-target.bst
@@ -0,0 +1,4 @@
+kind: compose
+
+build-depends:
+- target.bst
diff --git a/tests/frontend/project_world/elements/target.bst b/tests/frontend/project_world/elements/target.bst
new file mode 100644
index 000000000..b9432fafa
--- /dev/null
+++ b/tests/frontend/project_world/elements/target.bst
@@ -0,0 +1,8 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
+
+depends:
+- import-bin.bst
+- compose-all.bst
diff --git a/tests/frontend/project_world/project.conf b/tests/frontend/project_world/project.conf
new file mode 100644
index 000000000..a7e4a023c
--- /dev/null
+++ b/tests/frontend/project_world/project.conf
@@ -0,0 +1,7 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements
+
+fatal-warnings:
+- bad-element-suffix
diff --git a/tests/frontend/show.py b/tests/frontend/show.py
index 9c32dd664..88f38dd6a 100644
--- a/tests/frontend/show.py
+++ b/tests/frontend/show.py
@@ -45,6 +45,27 @@ def test_show_invalid_element_path(cli, datafiles):
'show',
"foo.bst"])
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project_default'))
+def test_show_default(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=[
+ 'show'])
+
+ result.assert_success()
+
+ # Get the result output of "[state sha element]" and turn into a list
+ results = result.output.strip().split(" ")
+ expected = 'target2.bst'
+ assert results[2] == expected
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project_fail'))
+def test_show_fail(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=[
+ 'show'])
+
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)