Ejemplo n.º 1
0
# 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 this program.  If not, see <http://www.gnu.org/licenses/>.
#

from buildfarm import BuildFarm
import optparse
import sys

parser = optparse.OptionParser("")
parser.add_option("--tree", help="Print builds for a specific tree.", type=str)
parser.add_option("--last", help="Print last builds.", action="store_true")

(opts, args) = parser.parse_args()

buildfarm = BuildFarm()

if opts.tree:
    builds = buildfarm.get_tree_builds(opts.tree)
elif opts.last:
    builds = buildfarm.get_last_builds()
else:
    parser.print_usage()
    sys.exit(1)

for build in builds:
    print build
Ejemplo n.º 2
0
class BuildFarmTests(BuildFarmTestCase):

    def setUp(self):
        super(BuildFarmTests, self).setUp()
        self.buildfarm = BuildFarm(self.path)
        self.write_compilers(["cc"])
        self.write_hosts({"myhost": "Fedora",
                          "charis": "Debian"})
        self.write_trees({"trivial": {"scm": "git", "repo": "git://foo", "branch": "master"},
                          "other": {"scm": "git", "repo": "other.git", "branch": "HEAD"}})
        self.buildfarm.commit()
        self.x = BuildFarm(self.path)

    def test_get_new_builds_empty(self):
        self.assertEquals([], list(self.x.get_new_builds()))

    def test_get_last_builds_empty(self):
        self.assertEquals([], list(self.x.get_last_builds()))

    def test_get_tree_builds_empty(self):
        self.assertEquals([], list(self.x.get_tree_builds("trival")))

    def test_get_tree_builds(self):
        path = self.upload_mock_logfile(self.x.builds, "tdb", "myhost", "gcc",
            stdout_contents="BUILD COMMIT REVISION: 12\n", mtime=1200)
        path = self.upload_mock_logfile(self.x.builds, "tdb", "myhost", "cc",
            stdout_contents="BUILD COMMIT REVISION: 13\n", mtime=1300)
        path = self.upload_mock_logfile(self.x.builds, "tdb", "myhost", "cc",
            stdout_contents="BUILD COMMIT REVISION: 42\n", mtime=4200)
        builds = list(self.x.get_tree_builds("tdb"))
        self.assertEquals(["42", "12"], [x.revision for x in builds])

    def test_get_last_builds(self):
        path = self.upload_mock_logfile(self.x.builds, "other", "myhost", "cc",
            "BUILD COMMIT REVISION: 12\n", mtime=1200)
        path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
            "BUILD COMMIT REVISION: 13\n", mtime=1300)
        path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
            "BUILD COMMIT REVISION: 42\n", mtime=4200)
        builds = list(self.x.get_last_builds())
        self.assertEquals(2, len(builds))
        self.assertEquals(4200, builds[0].upload_time)
        self.assertEquals("42", builds[0].revision_details())
        self.assertEquals("trivial", builds[0].tree)
        self.assertEquals(1200, builds[1].upload_time)
        self.assertEquals("12", builds[1].revision_details())
        self.assertEquals("other", builds[1].tree)

    def test_get_summary_builds_empty(self):
        self.assertEquals([], list(self.x.get_summary_builds()))

    def test_get_summary_builds(self):
        path = self.upload_mock_logfile(self.x.builds, "other", "myhost", "cc",
            "BUILD COMMIT REVISION: 12\n", mtime=1200)
        path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
            "BUILD COMMIT REVISION: 13\n", mtime=1300)
        path = self.upload_mock_logfile(self.x.builds, "trivial", "myhost", "cc",
            "BUILD COMMIT REVISION: 42\n", mtime=4200)
        builds = list(self.x.get_summary_builds())
        self.assertEquals(2, len(builds))
        self.assertEquals("other", builds[0][0])
        self.assertEquals("trivial", builds[1][0])
        builds = list(self.x.get_summary_builds(min_age=4000))
        self.assertEquals(1, len(builds))
        builds = list(self.x.get_summary_builds(min_age=5000))
        self.assertEquals(0, len(builds))

    def test_get_host_builds_empty(self):
        self.assertEquals([], list(self.x.get_host_builds("myhost")))

    def test_lcov_status_none(self):
        self.assertRaises(NoSuchBuildError, self.x.lcov_status, "trivial")

    def test_tree(self):
        self.assertEquals("trivial", self.x.trees["trivial"].name)
        tree = self.x.trees["trivial"]
        self.assertEquals("git", tree.scm)
        self.assertEquals("git://foo", tree.repo)
        self.assertEquals("master", tree.branch)

    def test_get_build_rev(self):
        path = self.upload_mock_logfile(self.x.builds, "tdb", "charis", "cc",
            stdout_contents="tHIS is what a log file looks like.\n"
            "BUILD COMMIT REVISION: 12\n")
        build = self.x.get_build("tdb", "charis", "cc", "12")
        self.assertEquals("tdb", build.tree)
        self.assertEquals("charis", build.host)
        self.assertEquals("cc", build.compiler)
        self.assertEquals("12", build.revision)

    def test_get_build_no_rev(self):
        path = self.create_mock_logfile("tdb", "charis", "cc",
            contents="This is what a log file looks like.")
        build = self.x.get_build("tdb", "charis", "cc")
        self.assertEquals("tdb", build.tree)
        self.assertEquals("charis", build.host)
        self.assertEquals("cc", build.compiler)
        self.assertIs(None, build.revision)