summaryrefslogtreecommitdiffstats
path: root/test/e2e_test.sh
blob: 95207f8172331378a9f0c50f286d60aafef043c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -e

test_dir="test"
orig_dir="$(pwd)"
cd "$(git rev-parse --show-toplevel)"
cargo build

# basic functionality
diff -w <(cargo run -- 0:1 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_0:1.txt")
diff -w <(cargo run -- 0 3 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_0_3.txt")
diff -w <(cargo run -- :1 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_:1.txt")
diff -w <(cargo run -- 9 3 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_9_3.txt")
diff -w <(cargo run -- 9 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_9.txt")
diff -w <(cargo run -- 12 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_12.txt")
diff -w <(cargo run -- 4:2 -i ${test_dir}/lorem.txt) <(cat "${test_dir}/choose_4:2.txt")
# add tests for different delimiters
# add tests using piping

set +e

# test failure to parse arguments
cargo run -- d:i -i ${test_dir}/lorem.txt >/dev/null
r=$?
if [ $r -ne 2 ]; then
  echo "Failed to return error code 2 on failure to parse arguments"
else
  echo "Success"
fi

cargo test

cd $orig_dir