test_tweaks.py 857B

1234567891011121314151617181920212223242526272829
  1. from dds_ci.testing.fixtures import ProjectOpener
  2. from dds_ci import paths, proc
  3. def test_lib_with_tweaks(project_opener: ProjectOpener) -> None:
  4. pr = project_opener.open('projects/tweaks')
  5. pr.build()
  6. app = pr.build_root / ('tweakable' + paths.EXE_SUFFIX)
  7. res = proc.run([app])
  8. # The default value is 99:
  9. assert res.returncode == 99
  10. # Build again, but with an empty/non-existent tweaks directory
  11. pr.build(tweaks_dir=pr.root / 'conf')
  12. res = proc.run([app])
  13. assert res.returncode == 99
  14. # Now write a tweaks header and rebuild:
  15. pr.write(
  16. 'conf/tweakable.tweaks.hpp', r'''
  17. #pragma once
  18. namespace tweakable {
  19. namespace config {
  20. const int value = 41;
  21. }
  22. }
  23. ''')
  24. pr.build(tweaks_dir=pr.root / 'conf')
  25. res = proc.run([app])
  26. assert res.returncode == 41