build / build (push) Canceled after 0s
- /etc/issue shows the Das OS version instead of the kernel's; the server installer carries it into the installed system. - das-server-installer: setfont -C /dev/tty0 before the language menu (sudo runs it in its own pty, so the Cyrillic was drawn as Latin), and floppy drives are no longer offered as install targets. - ncdu on the desktop image and in das-server 0.4.0. - das-shell 0.2.0: each prompt line sets its own color; the dbanner start screen buttons are no longer covered by the key bar; on the Linux console (TERM=linux) dprompt and dbanner draw solid borders and swap the glyphs that no console font has (▊▎▔▁ and others) for ones it has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
3.7 KiB
Python
92 lines
3.7 KiB
Python
import datetime
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import unittest
|
|
|
|
from tests.common import FILES, SCRATCH
|
|
|
|
from das_shell import prompt # noqa: E402
|
|
|
|
NOW = datetime.datetime(2026, 10, 21, 8, 12)
|
|
|
|
|
|
def text(design, **state):
|
|
return prompt.preview_text(design, prompt.sample_state(now=NOW, **state))
|
|
|
|
|
|
class PresetTest(unittest.TestCase):
|
|
def test_presets_load(self):
|
|
names = [n for n, _ in prompt.list_presets()]
|
|
self.assertEqual(names[0], "das")
|
|
self.assertTrue({"das", "das-git", "classic", "minimal", "server"} <= set(names))
|
|
|
|
def test_das_matches_the_authors_prompt(self):
|
|
d = prompt.load_preset("das")
|
|
self.assertEqual(text(d), "┌─[das@dasos]─[2026-10-21]─[08:12]─[~/Projects/web]\n└─╼ $ ")
|
|
self.assertEqual(text(d, rc=1), "┌─[✗]─[das@dasos]─[2026-10-21]─[08:12]─[~/Projects/web]\n└─╼ $ ")
|
|
self.assertEqual(text(d, root=True), "┌─[root@dasos]─[2026-10-21]─[08:12]─[/etc/sv]\n└─╼ # ")
|
|
|
|
def test_classic_is_void(self):
|
|
self.assertEqual(text(prompt.load_preset("classic")), "[das@dasos web]$ ")
|
|
|
|
def test_hidden_parts_take_their_separator(self):
|
|
d = prompt.load_preset("das-git")
|
|
self.assertNotIn("──", text(d))
|
|
self.assertIn("─[main*]─[.venv]─[jobs:2]", text(d, git="main*", venv=".venv", jobs=2))
|
|
|
|
def test_each_line_sets_its_color(self):
|
|
# Readline redraws only the last line, so it must not rely on the first
|
|
ps1 = prompt.script(prompt.load_preset("das")).split("PS1='", 1)[1].split("'", 1)[0]
|
|
self.assertTrue(ps1.split("\n")[1].startswith("\\[\\e[0;31m\\]└"), ps1)
|
|
|
|
def test_unknown_segments_are_dropped(self):
|
|
d = prompt.normalize({"segments": [{"type": "nope"}, {"type": "cwd"}]})
|
|
self.assertEqual([s["type"] for s in d["segments"]], ["cwd"])
|
|
|
|
|
|
@unittest.skipUnless(shutil.which("bash"), "needs bash")
|
|
class BashTest(unittest.TestCase):
|
|
"""The generated script in a real bash, after Void's skel .bashrc."""
|
|
|
|
def run_prompt(self, preset, before="true", term="xterm-256color"):
|
|
path = os.path.join(SCRATCH, preset + ".sh")
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(prompt.script(prompt.load_preset(preset)))
|
|
code = (f". {FILES}/prompt-lib.sh; . {path}; PS1='[\\u@\\h \\W]\\$ '; "
|
|
f"{before}; __das_prompt_hook; printf '%s' \"${{PS1@P}}\"")
|
|
out = subprocess.run(["bash", "--norc", "--noprofile", "-c", code], capture_output=True, text=True,
|
|
env=dict(os.environ, TERM=term, HOME="/home/das"), cwd="/").stdout
|
|
for seq in ("\x01", "\x02"):
|
|
out = out.replace(seq, "")
|
|
import re
|
|
return re.sub(r"\x1b\[[0-9;]*m|\x1b\][^\a]*\a", "", out)
|
|
|
|
def test_script_is_valid(self):
|
|
for name, _ in prompt.list_presets():
|
|
path = os.path.join(SCRATCH, name + ".sh")
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(prompt.script(prompt.load_preset(name)))
|
|
subprocess.run(["bash", "-n", path], check=True)
|
|
|
|
def test_skel_ps1_is_replaced(self):
|
|
out = self.run_prompt("das")
|
|
self.assertTrue(out.startswith("┌─["), out)
|
|
self.assertNotIn("[✗]", out)
|
|
|
|
def test_error_mark(self):
|
|
self.assertIn("┌─[✗]─[", self.run_prompt("das", "false"))
|
|
|
|
def test_console_glyphs(self):
|
|
out = self.run_prompt("das", "false", term="linux")
|
|
self.assertIn("[x]", out)
|
|
self.assertIn("└─> ", out)
|
|
|
|
def test_plain_terminal(self):
|
|
out = self.run_prompt("das", term="dumb")
|
|
self.assertTrue(out.startswith("┌─["), out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|