/usr/lib/python3/dist-packages/plainbox/impl/test_buildsystems.py is in python3-plainbox 0.25-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | # This file is part of Checkbox.
#
# Copyright 2014 Canonical Ltd.
# Written by:
# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
"""
plainbox.impl.test_buildsystems
===============================
Test definitions for plainbox.impl.buildsystems module
"""
from unittest import TestCase
from plainbox.impl.buildsystems import GoBuildSystem
from plainbox.impl.buildsystems import MakefileBuildSystem
from plainbox.impl.buildsystems import AutotoolsBuildSystem
from plainbox.vendor import mock
class GoBuildSystemTests(TestCase):
"""
Unit tests for the GoBuildSystem class
"""
def setUp(self):
self.buildsystem = GoBuildSystem()
@mock.patch('plainbox.impl.buildsystems.glob.glob')
def test_probe__go_sources(self, mock_glob):
"""
Ensure that if we have some go sources then the build system finds them
and signals suitability
"""
mock_glob.return_value = ['src/foo.go']
self.assertEqual(self.buildsystem.probe("src"), 50)
@mock.patch('plainbox.impl.buildsystems.glob.glob')
def test_probe__no_go_sources(self, mock_glob):
"""
Ensure that if we don't have any go sources the build system is not
suitable
"""
mock_glob.return_value = []
self.assertEqual(self.buildsystem.probe("src"), 0)
def test_get_build_command(self):
"""
Ensure that the build command is correct
"""
self.assertEqual(
self.buildsystem.get_build_command(
"/path/to/src", "/path/to/build/bin"),
"go build ../../src/*.go")
class MakefileBuildSystemTests(TestCase):
"""
Unit tests for the MakefileBuildSystem class
"""
def setUp(self):
self.buildsystem = MakefileBuildSystem()
@mock.patch('plainbox.impl.buildsystems.os.path.isfile')
def test_probe__Makefile(self, mock_isfile):
"""
Ensure that if we have a Makefile then the build system finds it and
signals suitability
"""
mock_isfile.side_effect = lambda path: path == 'src/Makefile'
self.assertEqual(self.buildsystem.probe("src"), 90)
@mock.patch('plainbox.impl.buildsystems.os.path.isfile')
def test_probe__no_Makefile(self, mock_isfile):
"""
Ensure that if we don't have a Makefile then the build system is not
suitable
"""
mock_isfile.side_effect = lambda path: False
self.assertEqual(self.buildsystem.probe("src"), 0)
@mock.patch('plainbox.impl.buildsystems.os.path.isfile')
def test_probe__configure_and_Makefile(self, mock_isfile):
"""
Ensure that if we have a configure script then the build system finds
it and signals lack of suitability, we want developers to specifically
tell us how to build with a configure script around.
"""
mock_isfile.side_effect = lambda path: path in ('src/Makefile',
'src/configure')
self.assertEqual(self.buildsystem.probe("src"), 0)
def test_get_build_command(self):
"""
Ensure that the build command is correct
"""
self.assertEqual(
self.buildsystem.get_build_command(
"/path/to/src", "/path/to/build/bin"),
"VPATH=../../src make -f ../../src/Makefile")
class AutotoolsBuildSystemTests(TestCase):
"""
Unit tests for the AutotoolsBuildSystem class
"""
def setUp(self):
self.buildsystem = AutotoolsBuildSystem()
@mock.patch('plainbox.impl.buildsystems.os.path.isfile')
def test_probe__probe(self, mock_isfile):
"""
Ensure that if we have a configure script then the build system finds
it and signals suitability
"""
mock_isfile.side_effect = lambda path: path == 'src/configure'
self.assertEqual(self.buildsystem.probe("src"), 90)
@mock.patch('plainbox.impl.buildsystems.os.path.isfile')
def test_probe__no_configure(self, mock_isfile):
"""
Ensure that if we don't have a configure script then the build system
is not suitable
"""
mock_isfile.side_effect = lambda path: False
self.assertEqual(self.buildsystem.probe("src"), 0)
def test_get_build_command(self):
"""
Ensure that the build command is correct
"""
self.assertEqual(
self.buildsystem.get_build_command(
"/path/to/src", "/path/to/build/bin"),
"../../src/configure && make")
|