Tim Bain | 65069d1 | 2024-05-10 04:07:11 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright 2024 The ChromiumOS Authors |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
Gilad Arnold | abb352e | 2012-09-23 08:24:27 | [diff] [blame] | 5 | |
Don Garrett | fb15e32 | 2016-06-22 02:12:08 | [diff] [blame] | 6 | """Unittests for builder.py.""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 10 | import subprocess |
| 11 | import unittest |
| 12 | |
Tim Bain | 65069d1 | 2024-05-10 04:07:11 | [diff] [blame] | 13 | import builder # pylint: disable=import-error |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 14 | |
Jack Rosenthal | 8de609d | 2023-02-09 20:20:35 | [diff] [blame] | 15 | |
Don Garrett | fb15e32 | 2016-06-22 02:12:08 | [diff] [blame] | 16 | # pylint: disable=protected-access |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 17 | |
Jack Rosenthal | 8de609d | 2023-02-09 20:20:35 | [diff] [blame] | 18 | |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 19 | class BuilderTest(unittest.TestCase): |
Jack Rosenthal | 8de609d | 2023-02-09 20:20:35 | [diff] [blame] | 20 | """Tests for builder.""" |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 21 | |
Jack Rosenthal | 8de609d | 2023-02-09 20:20:35 | [diff] [blame] | 22 | 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 Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 29 | |
Tim Bain | 65069d1 | 2024-05-10 04:07:11 | [diff] [blame] | 30 | def testBuild(self): |
| 31 | b = builder.Builder() |
| 32 | result = b.Build("amd64-generic", "sys-apps/attr", {}) |
| 33 | self.assertEqual("Success\n", result) |
| 34 | |
David Rochberg | 7c79a81 | 2011-01-19 19:24:45 | [diff] [blame] | 35 | |
Jack Rosenthal | 8de609d | 2023-02-09 20:20:35 | [diff] [blame] | 36 | if __name__ == "__main__": |
| 37 | unittest.main() |