<commit_before>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This file is part of Logtalk <https://logtalk.org/>
%  Copyright 1998-2021 <NAME> <<EMAIL>>
%  SPDX-License-Identifier: Apache-2.0
%
%  Licensed under the Apache License, Version 2.0 (the "License");
%  you may not use this file except in compliance with the License.
%  You may obtain a copy of the License at
%
%      http://www.apache.org/licenses/LICENSE-2.0
%
%  Unless required by applicable law or agreed to in writing, software
%  distributed under the License is distributed on an "AS IS" BASIS,
%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%  See the License for the specific language governing permissions and
%  limitations under the License.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


:- object(tests,
	extends(lgtunit)).

	:- info([
		version is 0:6:0,
		author is '<NAME>',
		date is 2021-11-05,
		comment is 'Unit tests for the "packs" tool.'
	]).

	:- uses(user, [
		atomic_list_concat/2
	]).

	cover(packs_common).
	cover(registries).
	cover(packs).
	cover(registry_loader_hook).
	cover(packs_specs_hook).

	setup :-
		packs::uninstall,
		packs::clean,
		registries::delete,
		registries::clean.

	cleanup :-
		setup.

	% we start with no defined registries or installed packs

	test(packs_registries_logtalk_packs_1_01, true(LogtalkPacks == Storage)) :-
		this(This),
		object_property(This, file(_, Directory)),
		atom_concat(Directory, 'test_files/logtalk_packs/', Storage),
		registries::logtalk_packs(LogtalkPacks).

	test(packs_registries_logtalk_packs_0_01, true) :-
		^^suppress_text_output,
		registries::logtalk_packs.

	test(packs_registries_list_0_01, true) :-
		^^suppress_text_output,
		registries::list.

	test(packs_registries_defined_3_01, false) :-
		^^suppress_text_output,
		registries::defined(_, _, _).

	test(packs_packs_available_0_01, true) :-
		^^suppress_text_output,
		packs::available.

	test(packs_packs_installed_0_01, true) :-
		^^suppress_text_output,
		packs::installed.

	test(packs_packs_installed_4_01, false) :-
		^^suppress_text_output,
		packs::installed(_, _, _, _).

	test(packs_packs_installed_3_01, false) :-
		^^suppress_text_output,
		packs::installed(_, _, _, _).

	test(packs_packs_outdated_0_01, true) :-
		^^suppress_text_output,
		packs::outdated.

	test(packs_packs_outdated_4_01, false) :-
		^^suppress_text_output,
		packs::outdated(_, _, _, _).

	test(packs_packs_orphaned_0_01, true) :-
		^^suppress_text_output,
		packs::orphaned.

	test(packs_packs_orphaned_2_01, false) :-
		^^suppress_text_output,
		packs::orphaned(_, _).

	test(packs_registries_clean_0_01, true) :-
		^^suppress_text_output,
		registries::clean.

	test(packs_packs_clean_0_01, true) :-
		^^suppress_text_output,
		packs::clean.

	test(packs_registries_lint_0_01, true) :-
		^^suppress_text_output,
		registries::lint.

	test(packs_packs_lint_0_01, true) :-
		^^suppress_text_output,
		packs::lint.

	test(packs_registries_update_0_01, true) :-
		^^suppress_text_output,
		registries::update.

	test(packs_packs_update_0_01, true) :-
		^^suppress_text_output,
		packs::update.

	% now we add a local registry

	test(packs_registries_add_1_01, true) :-
		^^suppress_text_output,
		this(This),
		object_property(This, file(_, Directory)),
		atomic_list_concat(['file://', Directory, 'test_files/local_1'], URL),
		registries::add(URL).

	test(packs_registries_lint_1_01, true) :-
		^^suppress_text_output,
		registries::lint(local_1).

	test(packs_registries_describe_1_01, true) :-
		^^suppress_text_output,
		registries::describe(local_1).

	test(packs_registries_readme_2_01, true(Readme == File)) :-
		this(This),<commit_msg>Additional tests for the `packs` tool<commit_after>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This file is part of Logtalk <https://logtalk.org/>
%  Copyright 1998-2021 <NAME> <<EMAIL>>
%  SPDX-License-Identifier: Apache-2.0
%
%  Licensed under the Apache License, Version 2.0 (the "License");
%  you may not use this file except in compliance with the License.
%  You may obtain a copy of the License at
%
%      http://www.apache.org/licenses/LICENSE-2.0
%
%  Unless required by applicable law or agreed to in writing, software
%  distributed under the License is distributed on an "AS IS" BASIS,
%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%  See the License for the specific language governing permissions and
%  limitations under the License.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


