<commit_before>#  Test suite for clitest

This is the test file for the `clitest` program. Yes, the program can test itself!

This file runs all the files inside the `dev/test` folder and checks the results. The command line options are also tested.

    Usage: ./clitest dev/test.md


## Preparing

Make sure we're on the same folder as `clitest`, since all the file paths here are relative, not absolute.

```
$ test -f ./clitest; echo $?
0
$ test -d ./dev/test/; echo $?
0
$
```

Set a default terminal width of 80 columns. It's used by separator lines.

```
$ COLUMNS=80
$ export COLUMNS
$
```

Ok. Now the real tests begins.

## Variables are persistent between tests?

```
$ echo $COLUMNS
80
$ not_exported=1
$ echo $not_exported
1
$ echo $not_exported  #→ 1
$ echo $not_exported  #→ --regex ^1$
```

## Check the temporary dir creation

```
$ TMPDIR___SAVE="$TMPDIR"
$ TMPDIR=/XXnotfoundXX
$ export TMPDIR
$ ./clitest dev/test/ok-1.sh 2>&1 | sed 's/clitest\.[0-9]*$/clitest.NNN/'
mkdir: /XXnotfoundXX: No such file or directory
clitest: Error: cannot create temporary dir: /XXnotfoundXX/clitest.NNN
$ TMPDIR="$TMPDIR___SAVE"
$
```<commit_msg>Command error messages are not portable<commit_after>#  Test suite for clitest

This is the test file for the `clitest` program. Yes, the program can test itself!

This file runs all the files inside the `dev/test` folder and checks the results. The command line options are also tested.

    Usage: ./clitest dev/test.md


## Preparing

Make sure we're on the same folder as `clitest`, since all the file paths here are relative, not absolute.

```
$ test -f ./clitest; echo $?
0
$ test -d ./dev/test/; echo $?
0
$
```

Set a default terminal width of 80 columns. It's used by separator lines.

```
$ COLUMNS=80
$ export COLUMNS
$
```

Ok. Now the real tests begins.

## Variables are persistent between tests?

```
$ echo $COLUMNS
80
$ not_exported=1
$ echo $not_exported
1
$ echo $not_exported  #→ 1
$ echo $not_exported  #→ --regex ^1$
```

## Check the temporary dir creation

```
$ TMPDIR___SAVE="$TMPDIR"
$ TMPDIR=/XXnotfoundXX
$ export TMPDIR
$ ./clitest dev/test/ok-1.sh 2>&1 | grep ^clitest | sed 's/clitest\.[0-9]*$/clitest.NNN/'
clitest: Error: cannot create temporary dir: /XXnotfoundXX/clitest.NNN
$ TMPDIR="$TMPDIR___SAVE"
$
```
{'fraction_non_alphanumeric': 0.12783595113438045, 'fraction_numerical': 0.014834205933682374, 'mean_word_length': 3.807127882599581, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '285038', 'n_tokens_mistral': 854, 'n_tokens_neox': 807, 'n_words': 294}