3 # Copyright (c) 2013 Felipe Contreras
6 test_description='test ruby support'
10 if ! test_have_prereq RUBY
12 skip_all='skipping ruby tests'
16 test_expect_success 'basic support' '
17 git ruby > actual <<-EOF &&
20 echo "hello world" > expected &&
21 test_cmp expected actual
24 test_expect_success 'argument passing' '
25 cat > script <<-"EOF" &&
29 git ruby script foo bar > actual &&
30 cat > expected <<-EOF &&
34 test_cmp expected actual
37 test_expect_success 'test for_each_ref()' '
39 git ruby > actual <<-EOF &&
40 for_each_ref() do |name, sha1, flags|
41 puts "%s: %s" % [name, sha1_to_hex(sha1)]
44 git for-each-ref --format="%(refname): %(objectname)" > expected &&
45 test_cmp expected actual
48 test_expect_success 'test setup_git_directory()' '
52 git ruby > ../actual <<-EOF
53 prefix, nongit_ok = setup_git_directory()
57 echo "t/" > expected &&
58 test_cmp expected actual
61 test_expect_success 'test dwim_ref()' '
62 git ruby > actual <<-EOF &&
63 sha1, num, ref = dwim_ref("HEAD")
64 puts sha1_to_hex(sha1), num, ref
66 git rev-parse -q --verify HEAD > expected &&
68 git rev-parse -q --verify --symbolic-full-name HEAD >> expected &&
69 test_cmp expected actual
72 test_expect_success 'test git_config()' '
73 git ruby > actual <<-EOF &&
74 git_config() do |key, value|
75 puts "%s=%s" % [key, value]
78 git config --list > expected &&
79 test_cmp expected actual
82 test_expect_success 'test get_sha1()' '
83 git ruby > actual <<-EOF &&
84 puts sha1_to_hex(get_sha1("HEAD"))
86 git rev-parse -q --verify HEAD > expected &&
87 test_cmp expected actual
90 test_expect_success 'test Object' '
91 git ruby > actual <<-EOF &&
92 object = Git::Object.get(get_sha1("HEAD"))
93 puts object, object.type == OBJ_COMMIT, sha1_to_hex(object.sha1)
95 git rev-parse -q --verify HEAD > expected &&
96 echo "true" >> expected &&
97 git rev-parse -q --verify HEAD >> expected &&
98 test_cmp expected actual
101 test_expect_success 'test Commit' '
102 git ruby > actual <<-EOF &&
103 commit = Git::Commit.get(get_sha1("HEAD"))
104 puts commit, commit.buffer
106 git rev-parse -q --verify HEAD > expected &&
107 git cat-file commit HEAD >> expected &&
108 test_cmp expected actual