Debian Codegraph @

tests/elements/setuptools.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__)), "setuptools")
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_setuptools_build(cli, datafiles):
35 project = str(datafiles)
36 checkout = os.path.join(cli.directory, "checkout")
37 element_name = "setuptoolshello.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_setuptools_run(cli, datafiles):
54 project = str(datafiles)
55 element_name = "setuptoolshello.bst"
56
57 result = cli.run(project=project, args=["build", element_name])
58 assert result.exit_code == 0
59
60 result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"])
61 assert result.exit_code == 0
62
63 assert result.output == """Hello World!\n"""