blob: 233781d88277a1f47c8a86ab17b4fcbfd9e91745 [file] [log] [blame]
Tim Bain65069d12024-05-10 04:07:111#!/usr/bin/env python3
2# Copyright 2024 The ChromiumOS Authors
David Rochberg7c79a812011-01-19 19:24:453# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
Gilad Arnoldabb352e2012-09-23 08:24:275
Don Garrettfb15e322016-06-22 02:12:086"""Unittests for builder.py."""
7
8from __future__ import print_function
9
David Rochberg7c79a812011-01-19 19:24:4510import subprocess
11import unittest
12
Tim Bain65069d12024-05-10 04:07:1113import builder # pylint: disable=import-error
David Rochberg7c79a812011-01-19 19:24:4514
Jack Rosenthal8de609d2023-02-09 20:20:3515
Don Garrettfb15e322016-06-22 02:12:0816# pylint: disable=protected-access
David Rochberg7c79a812011-01-19 19:24:4517
Jack Rosenthal8de609d2023-02-09 20:20:3518
David Rochberg7c79a812011-01-19 19:24:4519class BuilderTest(unittest.TestCase):
Jack Rosenthal8de609d2023-02-09 20:20:3520 """Tests for builder."""
David Rochberg7c79a812011-01-19 19:24:4521
Jack Rosenthal8de609d2023-02-09 20:20:3522 def testOutputOf(self):
23 self.assertRaises(
24 subprocess.CalledProcessError, builder._OutputOf, ["/bin/false"]
25 )
26
27 hello = "hello, world"
28 self.assertEqual(hello + "\n", builder._OutputOf(["/bin/echo", hello]))
David Rochberg7c79a812011-01-19 19:24:4529
Tim Bain65069d12024-05-10 04:07:1130 def testBuild(self):
31 b = builder.Builder()
32 result = b.Build("amd64-generic", "sys-apps/attr", {})
33 self.assertEqual("Success\n", result)
34
David Rochberg7c79a812011-01-19 19:24:4535
Jack Rosenthal8de609d2023-02-09 20:20:3536if __name__ == "__main__":
37 unittest.main()