test_git.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import os
  2. from gitremote import GitRemote
  3. import infra
  4. class GitTestBase(infra.basetest.BRTest):
  5. config = \
  6. """
  7. BR2_BACKUP_SITE=""
  8. """
  9. gitremotedir = infra.filepath("tests/download/git-remote")
  10. gitremote = None
  11. def setUp(self):
  12. super(GitTestBase, self).setUp()
  13. self.gitremote = GitRemote(self.builddir, self.gitremotedir, self.logtofile)
  14. def tearDown(self):
  15. self.show_msg("Cleaning up")
  16. if self.gitremote:
  17. self.gitremote.stop()
  18. if self.b and not self.keepbuilds:
  19. self.b.delete()
  20. def check_hash(self, package):
  21. # store downloaded tarball inside the output dir so the test infra
  22. # cleans it up at the end
  23. env = {"BR2_DL_DIR": os.path.join(self.builddir, "dl"),
  24. "GITREMOTE_PORT_NUMBER": str(self.gitremote.port)}
  25. self.b.build(["{}-dirclean".format(package),
  26. "{}-source".format(package)],
  27. env)
  28. class TestGitHash(GitTestBase):
  29. br2_external = [infra.filepath("tests/download/br2-external/git-hash")]
  30. def test_run(self):
  31. with self.assertRaises(SystemError):
  32. self.check_hash("bad")
  33. self.check_hash("good")
  34. self.check_hash("nohash")