<commit_before>%  Copyright 2008-2011 Zuse Institute Berlin
%
%   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.
%%%-------------------------------------------------------------------
%%% File    : unittest_helper.erl
%%% Author  : <NAME> <<EMAIL>>
%%% Description : Helper functions for Unit tests
%%%
%%% Created :  27 Aug 2008 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
-module(unittest_helper).
-author('<EMAIL>').
-vsn('$Id$').

%%-define(TRACE_RING_DATA(), print_ring_data()).
-define(TRACE_RING_DATA(), ok).

-export([fix_cwd/0,
         get_scalaris_port/0, get_yaws_port/0,
         make_ring_with_ids/1, make_ring_with_ids/2, make_ring/1, make_ring/2,
         stop_ring/0, stop_ring/1,
         stop_pid_groups/0,
         check_ring_size/1, check_ring_size_fully_joined/1,
         wait_for_stable_ring/0, wait_for_stable_ring_deep/0,
         start_process/1, start_process/2,
         start_subprocess/1, start_subprocess/2,
         get_all_children/1,
         get_processes/0, kill_new_processes/1, kill_new_processes/2,
         init_per_suite/1, end_per_suite/1,
         create_ct_all/1, create_ct_groups/2,
         init_per_group/2, end_per_group/2,
         get_ring_data/0, print_ring_data/0,
         macro_equals/4, macro_equals/5,
         expect_no_message_timeout/1,
         prepare_config/1,
         start_minimal_procs/3, stop_minimal_procs/1]).

-include("scalaris.hrl").
-include_lib("common_test/include/ct.hrl").

%% @doc Sets the current working directory to "../bin" if it does not end with
%%      "/bin" yet. Assumes that the current working directory is a sub-dir of
%%      our top-level, e.g. "test". This is needed in order for the config
%%      process to find its (default) config files.
-spec fix_cwd() -> ok | {error, Reason::file:posix()}.
fix_cwd() ->
    case file:get_cwd() of
        {ok, CurCWD} ->
            case string:rstr(CurCWD, "/bin") =/= (length(CurCWD) - 4 + 1) of
                true -> file:set_cwd("../bin");
                _    -> ok
            end;
        Error -> Error
    end.<commit_msg>- compile fix for erlang versions < R13B04<commit_after>%  Copyright 2008-2011 Zuse Institute Berlin
%
%   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.
%%%-------------------------------------------------------------------
%%% File    : unittest_helper.erl
%%% Author  : <NAME> <<EMAIL>>
%%% Description : Helper functions for Unit tests
%%%
%%% Created :  27 Aug 2008 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
-module(unittest_helper).
-author('<EMAIL>').
-vsn('$Id$').

%%-define(TRACE_RING_DATA(), print_ring_data()).
-define(TRACE_RING_DATA(), ok).

-export([fix_cwd/0,
         get_scalaris_port/0, get_yaws_port/0,
         make_ring_with_ids/1, make_ring_with_ids/2, make_ring/1, make_ring/2,
         stop_ring/0, stop_ring/1,
         stop_pid_groups/0,
         check_ring_size/1, check_ring_size_fully_joined/1,
         wait_for_stable_ring/0, wait_for_stable_ring_deep/0,
         start_process/1, start_process/2,
         start_subprocess/1, start_subprocess/2,
         get_all_children/1,
         get_processes/0, kill_new_processes/1, kill_new_processes/2,
         init_per_suite/1, end_per_suite/1,
         create_ct_all/1, create_ct_groups/2,
         init_per_group/2, end_per_group/2,
         get_ring_data/0, print_ring_data/0,
         macro_equals/4, macro_equals/5,
         expect_no_message_timeout/1,
         prepare_config/1,
         start_minimal_procs/3, stop_minimal_procs/1]).

-include("scalaris.hrl").
% we should include ct.hrl but erlang versions < R13B04 do not compile that way
% -> include contents of ct.hrl manually:
%-include_lib("common_test/include/ct.hrl").
-include_lib("test_server/include/test_server.hrl").
-compile({parse_transform,ct_line}).

%% @doc Sets the current working directory to "../bin" if it does not end with
%%      "/bin" yet. Assumes that the current working directory is a sub-dir of
%%      our top-level, e.g. "test". This is needed in order for the config
%%      process to find its (default) config files.
-spec fix_cwd() -> ok | {error, Reason::file:posix()}.
fix_cwd() ->
    case file:get_cwd() of
        {ok, CurCWD} ->
            case string:rstr(CurCWD, "/bin") =/= (length(CurCWD) - 4 + 1) of
                true -> file:set_cwd("../bin");
                _    -> ok
            end;
        Error -> Error
    end.
{'fraction_non_alphanumeric': 0.16254095376774663, 'fraction_numerical': 0.02184200946487077, 'mean_word_length': 2.445141065830721, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 30, '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': '3362053', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1733, 'n_words': 459}