mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-04 00:53:47 -06:00
feat: paint the installer with colour roles
One table of roles from the 16 basic colours (accent, success, warning, failure, muted, strong, selected) read by the full screen and by the end of a line-mode run. Status words take their role from one pattern table, the text never changes, and colour is off with NO_COLOR, TERM dumb or unset, a terminfo entry naming fewer than 8 colours, or an output that is not a terminal. Colour goldens keep the escape codes, and a test strips them back to the text goldens.
This commit is contained in:
1 parent
1f6c018006
commit
230885b77f
11 files changed
+2672
-120
No files matched your search
@@ -918,6 +918,37 @@ class ColourFollowsNoColorOrg(unittest.TestCase):
|
||||
self.assertFalse(term.live)
|
||||
|
||||
|
||||
class TheEndOfARunPaintsItsStatusWords(unittest.TestCase):
|
||||
"""Line mode ends on the words the full screen paints, in the same
|
||||
roles, and on the same text without colour."""
|
||||
|
||||
def _end(self, colour: bool, *counts: int, **given) -> str:
|
||||
term = install.Terminal(io.StringIO())
|
||||
term.colour = colour
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.suppress(SystemExit):
|
||||
install._report_outcome([Path("bios")], *counts, term=term, **given)
|
||||
return out.getvalue()
|
||||
|
||||
def test_the_same_words_with_and_without_colour(self):
|
||||
for counts, given, painted in (
|
||||
((3, 1, 1, 0, False), {"failures": [("a.bin", "HTTP 404")]},
|
||||
(("failure", "Finished with errors"), ("success", "3 files installed"),
|
||||
("failure", "1 file failed"), ("failure", "failed:"))),
|
||||
((2, 1, 0, 0, False), {},
|
||||
(("success", "Done"), ("success", "2 files installed"),
|
||||
("success", "1 file already up to date"))),
|
||||
((1, 0, 0, 0, False), {"offline": 2},
|
||||
(("warning", "Finished with files missing"), ("warning", "2 not fetched")))):
|
||||
with self.subTest(counts=counts):
|
||||
plain, coloured = self._end(False, *counts, **given), \
|
||||
self._end(True, *counts, **given)
|
||||
self.assertNotIn("\x1b", plain)
|
||||
self.assertEqual(install.unpainted(coloured), plain)
|
||||
for role, word in painted:
|
||||
self.assertIn(install._sgr(role) + word, coloured)
|
||||
|
||||
|
||||
class SmallWordings(unittest.TestCase):
|
||||
def test_check_asks_which_to_check(self):
|
||||
"""--check with several platforms asked "Install for:", and
|
||||
|
||||
Reference in new issue
Block a user