test_cli_commands.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import subprocess
  2. def check_subcommand(command, *args):
  3. cmd = ['bin/qmk', command] + list(args)
  4. return subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
  5. def test_cformat():
  6. assert check_subcommand('cformat', 'tmk_core/common/keyboard.c').returncode == 0
  7. def test_compile():
  8. assert check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default').returncode == 0
  9. def test_config():
  10. result = check_subcommand('config')
  11. assert result.returncode == 0
  12. assert 'general.color' in result.stdout
  13. def test_kle2json():
  14. assert check_subcommand('kle2json', 'kle.txt', '-f').returncode == 0
  15. def test_doctor():
  16. result = check_subcommand('doctor')
  17. assert result.returncode == 0
  18. assert 'QMK Doctor is checking your environment.' in result.stderr
  19. assert 'QMK is ready to go' in result.stderr
  20. def test_hello():
  21. result = check_subcommand('hello')
  22. assert result.returncode == 0
  23. assert 'Hello,' in result.stderr
  24. def test_pyformat():
  25. result = check_subcommand('pyformat')
  26. assert result.returncode == 0
  27. assert 'Successfully formatted the python code' in result.stderr
  28. def test_list_keyboards():
  29. result = check_subcommand('list-keyboards')
  30. assert result.returncode == 0
  31. # check to see if a known keyboard is returned
  32. # this will fail if handwired/onekey/pytest is removed
  33. assert 'handwired/onekey/pytest' in result.stdout