<commit_before>/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
 * Walbottle
 * Copyright (C) Collabora Ltd. 2015
 *
 * Walbottle is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Walbottle is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Walbottle.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <string.h>

#include "utils.h"
#include "wbl-json-node.h"
#include "wbl-schema.h"
#include "wbl-meta-schema.h"

/* Load JSON instances from a file, one per line. Each must be a valid JSON
 * instance. No escaping is required. */
gchar **
wbl_test_load_json_instances_from_file (const gchar  *filename)
{
	gchar *path = NULL;
	gchar *file_contents = NULL;
	gchar **lines = NULL;
	GError *error = NULL;
	guint i;

	path = g_test_build_filename (G_TEST_DIST, filename, NULL);
	g_test_message ("Loading JSON instances from ‘%s’.", path);
	g_file_get_contents (filename, &file_contents, NULL, &error);
	g_assert_no_error (error);
	g_free (path);

	lines = g_strsplit (file_contents, "\n", -1);

	/* Clear the last element if it’s an empty string. */
	for (i = g_strv_length (lines) - 1; g_strcmp0 (lines[i], "") == 0; i--) {
		lines[i] = NULL;
	}

	g_free (file_contents);

	return lines;<commit_msg>tests: Fix resolution of paths to installed test files<commit_after>/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
 * Walbottle
 * Copyright (C) Collabora Ltd. 2015
 *
 * Walbottle is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Walbottle is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Walbottle.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <string.h>

#include "utils.h"
#include "wbl-json-node.h"
#include "wbl-schema.h"
#include "wbl-meta-schema.h"

/* Load JSON instances from a file, one per line. Each must be a valid JSON
 * instance. No escaping is required. */
gchar **
wbl_test_load_json_instances_from_file (const gchar  *filename)
{
	gchar *path = NULL;
	gchar *file_contents = NULL;
	gchar **lines = NULL;
	GError *error = NULL;
	guint i;

	path = g_test_build_filename (G_TEST_DIST, filename, NULL);
	g_test_message ("Loading JSON instances from ‘%s’.", path);
	g_file_get_contents (path, &file_contents, NULL, &error);
	g_assert_no_error (error);
	g_free (path);

	lines = g_strsplit (file_contents, "\n", -1);

	/* Clear the last element if it’s an empty string. */
	for (i = g_strv_length (lines) - 1; g_strcmp0 (lines[i], "") == 0; i--) {
		lines[i] = NULL;
	}

	g_free (file_contents);

	return lines;
{'fraction_non_alphanumeric': 0.1166904422253923, 'fraction_numerical': 0.0068473609129814554, 'mean_word_length': 3.917251051893408, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5869931', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1146, 'n_words': 437}