From cccc1061bc145feb402953661aa0ca0627011831 Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: Thu, 29 Jun 2023 18:25:45 +0200 Subject: [PATCH] re-import sources as agreed with the maintainer --- .gitignore | 2 +- tests/scripts/run_tests | 33 +++++++++++++++++++++++++++++++++ tests/tests.yml | 15 +++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 tests/scripts/run_tests create mode 100644 tests/tests.yml diff --git a/.gitignore b/.gitignore index 352fa67..b1915dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/libgit2-glib-0.26.4.tar.xz +/libgit2-glib-0.26.0.tar.xz /libgit2-glib-0.26.4.tar.xz diff --git a/tests/scripts/run_tests b/tests/scripts/run_tests new file mode 100755 index 0000000..f4f5e22 --- /dev/null +++ b/tests/scripts/run_tests @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +""" Make sure that libgit2-glib works correctly +""" +import gi +gi.require_version("Ggit", "1.0") +from gi.repository import Ggit as Git +from gi.repository import Gio + +import os +import tempfile + +def test_libgit2(git_path): + """Test libgit2""" + Git.init() + repo = Git.Repository.init_repository(Gio.file_new_for_path(git_path), True) + + # Make an initial empty commit + sig = Git.Signature.new_now("bdcs-api-server", "user-email") + tree_id = repo.get_index().write_tree() + tree = repo.lookup(tree_id, Git.Tree) + repo.create_commit("HEAD", sig, sig, "UTF-8", "Initial commit", tree, []) + + commit_id = repo.revparse("master").get_id() + commit = repo.lookup(commit_id, Git.Commit) + message = commit.get_message() + + if message != "Initial commit": + print("ERROR: Problem with Initial commit: %s" % message) + os.exit(1) + +if __name__=='__main__': + with tempfile.TemporaryDirectory(prefix="test.libgit2.") as git_repo: + test_libgit2(git_repo) diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..3fe403c --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,15 @@ +--- +# Run a simple test +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + + required_packages: + - python36 + + tests: + - simple: + dir: scripts + run: ./run_tests