<commit_before>#!/usr/bin/env bash

function export_env_vars {
	if [[ -n $BATS_TEST_DIRNAME ]]; then
		export TESTDIR=$(cd "${BATS_TEST_DIRNAME}/.."; printf "$(pwd)")
	else
		export TESTDIR=$(cd "${SCRIPTDIR}"; printf "$(pwd)")
	fi
	export _TMPDIR=$(mktemp -d)
	export REPO_FIXTURES="${_TMPDIR}/repos"
	export HOME="${_TMPDIR}/home"
	export NOTHOME="${_TMPDIR}/nothome"

	export HOMESICK="$HOME/.homesick"
	export HOMESHICK_FN="homeshick"
	export HOMESHICK_FN_SRC="$HOMESICK/repos/homeshick/homeshick.sh"
	export HOMESHICK_BIN="$HOMESICK/repos/homeshick/bin/homeshick"

	# Check if expect is installed
	run type expect >/dev/null 2>&1
	if [[ $status != 0 ]]; then
		export EXPECT_INSTALLED=false
	else
		export EXPECT_INSTALLED=true
	fi
}

function remove_path {
	# Check if coreutils is in PATH
	system=$(uname -a)
	if [[ $system =~ "Darwin" && ! $system =~ "AppleTV" ]]; then
		run type brew >/dev/null 2>&1
		if [[ $status = 0 ]]; then
			coreutils_path=$(brew --prefix coreutils 2>/dev/null)/libexec/gnubin
			if [[ -d $coreutils_path && $PATH == *$coreutils_path* ]]; then
				if [[ -z $HOMESHICK_KEEP_PATH || $HOMESHICK_KEEP_PATH == false ]]; then
					export PATH=${PATH//$coreutils_path/''}
					export PATH=${PATH//'::'/':'} # Remove any left over colons
				fi
			fi
		fi
	fi
}

function mk_structure {
	mkdir "$REPO_FIXTURES" "$HOME" "$NOTHOME"
	local hs_repo=$HOMESICK/repos/homeshick
	mkdir -p $hs_repo
	ln -s $(cd "${TESTDIR}/.."; printf "$(pwd)")/homeshick.sh "${hs_repo}/homeshick.sh"
	ln -s $(cd "${TESTDIR}/../bin"; printf "$(pwd)") "${hs_repo}/bin"
	ln -s $(cd "${TESTDIR}/../utils"; printf "$(pwd)") "${hs_repo}/utils"
	ln -s $(cd "${TESTDIR}/../completions"; printf "$(pwd)") "${hs_repo}/completions"
}

function rm_structure {
	# Make sure _TMPDIR wasn't unset
	[[ -n $_TMPDIR ]] && find "${_TMPDIR}" -mindepth 1 -delete
}

function setup_env {
	export_env_vars
	remove_path
	mk_structure
	source $HOMESHICK_FN_SRC
}

function setup {
	setup_env
}

function teardown {
	rm_structure
}

function fixture {
	local name=$1
	[[ -e "${REPO_FIXTURES}/$name" ]] || source "${TESTDIR}/fixtures/${name}.bash"
}

function castle {
	local fixture_name=$1
	fixture "$fixture_name"
	$HOMESHICK_FN --batch clone "${REPO_FIXTURES}/${fixture_name}" > /dev/null
}
<commit_msg>Delete tmp folder itself after test run<commit_after>#!/usr/bin/env bash

function export_env_vars {
	if [[ -n $BATS_TEST_DIRNAME ]]; then
		export TESTDIR=$(cd "${BATS_TEST_DIRNAME}/.."; printf "$(pwd)")
	else
		export TESTDIR=$(cd "${SCRIPTDIR}"; printf "$(pwd)")
	fi
	export _TMPDIR=$(mktemp -d)
	export REPO_FIXTURES="${_TMPDIR}/repos"
	export HOME="${_TMPDIR}/home"
	export NOTHOME="${_TMPDIR}/nothome"

	export HOMESICK="$HOME/.homesick"
	export HOMESHICK_FN="homeshick"
	export HOMESHICK_FN_SRC="$HOMESICK/repos/homeshick/homeshick.sh"
	export HOMESHICK_BIN="$HOMESICK/repos/homeshick/bin/homeshick"

	# Check if expect is installed
	run type expect >/dev/null 2>&1
	if [[ $status != 0 ]]; then
		export EXPECT_INSTALLED=false
	else
		export EXPECT_INSTALLED=true
	fi
}

function remove_path {
	# Check if coreutils is in PATH
	system=$(uname -a)
	if [[ $system =~ "Darwin" && ! $system =~ "AppleTV" ]]; then
		run type brew >/dev/null 2>&1
		if [[ $status = 0 ]]; then
			coreutils_path=$(brew --prefix coreutils 2>/dev/null)/libexec/gnubin
			if [[ -d $coreutils_path && $PATH == *$coreutils_path* ]]; then
				if [[ -z $HOMESHICK_KEEP_PATH || $HOMESHICK_KEEP_PATH == false ]]; then
					export PATH=${PATH//$coreutils_path/''}
					export PATH=${PATH//'::'/':'} # Remove any left over colons
				fi
			fi
		fi
	fi
}

function mk_structure {
	mkdir "$REPO_FIXTURES" "$HOME" "$NOTHOME"
	local hs_repo=$HOMESICK/repos/homeshick
	mkdir -p $hs_repo
	ln -s $(cd "${TESTDIR}/.."; printf "$(pwd)")/homeshick.sh "${hs_repo}/homeshick.sh"
	ln -s $(cd "${TESTDIR}/../bin"; printf "$(pwd)") "${hs_repo}/bin"
	ln -s $(cd "${TESTDIR}/../utils"; printf "$(pwd)") "${hs_repo}/utils"
	ln -s $(cd "${TESTDIR}/../completions"; printf "$(pwd)") "${hs_repo}/completions"
}

function rm_structure {
	# Make sure _TMPDIR wasn't unset
	[[ -n $_TMPDIR ]] && rm -rf $_TMPDIR
}

function setup_env {
	export_env_vars
	remove_path
	mk_structure
	source $HOMESHICK_FN_SRC
}

function setup {
	setup_env
}

function teardown {
	rm_structure
}

function fixture {
	local name=$1
	[[ -e "${REPO_FIXTURES}/$name" ]] || source "${TESTDIR}/fixtures/${name}.bash"
}

function castle {
	local fixture_name=$1
	fixture "$fixture_name"
	$HOMESHICK_FN --batch clone "${REPO_FIXTURES}/${fixture_name}" > /dev/null
}

{'fraction_non_alphanumeric': 0.18024529128339903, 'fraction_numerical': 0.004161191414805081, 'mean_word_length': 4.398345153664303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6464095', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1775, 'n_words': 396}