test_cli_commands.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/backlight.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_doctor():
  14. result = check_subcommand('doctor')
  15. assert result.returncode == 0
  16. assert 'QMK Doctor is checking your environment.' in result.stderr
  17. assert 'QMK is ready to go' in result.stderr
  18. def test_hello():
  19. result = check_subcommand('hello')
  20. assert result.returncode == 0
  21. assert 'Hello,' in result.stderr
  22. def test_pyformat():
  23. result = check_subcommand('pyformat')
  24. assert result.returncode == 0
  25. assert 'Successfully formatted the python code' in result.stderr
  26. def test_list_keyboards():
  27. result = check_subcommand('list-keyboards')
  28. assert result.returncode == 0
  29. # check to see if a known keyboard is returned
  30. # this will fail if handwired/onekey/pytest is removed
  31. assert 'handwired/onekey/pytest' in result.stdout