commit - 0857e5e4f4cd18ab9fc0e8ff34992e4d0ff59b85
commit + 5a83d54eba5f144334986a6989a7c146de4b3423
blob - aabadbc6499974adfc15b94e181447de1a5680d6
blob + 765397c281537ffd8b4ec4031d0b6943e805cc56
--- regress/repository/Makefile
+++ regress/repository/Makefile
SRCS = path.c repository.c error.c refs.c object.c sha1.c diff.c \
diffreg.c pack.c delta.c zbuf.c repository_test.c
-CPPFLAGS = -I${.CURDIR}/../../include
+CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
LDADD = -lutil -lz
DEBUG = -O0 -g
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
blob - d822baa5771cc1ed7cc4de41a1385a96bf47e34e
blob + 85c1d231761e8669b269cdccc1fef619aeb9ce99
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
#include <stdarg.h>
#include <stdio.h>
+#include <util.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "got_repository.h"
#include "got_diff.h"
+#include "got_lib_path.h"
+
+#ifndef nitems
+#define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
+#endif
+
#define GOT_REPO_PATH "../../../"
static int verbose;
struct got_blob_object *blob1;
struct got_blob_object *blob2;
FILE *outfile;
+ int i;
+ char *line;
+ size_t len;
+ const char delim[3] = {'\0', '\0', '\0'};
+ const char *expected_output[] = {
+ "--- 141f5fdc96126c1f4195558560a3c915e3d9b4c3",
+ "+++ de7eb21b21c7823a753261aadf7cba35c9580fbf",
+ "@@ -1,10 +1,10 @@",
+ " .PATH:${.CURDIR}/../../lib",
+ " ",
+ " PROG = repository_test",
+ "-SRCS = path.c repository.c error.c refs.c repository_test.c",
+ "+SRCS = path.c repository.c error.c refs.c object.c sha1.c repository_test.c",
+ " ",
+ " CPPFLAGS = -I${.CURDIR}/../../include",
+ "-LDADD = -lutil",
+ "+LDADD = -lutil -lz",
+ " ",
+ " NOMAN = yes"
+ };
err = got_repo_open(&repo, repo_path);
if (err != NULL || repo == NULL)
return 0;
test_printf("\n");
- if (!verbose) {
- outfile = fopen("/dev/null", "w+");
- if (outfile == NULL)
- return 0;
- } else
- outfile = stdout;
+ outfile = got_opentemp();
+ if (outfile == NULL)
+ return 0;
got_diff_blob(blob1, blob2, NULL, NULL, outfile);
+ rewind(outfile);
+ i = 0;
+ while ((line = fparseln(outfile, &len, NULL, delim, 0)) != NULL) {
+ test_printf(line);
+ test_printf("\n");
+ if (i < nitems(expected_output) &&
+ strcmp(line, expected_output[i]) != 0) {
+ test_printf("diff output mismatch; expected: '%s'\n",
+ expected_output[i]);
+ }
+ i++;
+ }
+ fclose(outfile);
test_printf("\n");
+ if (i != nitems(expected_output) + 1) {
+ test_printf("number of lines expected: %d; actual: %d\n",
+ nitems(expected_output), i - 1);
+ return 0;
+ }
got_object_blob_close(blob1);
got_object_blob_close(blob2);