~dricottone/my-utils

ref: 0fc0112189c80cb24b03ed1a9b8631466657c637 my-utils/tests/bom_test.sh -rwxr-xr-x 1.3 KiB
0fc01121Dominic Ricottone Added tarls; Update to mktar for archiving directories 4 years ago
                                                                                
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# debom

# create temp directory
mkdir -p tests/temp_bom

# exit codes
if ! debom -V >/dev/null 2>&1; then
  printf "Wrong exit code on 'debom -V' - should be 0\n"
  exit 1
elif ! debom -h >/dev/null 2>&1; then
  printf "Wrong exit code on 'debom -h' - should be 0\n"
  exit 1
elif debom >/dev/null 2>&1; then
  printf "Wrong exit code on 'debom' - should be 1\n"
  exit 1
elif debom non-existant >/dev/null 2>&1; then
  printf "Wrong exit code on 'debom non-existant' should be 1\n"
  exit 1
fi

# de-BOM a file
cd tests/temp_bom
debom -d ../static/debom_target.txt > debom.txt
if ! cmp ../static/debom_result.txt debom.txt >/dev/null 2>&1; then
  printf "Failure in de-BOM test\n"
  exit 1
fi
cd ../..

# rebom

# exit codes
if ! rebom -v >/dev/null 2>&1; then
  printf "Wrong exit code on 'rebom -v' - should be 0\n"
  exit 1
elif ! rebom -h >/dev/null 2>&1; then
  printf "Wrong exit code on 'rebom -h' - should be 0\n"
  exit 1
elif rebom >/dev/null 2>&1; then
  printf "Wrong exit code on 'rebom' - should be 1\n"
  exit 1
elif rebom non-existant >/dev/null 2>&1; then
  printf "Wrong exit code on 'rebom non-existant' should be 1\n"
  exit 1
fi

# re-BOM a file
cd tests/temp_bom
rebom ../static/debom_result.txt > rebom.txt
if ! cmp ../static/debom_target.txt rebom.txt >/dev/null 2>&1; then
  printf "Failure in re-BOM test\n"
  exit 1
fi
cd ../..