Fix tests to use version 5 format

This commit is contained in:
Chris Down 2018-02-20 11:30:07 +00:00
parent 4e969bd67d
commit 1a145d298f
2 changed files with 7 additions and 8 deletions

View file

@ -6,9 +6,9 @@ set -o pipefail
: "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
major_version=4
major_version=5
dir=$CM_DIR/clipmenu.$major_version.$USER
cache_file=$dir/line_cache
cache_file=$dir/line_cache_primary
if [[ $0 == /* ]]; then
location=${0%/*}
@ -58,8 +58,8 @@ rm -rf "$dir"
mkdir -p "$dir"
cat > "$cache_file" << 'EOF'
Selected text. (2 lines)
Selected text 2. (2 lines)
1234 Selected text. (2 lines)
1235 Selected text 2. (2 lines)
EOF
cat > "$dir/$(cksum <<< 'Selected text. (2 lines)')" << 'EOF'
@ -70,7 +70,6 @@ EOF
### TESTS ###
temp=$(mktemp)
trap 'rm -f -- "$temp"' EXIT
/tmp/clipmenu --foo bar > "$temp" 2>&1

View file

@ -1,6 +1,6 @@
#!/bin/bash
major_version=4
major_version=5
msg() {
printf '>>> %s\n' "$@" >&2
@ -9,7 +9,7 @@ msg() {
: "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
dir=$CM_DIR/clipmenu.$major_version.$USER
cache_file=$dir/line_cache
cache_file=$dir/line_cache_primary
log=$(mktemp)
tim=$(mktemp)
@ -62,7 +62,7 @@ if ! (( NO_RECREATE )); then
)
read -r first_line_raw <<< "$data"
printf -v first_line '%s (%s lines)\n' "$first_line_raw" "$num_lines"
printf '%s' "$first_line" >> "$cache_file"
printf '%d %s' "$i" "$first_line" >> "$cache_file"
fn=$dir/$(cksum <<< "$first_line")
printf '%s' "$data" > "$fn"
done