| 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.integration import assert_contains |
| 22 |
from buildstream._testing.integration import integration_cache # pylint: disable=unused-import |
| 23 |
from buildstream._testing.runcli import cli_integration as cli # pylint: disable=unused-import |
| 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__)), "make") |
| 30 |
|
| 31 |
|
| 32 |
# Test that a make build 'works' - we use the make sample |
| 33 |
# makehello project for this. |
| 34 |
@pytest.mark.datafiles(DATA_DIR) |
| 35 |
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") |
| 36 |
def test_make_build(cli, datafiles): |
| 37 |
project = str(datafiles) |
| 38 |
checkout = os.path.join(cli.directory, "checkout") |
| 39 |
element_name = "makehello.bst" |
| 40 |
|
| 41 |
result = cli.run(project=project, args=["build", element_name]) |
| 42 |
assert result.exit_code == 0 |
| 43 |
|
| 44 |
result = cli.run( |
| 45 |
project=project, |
| 46 |
args=["artifact", "checkout", element_name, "--directory", checkout], |
| 47 |
) |
| 48 |
assert result.exit_code == 0 |
| 49 |
|
| 50 |
assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"]) |
| 51 |
|
| 52 |
|
| 53 |
# Test running an executable built with make |
| 54 |
@pytest.mark.datafiles(DATA_DIR) |
| 55 |
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") |
| 56 |
def test_make_run(cli, datafiles): |
| 57 |
project = str(datafiles) |
| 58 |
element_name = "makehello.bst" |
| 59 |
|
| 60 |
result = cli.run(project=project, args=["build", element_name]) |
| 61 |
assert result.exit_code == 0 |
| 62 |
|
| 63 |
result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"]) |
| 64 |
assert result.exit_code == 0 |
| 65 |
assert result.output == "Hello, world\n" |