Debian Codegraph @

tests/elements/cmake.py

raw
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 #
14
15 # Pylint doesn't play well with fixtures and dependency injection from pytest
16 # pylint: disable=redefined-outer-name
17
18 import os
19 import pytest
20
21 from buildstream._testing.runcli import cli_integration as cli # pylint: disable=unused-import
22 from buildstream._testing.integration import integration_cache # pylint: disable=unused-import
23 from buildstream._testing.integration import assert_contains
24 from buildstream._testing._utils.site import HAVE_SANDBOX
25
26 pytestmark = pytest.mark.integration
27
28
29 DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "cmake")
30
31
32 @pytest.mark.datafiles(DATA_DIR)
33 @pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
34 def test_cmake_build(cli, datafiles):
35 project = str(datafiles)
36 checkout = os.path.join(cli.directory, "checkout")
37 element_name = "cmakehello.bst"
38
39 result = cli.run(project=project, args=["build", element_name])
40 assert result.exit_code == 0
41
42 result = cli.run(
43 project=project,
44 args=["artifact", "checkout", element_name, "--directory", checkout],
45 )
46 assert result.exit_code == 0
47
48 assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
49
50
51 @pytest.mark.datafiles(DATA_DIR)
52 @pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
53 def test_cmake_confroot_build(cli, datafiles):
54 project = str(datafiles)
55 checkout = os.path.join(cli.directory, "checkout")
56 element_name = "cmakeconfroothello.bst"
57
58 result = cli.run(project=project, args=["build", element_name])
59 assert result.exit_code == 0
60
61 result = cli.run(
62 project=project,
63 args=["artifact", "checkout", element_name, "--directory", checkout],
64 )
65 assert result.exit_code == 0
66
67 assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
68
69
70 @pytest.mark.datafiles(DATA_DIR)
71 @pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
72 def test_cmake_run(cli, datafiles):
73 project = str(datafiles)
74 element_name = "cmakehello.bst"
75
76 result = cli.run(project=project, args=["build", element_name])
77 assert result.exit_code == 0
78
79 result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"])
80 assert result.exit_code == 0
81
82 assert (
83 result.output
84 == """Hello World!
85 This is hello.
86 """
87 )