Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
1d415455
Commit
1d415455
authored
Jan 02, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clay: Move `file_create` to the helpers file
parent
7a704309
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
53 deletions
+27
-53
tests-clay/clay_helpers.c
+18
-0
tests-clay/clay_libgit2.h
+3
-0
tests-clay/index/read_tree.c
+3
-4
tests-clay/index/rename.c
+1
-2
tests-clay/object/commit/commitstagedfile.c
+1
-11
tests-clay/status/single.c
+1
-10
tests-clay/testlib.c
+0
-20
tests-clay/testlib.h
+0
-6
No files found.
tests-clay/clay_helpers.c
View file @
1d415455
#include "clay_libgit2.h"
#include "posix.h"
void
clay_on_init
(
void
)
{
...
...
@@ -9,3 +10,20 @@ void clay_on_shutdown(void)
{
git_threads_shutdown
();
}
void
cl_git_mkfile
(
const
char
*
filename
,
const
char
*
content
)
{
int
fd
;
fd
=
p_creat
(
filename
,
0666
);
cl_assert
(
fd
!=
0
);
if
(
content
)
{
cl_must_pass
(
p_write
(
fd
,
content
,
strlen
(
content
)));
}
else
{
cl_must_pass
(
p_write
(
fd
,
filename
,
strlen
(
filename
)));
cl_must_pass
(
p_write
(
fd
,
"
\n
"
,
1
));
}
cl_must_pass
(
p_close
(
fd
));
}
tests-clay/clay_libgit2.h
View file @
1d415455
...
...
@@ -51,4 +51,7 @@ GIT_INLINE(void) cl_assert_strequal_internal(
#define REP256(STR) REP16(REP16(STR))
#define REP1024(STR) REP4(REP256(STR))
/* Write the contents of a buffer to disk */
void
cl_git_mkfile
(
const
char
*
filename
,
const
char
*
content
);
#endif
tests-clay/index/read_tree.c
View file @
1d415455
#include "clay_libgit2.h"
#include "testlib.h"
#include "posix.h"
/* Test that reading and writing a tree is a no-op */
...
...
@@ -21,9 +20,9 @@ void test_index_read_tree__read_write_involution(void)
p_mkdir
(
"./read_tree/abc"
,
0700
);
/* Sort order: '-' < '/' < '_' */
file_creat
e
(
"./read_tree/abc-d"
,
NULL
);
file_creat
e
(
"./read_tree/abc/d"
,
NULL
);
file_creat
e
(
"./read_tree/abc_d"
,
NULL
);
cl_git_mkfil
e
(
"./read_tree/abc-d"
,
NULL
);
cl_git_mkfil
e
(
"./read_tree/abc/d"
,
NULL
);
cl_git_mkfil
e
(
"./read_tree/abc_d"
,
NULL
);
cl_git_pass
(
git_index_add
(
index
,
"abc-d"
,
0
));
cl_git_pass
(
git_index_add
(
index
,
"abc_d"
,
0
));
...
...
tests-clay/index/rename.c
View file @
1d415455
#include "clay_libgit2.h"
#include "testlib.h"
#include "posix.h"
void
test_index_rename__single_file
(
void
)
...
...
@@ -17,7 +16,7 @@ void test_index_rename__single_file(void)
cl_assert
(
git_index_entrycount
(
index
)
==
0
);
file_creat
e
(
"./rename/lame.name.txt"
,
"new_file
\n
"
);
cl_git_mkfil
e
(
"./rename/lame.name.txt"
,
"new_file
\n
"
);
/* This should add a new blob to the object database in 'd4/fa8600b4f37d7516bef4816ae2c64dbf029e3a' */
cl_git_pass
(
git_index_add
(
index
,
"lame.name.txt"
,
0
));
...
...
tests-clay/object/commit/commitstagedfile.c
View file @
1d415455
...
...
@@ -3,16 +3,6 @@
static
git_repository
*
repo
;
static
void
file_create
(
const
char
*
filename
,
const
char
*
content
)
{
int
fd
;
fd
=
p_creat
(
filename
,
0666
);
cl_assert
(
fd
!=
0
);
cl_git_pass
(
p_write
(
fd
,
content
,
strlen
(
content
)));
cl_git_pass
(
p_close
(
fd
));
}
void
test_object_commit_commitstagedfile__initialize
(
void
)
{
cl_fixture
(
"treebuilder"
);
...
...
@@ -79,7 +69,7 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
/*
* Add a new file to the index
*/
file_creat
e
(
"treebuilder/test.txt"
,
"test
\n
"
);
cl_git_mkfil
e
(
"treebuilder/test.txt"
,
"test
\n
"
);
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_index_add
(
index
,
"test.txt"
,
0
));
...
...
tests-clay/status/single.c
View file @
1d415455
...
...
@@ -7,15 +7,6 @@ cleanup__remove_file(void *_file)
cl_must_pass
(
p_unlink
((
char
*
)
_file
));
}
static
void
file_create
(
const
char
*
filename
,
const
char
*
content
)
{
int
fd
=
p_creat
(
filename
,
0666
);
cl_assert
(
fd
>=
0
);
cl_must_pass
(
p_write
(
fd
,
content
,
strlen
(
content
)));
cl_must_pass
(
p_close
(
fd
));
}
/* test retrieving OID from a file apart from the ODB */
void
test_status_single__hash_single_file
(
void
)
{
...
...
@@ -27,7 +18,7 @@ void test_status_single__hash_single_file(void)
/* initialization */
git_oid_fromstr
(
&
expected_id
,
file_hash
);
file_creat
e
(
file_name
,
file_contents
);
cl_git_mkfil
e
(
file_name
,
file_contents
);
cl_set_cleanup
(
&
cleanup__remove_file
,
(
void
*
)
file_name
);
cl_git_pass
(
git_odb_hashfile
(
&
actual_id
,
file_name
,
GIT_OBJ_BLOB
));
...
...
tests-clay/testlib.c
deleted
100644 → 0
View file @
7a704309
#include "clay.h"
#include "testlib.h"
#include "posix.h"
void
file_create
(
const
char
*
filename
,
const
char
*
content
)
{
int
fd
;
fd
=
p_creat
(
filename
,
0666
);
cl_assert
(
fd
!=
0
);
if
(
content
)
{
cl_must_pass
(
p_write
(
fd
,
content
,
strlen
(
content
)));
}
else
{
cl_must_pass
(
p_write
(
fd
,
filename
,
strlen
(
filename
)));
cl_must_pass
(
p_write
(
fd
,
"
\n
"
,
1
));
}
cl_must_pass
(
p_close
(
fd
));
}
tests-clay/testlib.h
deleted
100644 → 0
View file @
7a704309
#ifndef INCLUDE_testlib_h__
#define INCLUDE_testlib_h__
void
file_create
(
const
char
*
filename
,
const
char
*
content
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment