File: basic-command-line

package info (click to toggle)
diffoscope 177
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,340 kB
  • sloc: python: 14,727; makefile: 97; sh: 81; xml: 26; javascript: 2
file content (56 lines) | stat: -rwxr-xr-x 1,494 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

# not set -e: we are testing exit codes

# to have diffoscope able to output stuff in utf-8
export LC_ALL=C.UTF-8

if ! [ -d "$AUTOPKGTEST_TMP" ]; then
	AUTOPKGTEST_TMP=`mktemp -d`
	TEMP=true
fi

echo "a" > $AUTOPKGTEST_TMP/a
echo "a" > $AUTOPKGTEST_TMP/a_
echo "b" > $AUTOPKGTEST_TMP/b

echo "Testing identical files..."
diffoscope $AUTOPKGTEST_TMP/a $AUTOPKGTEST_TMP/a_
if [ $? -ne 0 ]; then
	echo "Exit code was different from 0 when comparing files with identical content." >&2
	exit 1
fi

echo "Testing different files..."
diffoscope $AUTOPKGTEST_TMP/a $AUTOPKGTEST_TMP/b
if [ $? -ne 1 ]; then
	echo "Exit code was different from 1 when comparing files with different content." >&2
	exit 1
fi

echo "Testing LC_ALL=C works..."
LC_ALL=C diffoscope --debug $AUTOPKGTEST_TMP/a $AUTOPKGTEST_TMP/a_ 2>/dev/null
if [ $? -ne 0 ]; then
	echo "diffoscope could not handle LC_ALL=C; make sure you're not unconditionally outputting non-ascii chars anywhere." >&2
	exit 1
fi

echo "Testing LC_ALL=C works (--help)..."
LC_ALL=C diffoscope --help >/dev/null
if [ $? -ne 0 ]; then
	echo "diffoscope could not handle LC_ALL=C; make sure you're not unconditionally outputting non-ascii chars anywhere." >&2
	exit 1
fi

echo "Testing invalid command line flag..."
diffoscope --thisflagdoesntexistandwontexist
if [ $? -ne 2 ]; then
	echo "Exit code was different from 2 when passing a non-existent flag." >&2
	exit 1
fi

if [ -n "${TEMP:-}" ]; then
	rm -rf "$AUTOPKGTEST_TMP"
fi

echo "All good!"