test_gitforge.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import os
  2. import shutil
  3. import infra
  4. class GitforgeTestBase(infra.basetest.BRConfigTest):
  5. config = ""
  6. def setUp(self):
  7. super(GitforgeTestBase, self).setUp()
  8. def tearDown(self):
  9. self.show_msg("Cleaning up")
  10. if self.b and not self.keepbuilds:
  11. self.b.delete()
  12. def check_download(self, package):
  13. # store downloaded tarball inside the output dir so the test infra
  14. # cleans it up at the end
  15. dl_dir = os.path.join(self.builddir, "dl")
  16. # enforce we test the download
  17. if os.path.exists(dl_dir):
  18. shutil.rmtree(dl_dir)
  19. env = {"BR2_DL_DIR": dl_dir}
  20. self.b.build(["{}-dirclean".format(package),
  21. "{}-legal-info".format(package)],
  22. env)
  23. class TestGitHub(GitforgeTestBase):
  24. br2_external = [infra.filepath("tests/download/br2-external/github")]
  25. def test_run(self):
  26. self.check_download("github-helper-tag")
  27. self.check_download("github-helper-hash")
  28. self.check_download("github-release")
  29. class TestGitLab(GitforgeTestBase):
  30. br2_external = [infra.filepath("tests/download/br2-external/gitlab")]
  31. def test_run(self):
  32. self.check_download("gitlab-helper-hash")
  33. self.check_download("gitlab-helper-tag")
  34. self.check_download("gitlab-release")