File: integration

package info (click to toggle)
denemo 2.6.49-0.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 66,916 kB
  • sloc: ansic: 94,587; lisp: 38,713; xml: 22,675; python: 1,930; sh: 1,239; makefile: 642; yacc: 288; sed: 93
file content (124 lines) | stat: -rwxr-xr-x 2,856 bytes parent folder | download | duplicates (4)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# modelled after denemo/tests/integration.c

set -u

exec 2>&1

oneTimeSetUp() {
	export GUILE_AUTO_COMPILE=0
	export HOME=$AUTOPKGTEST_TMP

	example_dir="examples"
	fixtures_dir="tests/fixtures"
	ref_dir="references"

	temp_dir="$AUTOPKGTEST_TMP"
	mkdir -p $temp_dir/denemo
	mkdir -p $temp_dir/scm
}

tearDown() {
	echo
}

compare_denemo_files() {
	a=$1
	b=$2
	assertTrue 'The two files should be identical' 'diff "$a" "$b"'
}

testOpenBlankFile() {
	input="$fixtures_dir/denemo/blank.denemo"

	echo "Opening $input"
	denemo -n -e "$input"
	exit_code=$?
	assertEquals 'Denemo should have exited with 0' 0 $exit_code
}

testOpenSaveBlankFile() {
	output="$temp_dir/denemo/blank.denemo"
	input="$fixtures_dir/denemo/blank.denemo"

	scheme="(d-SaveAs \"$output\")(d-Quit)"
	denemo -n -e -a "$scheme" "$input"
	exit_code=$?
	assertEquals 'Denemo should have exited with 0' 0 $exit_code

	assertTrue "Output file $output should exist" '[ -r "$output" ]'

	denemo -n -e "$output"
	exit_code=$?
	assertEquals 'Denemo should have exited with 0' 0 $exit_code

	compare_denemo_files "$input" "$output"
}

open_save_complex_file() {
	input="$1"
	filename="${input##*/}"
	base_name="${filename%.*}"
	extension="${input##*.}"

	output_filename="$base_name.denemo"
	output="$temp_dir/$extension/$output_filename"
	reference="$ref_dir/$extension/$output_filename"

	echo "Opening $input"
	scheme="(d-SaveAs \"$output\")(d-Quit)"
	if [ "$extension" = "scm" ]; then
		echo denemo -n -e -i "$input" -a "$scheme"
		denemo -n -e -i "$input" -a "$scheme" >& /dev/null
	else
		denemo -n -e -a "$scheme" "$input" >& /dev/null
	fi
	exit_code=$?
	assertEquals 'Denemo should have exited with 0' 0 $exit_code

	assertTrue "Output file $output should exist" '[ -r "$output" ]'

	echo "Finding and reopening $output"
	denemo -n -e "$output" >& /dev/null
	exit_code=$?
	assertEquals 'Denemo should have exited with 0' 0 $exit_code

	# Comparison
	if [ -f "$reference" ]; then
		echo "Comparing $output with the reference $reference"
		compare_denemo_files "$output" "$reference"
	elif [ "$extension" = "denemo" ]; then
		echo "Comparing $input with $output"
		compare_denemo_files "$input" "$output"
	else
		compare_file="$base_name.denemo"
		if [ -f "$compare_file" ]; then
			echo "Comparing $compare_file with $output"
			compare_denemo_files "$compare_file" "$output"
		fi
	fi
}

parse_dir_and_run_complex_test() {
	path=$1
	extension=$2

	for i in $(find $path -name "*.$extension"); do
		open_save_complex_file $i
	done
}

testOpenSaveComplexDenemoFilesInExampleDir() {
	parse_dir_and_run_complex_test $example_dir "denemo"
}

testOpenSaveComplexDenemoFilesInFixturesDir() {
	parse_dir_and_run_complex_test $fixtures_dir "denemo"
}

testOpenSaveComplexScmFilesInFixturesDir() {
	parse_dir_and_run_complex_test $fixtures_dir "scm"
}

# load and run shUnit2
. shunit2