<commit_before>#!/usr/bin/env bash
. ./wvtest-bup.sh
. t/lib.sh

set -o pipefail

top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?

export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"

bup() { "$top/bup" "$@"; }

WVSTART "compression"
WVPASS cd "$tmpdir"

D=compression0.tmp
WVPASS force-delete "$BUP_DIR"
WVPASS bup init
WVPASS mkdir $D
WVPASS bup index "$top/Documentation"
WVPASS bup save -n compression -0 --strip "$top/Documentation"
# Some platforms set -A by default when root, so just use it everywhere.
expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $?
actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $?
WVPASSEQ "$actual" "$expected"
compression_0_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?

D=compression9.tmp
WVPASS force-delete "$BUP_DIR"
WVPASS bup init
WVPASS mkdir $D
WVPASS bup index "$top/Documentation"
WVPASS bup save -n compression -9 --strip "$top/Documentation"
expected="$(ls -A "$top/Documentation" | sort)" || exit $?
actual="$(bup ls -A compression/latest/ | sort)" || exit $?
WVPASSEQ "$actual" "$expected"
compression_9_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?

WVPASS [ "$compression_9_size" -lt "$compression_0_size" ]


WVPASS rm -rf "$tmpdir"<commit_msg>test-compression.sh: use "tar ... | wc -c" instead of du.<commit_after>#!/usr/bin/env bash
. ./wvtest-bup.sh
. t/lib.sh

set -o pipefail

top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?

export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"

bup() { "$top/bup" "$@"; }
fs-size() { tar cf - "$@" | wc -c; }

WVSTART "compression"
WVPASS cd "$tmpdir"

D=compression0.tmp
WVPASS force-delete "$BUP_DIR"
WVPASS bup init
WVPASS mkdir $D
WVPASS bup index "$top/Documentation"
WVPASS bup save -n compression -0 --strip "$top/Documentation"
# Some platforms set -A by default when root, so just use it everywhere.
expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $?
actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $?
WVPASSEQ "$actual" "$expected"
compression_0_size=$(WVPASS fs-size "$BUP_DIR") || exit $?

D=compression9.tmp
WVPASS force-delete "$BUP_DIR"
WVPASS bup init
WVPASS mkdir $D
WVPASS bup index "$top/Documentation"
WVPASS bup save -n compression -9 --strip "$top/Documentation"
expected="$(ls -A "$top/Documentation" | sort)" || exit $?
actual="$(bup ls -A compression/latest/ | sort)" || exit $?
WVPASSEQ "$actual" "$expected"
compression_9_size=$(WVPASS fs-size "$BUP_DIR") || exit $?

WVPASS [ "$compression_9_size" -lt "$compression_0_size" ]


WVPASS rm -rf "$tmpdir"
{'fraction_non_alphanumeric': 0.17401129943502824, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 4.627118644067797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6473148', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1029, 'n_words': 279}