summaryrefslogtreecommitdiff
path: root/test/librestage-test.sh
blob: affad6a761a5c27f8b48eb054cf9ba585bd70977 (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
72
#!/usr/bin/env roundup

describe librestage

. ./test-common.sh

before() {
	_before

	mkdir -p $XDG_CONFIG_HOME/libretools
	echo "WORKDIR='$tmpdir/workdir'" > $XDG_CONFIG_HOME/libretools/libretools.conf
	echo "ARCHES=('x86_64' 'i686' 'misp64el')" >> $XDG_CONFIG_HOME/libretools/libretools.conf

	mkdir -p $XDG_CONFIG_HOME/xbs
	echo "BUILDSYSTEM=abslibre" > $XDG_CONFIG_HOME/xbs/xbs.conf

	echo 'PKGEXT=.pkg.tar.gz' > $HOME/.makepkg.conf
	echo "PKGDEST='$tmpdir/workdir/pkgdest'" >> $HOME/.makepkg.conf
	echo "PACKAGER='Test Suite <test@localhost>'" >> $HOME/.makepkg.conf
	mkdir -p "$tmpdir/workdir/pkgdest"
}

after() {
	_after
}

it_displays_usage_text() {
	rm -rf "$XDG_CONFIG_HOME"
	LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr

	[[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]]
	empty "$tmpdir/stderr"
}

it_fails_with_0_args() {
	librestage >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

	[[ $stat != 0 ]]
	empty "$tmpdir/stdout"
	not empty "$tmpdir/stderr"
}

it_fails_with_invalid_args() {
	librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

	[[ $stat != 0 ]]
	empty "$tmpdir/stdout"
	not empty "$tmpdir/stderr"
}

it_guesses_the_repo() {
	mkdir -p -- "$tmpdir/reponame/libretools-hello"
	cp librestage.d/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD"
	cd "$tmpdir/reponame/libretools-hello"

	makepkg
	librestage

	[[ -f $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.gz ]]
}

it_stages_packages_without_PKGDEST() {
	echo "PKGDEST=''" >> $HOME/.makepkg.conf

	cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
	cd "$tmpdir"

	makepkg
	librestage repo1

	[[ -f $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.gz ]]
}