<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include "assert.h"

static const char *progname;
static int tests;
static int passed;

static void run(void (*func)(void), const char *name)
{
	pid_t pid;
	int status;

	printf("  %-9s %s %s\n", "Check", progname, name);

	tests++;

	pid = fork();
	assert(pid >= 0);

	if (pid == 0) {
		func();
		exit(0);
	}

	assert(waitpid(pid, &status, 0) == pid);

	if (status == 0)
		passed++;
	else
		fprintf(stderr, "%s: test_%s() failed with status %d\n", progname, name, status);
}

#define test(name) \
	do { \
		void test_##name(void); \
		if (argc <= 1) \
			run(test_##name, #name); \
		else if (strcmp(argv[1], #name) == 0) \
			test_##name(); \
	} while (0)

int main(int argc, char **argv)
{
	progname = argv[0];

#include "test/suite.h"

	return passed == tests ? 0 : 1;<commit_msg>print error on bad test runner parameters<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include "assert.h"

static const char *progname;
static int tests;
static int passed;

static void run(void (*func)(void), const char *name)
{
	pid_t pid;
	int status;

	printf("  %-9s %s %s\n", "Check", progname, name);

	tests++;

	pid = fork();
	assert(pid >= 0);

	if (pid == 0) {
		func();
		exit(0);
	}

	assert(waitpid(pid, &status, 0) == pid);

	if (status == 0)
		passed++;
	else
		fprintf(stderr, "%s: test_%s() failed with status %d\n", progname, name, status);
}

#define test(name) \
	do { \
		void test_##name(void); \
		if (argc == 1) { \
			run(test_##name, #name); \
		} else if (argc == 2 && strcmp(argv[1], #name) == 0) { \
			test_##name(); \
			return 0; \
		} \
	} while (0)

int main(int argc, char **argv)
{
	progname = argv[0];

#include "test/suite.h"

	if (argc > 1) {
		fprintf(stderr, "%s: no such test\n", progname);
		return 1;
	}

	return passed == tests ? 0 : 1;
{'fraction_non_alphanumeric': 0.2002997002997003, 'fraction_numerical': 0.014985014985014986, 'mean_word_length': 3.5112612612612613, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2517836', 'n_tokens_mistral': 883, 'n_tokens_neox': 810, 'n_words': 226}