summaryrefslogtreecommitdiff
path: root/check-previous-test-results.sh
blob: b9f3b1172d127e6488b0a7ced35c264cbffd8a23 (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
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
appfolder="$1"
rootfolder="$2"
changesfile="$3"
platformkeyword="$4"

previousrunfolder="$rootfolder/PreviousUITestResults"
should_run_tests=false

echo "Looking for $previousrunfolder"

if test -e $previousrunfolder
then
	echo "Found previous build's test results folder"
else
	should_run_tests=true
	echo "Previous test results folder not found"
fi

echo "Looking for $previousrunfolder/nunit_output.xml"

if test -e $previousrunfolder/nunit_output.xml
then
	echo "Found previous NUnit results"
else
	should_run_tests=true
	echo "Previous NUnit results not found"
fi

if test -e $changesfile
then
	echo "Found list of changes:"
	changes_require_tests=false
	cat $changesfile
	
	# Look for platform-specific code changes
	if grep -q $platformkeyword $changesfile
	then
		echo "Found changes to $platformkeyword stuff"
		should_run_tests=true
		changes_require_tests=true
	fi

	# Now check for universal stuff (Core, Issues...)
	if grep -q -e 'Xamarin\.Forms\.Controls' -e 'Xamarin\.Forms\.Core' -e 'Xamarin\.Forms\.CustomAttributes' -e 'Xamarin\.Forms\.Xaml' $changesfile
	then
		echo "Found changes which require a UI Tests run"
		should_run_tests=true
		changes_require_tests=true
	fi
	
	if ! $changes_require_tests
	then
		echo "No changes which require a UI Tests run for $platformkeyword were found"
	fi
	
else
	should_run_tests=false
	echo "No changes in this build"
fi

if $should_run_tests
then
	echo "Can't reuse previous results; UI tests will be run."
	touch $appfolder/noresults.xml
	exit 1
else
	echo "We can just reuse the previous test results"
	echo "##teamcity[importData type='nunit' path='$previousrunfolder/nunit_output.xml' parseOutOfDate='true']"
	cp $previousrunfolder/nunit_output.xml $appfolder/nunit_output.xml
	exit 0
fi