@@ -13,8 +13,7 @@ You probably want to make changes to both files.
1313#include "refs.h"
1414#include "posix.h"
1515
16- static git_repository * repo ;
17- static git_index * repo_index ;
16+ #define TEST_REPO_PATH "merge-resolve"
1817
1918#define UPTODATE_BRANCH "master"
2019#define PREVIOUS_BRANCH "previous"
@@ -25,18 +24,27 @@ static git_index *repo_index;
2524#define NOFASTFORWARD_BRANCH "branch"
2625#define NOFASTFORWARD_ID "7cb63eed597130ba4abb87b3e544b85021905520"
2726
27+ static git_repository * sandbox ;
28+ static git_repository * repo ;
29+
30+ void test_merge_analysis__initialize_with_bare_repository (void )
31+ {
32+ sandbox = cl_git_sandbox_init (TEST_REPO_PATH );
33+ cl_git_pass (git_repository_open_ext (& repo , git_repository_path (sandbox ),
34+ GIT_REPOSITORY_OPEN_BARE , NULL ));
35+ }
2836
29- /* Fixture setup and teardown */
30- void testimpl_merge_analysis__initialize (git_repository * t_repo , git_index * t_repo_index )
37+ void test_merge_analysis__initialize_with_nonbare_repository (void )
3138{
32- repo = t_repo ;
33- repo_index = t_repo_index ;
39+ sandbox = cl_git_sandbox_init (TEST_REPO_PATH );
40+ cl_git_pass (git_repository_open_ext (& repo , git_repository_workdir (sandbox ),
41+ 0 , NULL ));
3442}
3543
36- void testimpl_merge_analysis__cleanup (void )
44+ void test_merge_analysis__cleanup (void )
3745{
38- repo_index = NULL ;
39- repo = NULL ;
46+ git_repository_free ( repo ) ;
47+ cl_git_sandbox_cleanup () ;
4048}
4149
4250static void analysis_from_branch (
@@ -72,7 +80,7 @@ static void analysis_from_branch(
7280 git_reference_free (their_ref );
7381}
7482
75- void testimpl_merge_analysis__fastforward (void )
83+ void test_merge_analysis__fastforward (void )
7684{
7785 git_merge_analysis_t merge_analysis ;
7886 git_merge_preference_t merge_pref ;
@@ -81,7 +89,7 @@ void testimpl_merge_analysis__fastforward(void)
8189 cl_assert_equal_i (GIT_MERGE_ANALYSIS_NORMAL |GIT_MERGE_ANALYSIS_FASTFORWARD , merge_analysis );
8290}
8391
84- void testimpl_merge_analysis__no_fastforward (void )
92+ void test_merge_analysis__no_fastforward (void )
8593{
8694 git_merge_analysis_t merge_analysis ;
8795 git_merge_preference_t merge_pref ;
@@ -90,7 +98,7 @@ void testimpl_merge_analysis__no_fastforward(void)
9098 cl_assert_equal_i (GIT_MERGE_ANALYSIS_NORMAL , merge_analysis );
9199}
92100
93- void testimpl_merge_analysis__uptodate (void )
101+ void test_merge_analysis__uptodate (void )
94102{
95103 git_merge_analysis_t merge_analysis ;
96104 git_merge_preference_t merge_pref ;
@@ -99,7 +107,7 @@ void testimpl_merge_analysis__uptodate(void)
99107 cl_assert_equal_i (GIT_MERGE_ANALYSIS_UP_TO_DATE , merge_analysis );
100108}
101109
102- void testimpl_merge_analysis__uptodate_merging_prev_commit (void )
110+ void test_merge_analysis__uptodate_merging_prev_commit (void )
103111{
104112 git_merge_analysis_t merge_analysis ;
105113 git_merge_preference_t merge_pref ;
@@ -108,22 +116,22 @@ void testimpl_merge_analysis__uptodate_merging_prev_commit(void)
108116 cl_assert_equal_i (GIT_MERGE_ANALYSIS_UP_TO_DATE , merge_analysis );
109117}
110118
111- void testimpl_merge_analysis__unborn (void )
119+ void test_merge_analysis__unborn (void )
112120{
113121 git_merge_analysis_t merge_analysis ;
114122 git_merge_preference_t merge_pref ;
115123 git_buf master = GIT_BUF_INIT ;
116124
117125 cl_git_pass (git_buf_joinpath (& master , git_repository_path (repo ), "refs/heads/master" ));
118- p_unlink (git_buf_cstr (& master ));
126+ cl_must_pass ( p_unlink (git_buf_cstr (& master ) ));
119127
120128 analysis_from_branch (& merge_analysis , & merge_pref , NULL , NOFASTFORWARD_BRANCH );
121129 cl_assert_equal_i (GIT_MERGE_ANALYSIS_FASTFORWARD |GIT_MERGE_ANALYSIS_UNBORN , merge_analysis );
122130
123131 git_buf_dispose (& master );
124132}
125133
126- void testimpl_merge_analysis__fastforward_with_config_noff (void )
134+ void test_merge_analysis__fastforward_with_config_noff (void )
127135{
128136 git_config * config ;
129137 git_merge_analysis_t merge_analysis ;
@@ -140,7 +148,7 @@ void testimpl_merge_analysis__fastforward_with_config_noff(void)
140148 git_config_free (config );
141149}
142150
143- void testimpl_merge_analysis__no_fastforward_with_config_ffonly (void )
151+ void test_merge_analysis__no_fastforward_with_config_ffonly (void )
144152{
145153 git_config * config ;
146154 git_merge_analysis_t merge_analysis ;
@@ -157,7 +165,7 @@ void testimpl_merge_analysis__no_fastforward_with_config_ffonly(void)
157165 git_config_free (config );
158166}
159167
160- void testimpl_merge_analysis__between_uptodate_refs (void )
168+ void test_merge_analysis__between_uptodate_refs (void )
161169{
162170 git_merge_analysis_t merge_analysis ;
163171 git_merge_preference_t merge_pref ;
@@ -166,7 +174,7 @@ void testimpl_merge_analysis__between_uptodate_refs(void)
166174 cl_assert_equal_i (GIT_MERGE_ANALYSIS_UP_TO_DATE , merge_analysis );
167175}
168176
169- void testimpl_merge_analysis__between_noff_refs (void )
177+ void test_merge_analysis__between_noff_refs (void )
170178{
171179 git_merge_analysis_t merge_analysis ;
172180 git_merge_preference_t merge_pref ;
0 commit comments