test-driver.c
changeset 136 eef2b734f2cc
parent 129 d221757574c1
child 137 4722cd3437cb
     1.1 --- a/test-driver.c	Thu Feb 21 12:09:13 2008 -0500
     1.2 +++ b/test-driver.c	Fri Feb 29 11:51:58 2008 -0500
     1.3 @@ -60,6 +60,7 @@
     1.4  	int n_install_pkgs, n_remove_pkgs;
     1.5  
     1.6  	int in_result, result_errors;
     1.7 +	int in_unsatisfiable;
     1.8  };
     1.9  
    1.10  static void
    1.11 @@ -181,6 +182,9 @@
    1.12  	const char *name = NULL, *rel_str = NULL, *version = NULL;
    1.13  	enum razor_version_relation rel;
    1.14  
    1.15 +	if (ctx->in_unsatisfiable)
    1.16 +		return;
    1.17 +
    1.18  	get_atts(atts, "name", &name, "rel", &rel_str, "version", &version, NULL);
    1.19  	if (name == NULL) {
    1.20  		fprintf(stderr, "  no name specified for property\n");
    1.21 @@ -209,13 +213,17 @@
    1.22  static void
    1.23  end_transaction(struct test_context *ctx)
    1.24  {
    1.25 -	ctx->system_set = razor_set_update(ctx->system_set,
    1.26 -					   ctx->repo_set,
    1.27 -					   ctx->n_install_pkgs,
    1.28 -					   (const char **)ctx->install_pkgs);
    1.29 -	ctx->system_set = razor_set_remove(ctx->system_set,
    1.30 -					   ctx->n_remove_pkgs,
    1.31 -					   (const char **)ctx->remove_pkgs);
    1.32 +	if (ctx->n_install_pkgs) {
    1.33 +		ctx->system_set = razor_set_update(ctx->system_set,
    1.34 +						   ctx->repo_set,
    1.35 +						   ctx->n_install_pkgs,
    1.36 +						   (const char **)ctx->install_pkgs);
    1.37 +	}
    1.38 +	if (ctx->n_remove_pkgs && ctx->system_set) {
    1.39 +		ctx->system_set = razor_set_remove(ctx->system_set,
    1.40 +						   ctx->n_remove_pkgs,
    1.41 +						   (const char **)ctx->remove_pkgs);
    1.42 +	}
    1.43  
    1.44  	while (ctx->n_install_pkgs--)
    1.45  		free(ctx->install_pkgs[ctx->n_install_pkgs]);
    1.46 @@ -279,27 +287,34 @@
    1.47  {
    1.48  	ctx->in_result = 0;
    1.49  
    1.50 -	if (ctx->system_set && ctx->result_set) {
    1.51 +	if (ctx->result_set) {
    1.52 +		if (!ctx->system_set)
    1.53 +			ctx->system_set = razor_set_create();
    1.54  		ctx->result_errors = 0;
    1.55  		razor_set_diff(ctx->system_set, ctx->result_set,
    1.56  			       diff_callback, ctx);
    1.57  		if (ctx->result_errors)
    1.58  			exit(1);
    1.59  	}
    1.60 -
    1.61  }
    1.62  
    1.63  static void
    1.64 -start_unsatisfied(struct test_context *ctx, const char **atts)
    1.65 +start_unsatisfiable(struct test_context *ctx, const char **atts)
    1.66  {
    1.67 +	if (ctx->system_set) {
    1.68 +		fprintf(stderr, "Expected to fail, but didn't\n");
    1.69 +		exit(1);
    1.70 +	}
    1.71 +
    1.72  	/* FIXME */
    1.73 -	fprintf(stderr, "Can't handle <unsatisfied>\n");
    1.74 -	exit(1);
    1.75 +	fprintf(stderr, "  Not actually checking <unsatisfiable>\n");
    1.76 +	ctx->in_unsatisfiable = 1;
    1.77  }
    1.78  
    1.79  static void
    1.80 -end_unsatisfied(struct test_context *ctx)
    1.81 +end_unsatisfiable(struct test_context *ctx)
    1.82  {
    1.83 +	ctx->in_unsatisfiable = 0;
    1.84  }
    1.85  
    1.86  static void
    1.87 @@ -323,8 +338,8 @@
    1.88  		start_remove(ctx, atts);
    1.89  	} else if (strcmp(element, "result") == 0) {
    1.90  		start_result(ctx, atts);
    1.91 -	} else if (strcmp(element, "unsatisfied") == 0) {
    1.92 -		start_unsatisfied(ctx, atts);
    1.93 +	} else if (strcmp(element, "unsatisfiable") == 0) {
    1.94 +		start_unsatisfiable(ctx, atts);
    1.95  	} else if (strcmp(element, "package") == 0) {
    1.96  		start_package(ctx, atts);
    1.97  	} else if (strcmp(element, "requires") == 0) {
    1.98 @@ -356,8 +371,8 @@
    1.99  		end_transaction(ctx);
   1.100  	} else if (strcmp(element, "result") == 0) {
   1.101  		end_result(ctx);
   1.102 -	} else if (strcmp(element, "unsatisfied") == 0) {
   1.103 -		end_unsatisfied(ctx);
   1.104 +	} else if (strcmp(element, "unsatisfiable") == 0) {
   1.105 +		end_unsatisfiable(ctx);
   1.106  	}
   1.107  }
   1.108