Sprinter: добавить отладку C-исходников и интеграцию VS Code
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""Генератор launcher Lua не должен менять вложенность событий/сигнатуры."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT / 'toolchain'))
|
||||
from sdbg_launcher import disk_entries, lua_script, write_keyboard_config
|
||||
|
||||
|
||||
class LauncherTests(unittest.TestCase):
|
||||
def test_lua_tables_have_expected_shape(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path = Path(directory) / 'launch.lua'
|
||||
lua_script(path, Path(directory)/'ready.json', 0x8100, b'\x21\x42',
|
||||
[(0.0, ':kbd:test', 4, 1)], 0)
|
||||
text = path.read_text()
|
||||
self.assertIn('local events={{0.0,":kbd:test",4,1}}', text)
|
||||
self.assertIn('local signature={33,66}', text)
|
||||
self.assertIn('local function dss_prompt_row()', text)
|
||||
self.assertNotIn('local events={{{', text)
|
||||
self.assertNotIn('local signature={{', text)
|
||||
|
||||
def test_disk_entries_reject_missing_and_83_collision(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root=Path(directory)
|
||||
exe=root/'program-long.exe';exe.write_bytes(b'x')
|
||||
duplicate=root/'program-last.exe';duplicate.write_bytes(b'y')
|
||||
with self.assertRaisesRegex(ValueError,'8.3'):
|
||||
disk_entries(exe,[duplicate])
|
||||
with self.assertRaisesRegex(ValueError,'Не найден'):
|
||||
disk_entries(exe,[root/'missing.dat'])
|
||||
|
||||
def test_isolated_config_enables_both_sprinter_keyboards(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
write_keyboard_config(Path(directory))
|
||||
root = ET.parse(Path(directory)/'sprinter.cfg').getroot()
|
||||
self.assertEqual(root.attrib['version'], '10')
|
||||
self.assertEqual(root.find('system').attrib['name'], 'sprinter')
|
||||
keyboards = {item.attrib['tag']: item.attrib['enabled']
|
||||
for item in root.findall('./system/input/keyboard')}
|
||||
self.assertEqual(keyboards, {':': '1', ':kbd:ms_naturl': '1'})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user