:- object(tests,
	extends(lgtunit)).

	:- info([
		version is 0:7:0,
		author is '<NAME>',
		date is 2021-11-05,
		comment is 'Unit tests for the "packs" tool.'
	]).

	:- uses(user, [
		atomic_list_concat/2
	]).

	cover(packs_common).
	cover(registries).
	cover(packs).
	cover(registry_loader_hook).
	cover(packs_specs_hook).

	setup :-
		packs::uninstall,
		packs::clean,
		registries::delete,
		registries::clean.

	cleanup :-
		setup.

	% we start with no defined registries or installed packs

	test(packs_registries_logtalk_packs_1_01, true(LogtalkPacks == Storage)) :-
		this(This),
		object_property(This, file(_, Directory)),
		atom_concat(Directory, 'test_files/logtalk_packs/', Storage),
		registries::logtalk_packs(LogtalkPacks).

	test(packs_packs_logtalk_packs_1_01, true(LogtalkPacks == Storage)) :-
		this(This),
		object_property(This, file(_, Directory)),
		atom_concat(Directory, 'test_files/logtalk_packs/', Storage),
		packs::logtalk_packs(LogtalkPacks).

	test(packs_registries_logtalk_packs_0_01, true) :-
		registries::logtalk_packs.

	test(packs_packs_logtalk_packs_0_02, true) :-
		packs::logtalk_packs.

	test(packs_registries_directory_1_01, true(atom(Directory))) :-
		^^suppress_text_output,
		registries::directory(Directory).

	test(packs_packs_directory_1_01, true(atom(Directory))) :-
		^^suppress_text_output,
		packs::directory(Directory).

	test(packs_registries_list_0_01, true) :-
		^^suppress_text_output,
		registries::list.

	test(packs_registries_defined_3_01, false) :-
		^^suppress_text_output,
		registries::defined(_, _, _).

	test(packs_packs_available_0_01, true) :-
		^^suppress_text_output,
		packs::available.

	test(packs_packs_installed_0_01, true) :-
		^^suppress_text_output,
		packs::installed.

	test(packs_packs_installed_4_01, false) :-
		^^suppress_text_output,
		packs::installed(_, _, _, _).

	test(packs_packs_installed_3_01, false) :-
		^^suppress_text_output,
		packs::installed(_, _, _, _).

	test(packs_packs_outdated_0_01, true) :-
		^^suppress_text_output,
		packs::outdated.

	test(packs_packs_outdated_4_01, false) :-
		^^suppress_text_output,
		packs::outdated(_, _, _, _).

	test(packs_packs_orphaned_0_01, true) :-
		^^suppress_text_output,
		packs::orphaned.

	test(packs_packs_orphaned_2_01, false) :-
		^^suppress_text_output,
		packs::orphaned(_, _).

	test(packs_registries_clean_0_01, true) :-
		^^suppress_text_output,
		registries::clean.

	test(packs_packs_clean_0_01, true) :-
		^^suppress_text_output,
		packs::clean.

	test(packs_registries_lint_0_01, true) :-
		^^suppress_text_output,
		registries::lint.

	test(packs_packs_lint_0_01, true) :-
		^^suppress_text_output,
		packs::lint.

	test(packs_registries_update_0_01, true) :-
		^^suppress_text_output,
		registries::update.

	test(packs_packs_update_0_01, true) :-
		^^suppress_text_output,
		packs::update.

	test(packs_registries_help_0_01, true) :-
		^^suppress_text_output,
		registries::help.

	test(packs_packs_help_0_01, true) :-
		^^suppress_text_output,
		packs::help.

	% now we add a local registry

	test(packs_registries_add_1_01, true) :-
		^^suppress_text_output,
		this(This),
		object_property(This, file(_, Directory)),
		atomic_list_concat(['file://', Directory, 'test_files/local_1'], URL),
		registries::add(URL).

	test(packs_registries_lint_1_01, true) :-
		^^suppress_text_output,
		registries::lint(local_1).

	test(packs_registries_describe_1_01, true) :-
		^^suppress_text_output,
		registries::describe(local_1).

	test(packs_registries_directory_2_01, true(atom(Directory))) :-
		^^suppress_text_output,
		registries::directory(local_1, Directory).

	test(packs_registries_readme_2_01, true(Readme == File)) :-
		this(This),
{'fraction_non_alphanumeric': 0.159164566078502, 'fraction_numerical': 0.025447125195054616, 'mean_word_length': 5.438948995363215, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '1165784', 'n_tokens_mistral': 3426, 'n_tokens_neox': 3057, 'n_words': 526}