[msitools: 8/16] tests: translate autotest tests to BATS
- From: Marc-André Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [msitools: 8/16] tests: translate autotest tests to BATS
- Date: Sun, 29 Mar 2020 01:09:09 +0000 (UTC)
commit 2f87713ea1c1eabc336a4c4ab96c6886d936aaad
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Sun Mar 29 00:34:24 2020 +0100
tests: translate autotest tests to BATS
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
.gitmodules | 3 +
subprojects/bats-core | 1 +
tests/common.bash | 24 ++++++++
tests/tools.bats | 137 +++++++++++++++++++++++++++++++++++++++++
tests/wixl.bats | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 330 insertions(+)
---
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..b2c350d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "subprojects/bats-core"]
+ path = subprojects/bats-core
+ url = https://github.com/bats-core/bats-core
diff --git a/subprojects/bats-core b/subprojects/bats-core
new file mode 160000
index 0000000..87b16eb
--- /dev/null
+++ b/subprojects/bats-core
@@ -0,0 +1 @@
+Subproject commit 87b16eb8ec381beca7f05d028e4ad7cf3f647a0f
diff --git a/tests/common.bash b/tests/common.bash
new file mode 100644
index 0000000..d70cd68
--- /dev/null
+++ b/tests/common.bash
@@ -0,0 +1,24 @@
+#!/usr/bin/bash
+
+BUILDDIR=${BUILDDIR:=`pwd`}
+SRCDIR=${SRCDIR:=`pwd`/..}
+
+testdatabase="$BUILDDIR/tests/testdatabase$EXT"
+testrecord="$BUILDDIR/tests/testrecord$EXT"
+testsuminfo="$BUILDDIR/tests/testsuminfo$EXT"
+msibuild="$BUILDDIR/tools/msibuild$EXT"
+msiinfo="$BUILDDIR/tools/msiinfo$EXT"
+wixl="$BUILDDIR/tools/wixl/wixl$EXT"
+wixlheat="$BUILDDIR/tools/wixl/wixl-heat$EXT"
+
+setup() {
+ export TEST_SUITE_TMPDIR=`mktemp -d`
+ cp -R "$SRCDIR/tests/data"/* "$TEST_SUITE_TMPDIR"
+ cd "$TEST_SUITE_TMPDIR"
+}
+
+teardown() {
+ if [ -n "$TEST_SUITE_TMPDIR" ]; then
+ echo rm -rf "$TEST_SUITE_TMPDIR"
+ fi
+}
diff --git a/tests/tools.bats b/tests/tools.bats
new file mode 100644
index 0000000..b777f60
--- /dev/null
+++ b/tests/tools.bats
@@ -0,0 +1,137 @@
+#!/usr/bin/env bats
+
+load common
+
+@test "testdatabase shouldn't print fail" {
+ run "$testdatabase"
+ [ "$status" -eq 0 ]
+ ! echo "$output" | grep ^FAIL
+}
+
+@test "testrecord shouldn't print fail" {
+ run "$testrecord"
+ [ "$status" -eq 0 ]
+ ! echo "$output" | grep ^FAIL
+}
+
+@test "testsuminfo shouldn't print fail" {
+ if [ ! -x "$testsuminfo" ]; then
+ skip "testsuminfo isn't built"
+ fi
+ run "$testsuminfo"
+ [ "$status" -eq 0 ]
+ ! echo "$output" | grep ^FAIL
+}
+
+@test "msibuild - invalid command line" {
+ run "$msibuild"
+ [ "$status" -eq 1 ]
+ run "$msibuild" out.msi
+ [ "$status" -eq 1 ]
+ [ ! -f out.msi ]
+}
+
+@test "msibuild - empty MSI" {
+ run "$msibuild" out.msi -s 'Project name'
+ [ "$status" -eq 0 ]
+ run "$msiinfo" suminfo out.msi
+ [ "$status" -eq 0 ]
+ echo "$output" | grep "Subject: Project name"
+ echo "$output" | grep "Template: ;1033"
+ echo "$output" | grep "Version: 200"
+}
+
+@test "msibuild - UUID" {
+ run "$msibuild" out.msi -s 'Project name'
+ [ "$status" -eq 0 ]
+ run "$msiinfo" suminfo out.msi
+ [ "$status" -eq 0 ]
+ UUID='\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}'
+ echo "$output" | grep -E "^Revision number \\(UUID\\): $UUID\$"
+}
+
+@test "msibuild - UUID does not change" {
+ run "$msibuild" out.msi -s 'Project name'
+ run "$msiinfo" suminfo out.msi
+ exp=$(echo "$output" | grep "^Revision")
+ run "$msibuild" out.msi -s 'Project name2'
+ run "$msiinfo" suminfo out.msi
+ echo "$output" | grep "Subject: Project name2"
+ [ "$(echo "$output" | grep "^Revision")" = "$exp" ]
+}
+
+@test "msibuild - add stream" {
+ echo "This is test.txt" > test.txt
+ run "$msibuild" out.msi -a Binary.testtxt test.txt
+ run "$msiinfo" streams out.msi
+ output=$(echo "$output" | grep -v SummaryInformation)
+ [ "$output" = "Binary.testtxt" ]
+ run "$msiinfo" extract out.msi Binary.testtxt
+ [ "$output" = "This is test.txt" ]
+}
+
+@test "msibuild - add tables" {
+ cat >tables.txt <<EOF
+Name
+s64
+_Tables
+Binary
+EOF
+ run "$msibuild" out.msi -i tables.txt
+ run "$msiinfo" tables out.msi
+ [ "$output" = "_SummaryInformation
+_ForceCodepage
+Binary" ]
+}
+
+@test "msibuild - add tables and definitions" {
+ run "$msibuild" out.msi -i tables.txt columns.txt
+ run "$msiinfo" export out.msi Icon
+ exp=$(printf "Name Data\r\ns72 v0\r\nIcon Name\r\n")
+ [ "$output" = "$exp" ]
+}
+
+@test "msibuild - seperate invocations" {
+ run "$msibuild" out.msi -i tables.txt
+ run "$msiinfo" tables out.msi
+ exp="$output"
+ run "$msibuild" out.msi -i columns.txt
+ run "$msiinfo" tables out.msi
+ [ "$output" = "$exp" ]
+}
+
+@test "msibuild - add table with data" {
+ run "$msibuild" out.msi -i tables.txt columns.txt button.txt
+ run "$msiinfo" export out.msi RadioButton
+ exp=$(cat button.txt)
+ [ "$output" = "$exp" ]
+}
+
+@test "msibuild - add table with stream" {
+ run "$msibuild" out.msi -i tables.txt columns.txt icon.txt
+ run "$msiinfo" streams out.msi
+ out=$(echo "$output" | grep -v SummaryInformation)
+ [ "$out" = "Icon.firefox.16.0.2.0.ico.exe" ]
+ run "$msiinfo" extract out.msi Icon.firefox.16.0.2.0.ico.exe
+ exp=$(cat Icon/firefox.16.0.2.0.ico.exe)
+ [ "$output" = "$exp" ]
+}
+
+@test "msibuild - update _SummaryInformation table" {
+ run "$msibuild" -i out.msi _SummaryInformation.idt
+ run "$msiinfo" suminfo out.msi
+ [ "$output" = "Title: Installation Database
+Subject: Acme's Foobar 1.0 Installer
+Author: Acme Ltd.
+Keywords: Installer
+Comments: Foobar is a registered trademark of Acme Ltd.
+Template: Intel;1033
+Revision number (UUID): {D045A303-F114-4A3B-A01D-24FC2D2A67D7}
+Created: Tue Dec 18 15:12:50 2012
+Last saved: Tue Dec 18 15:12:50 2012
+Version: 100 (64)
+Source: 2 (2)
+Restrict: 0 (0)
+Application: Windows Installer XML (3.7.1119.0)
+Security: 2 (2)" ]
+}
diff --git a/tests/wixl.bats b/tests/wixl.bats
new file mode 100644
index 0000000..50cc4ef
--- /dev/null
+++ b/tests/wixl.bats
@@ -0,0 +1,165 @@
+#!/usr/bin/env bats
+
+load common
+
+@test "wixl - invalid command line" {
+ run "$wixl"
+ [ "$status" -eq 1 ]
+ run "$wixl" out.msi foo.wxs
+ [ "$status" -eq 1 ]
+ run "$wixl" -o out.msi
+ [ "$status" -eq 1 ]
+ run "$wixl" -E
+ [ "$status" -eq 1 ]
+ run "$wixl" -D
+ [ "$status" -eq 1 ]
+ run "$wixl" -E -o out.msi
+ [ "$status" -eq 1 ]
+ run test -f out.msi
+ [ "$status" -eq 1 ]
+}
+
+@test "wixl - WiX tutorial SampleFirst" {
+ cd wixl
+ run "$wixl" -o out.msi SampleFirst.wxs
+ [ "$status" -eq 0 ]
+ # FIXME: add tons of tests on out.msi
+ test -f out.msi
+}
+
+@test "wixl - SampleUser" {
+ cd wixl
+ run "$wixl" -o out.msi SampleUser.wxs
+ [ "$status" -eq 0 ]
+ # FIXME: add tons of tests on out.msi
+ test -f out.msi
+}
+
+@test "wixl - SampleMachine" {
+ cd wixl
+ run "$wixl" -o out.msi SampleMachine.wxs
+ [ "$status" -eq 0 ]
+ run "$msiinfo" export out.msi Property
+ echo "$output" | grep -q 'ALLUSERS 1'
+}
+
+@test "wixl - stable component GUIDs" {
+ cd wixl
+ run "$wixl" -o out.msi ComponentGUID.wxs
+ run "$msiinfo" export -s out.msi Component
+ echo "$output" > /tmp/out
+ out=$(echo "$output" | sed 's/reg\w*'// | sort | grep INSERT)
+ exp="INSERT INTO \`Component\` (\`Component\`, \`ComponentId\`, \`Directory_\`, \`Attributes\`,
\`KeyPath\`) VALUES ('MainExecutable', '{0E066A5A-AE0E-5F43-B984-F6C685AF13F0}', 'INSTALLDIR', 0, 'FoobarEXE')
+INSERT INTO \`Component\` (\`Component\`, \`ComponentId\`, \`Directory_\`, \`Attributes\`, \`KeyPath\`)
VALUES ('Manual', '{BE256176-257D-5ACD-902D-801F8E305172}', 'INSTALLDIR', 0, 'Manual')
+INSERT INTO \`Component\` (\`Component\`, \`ComponentId\`, \`Directory_\`, \`Attributes\`, \`KeyPath\`)
VALUES ('ProgramMenuDir', '{F47E26A5-C6A8-57BA-B6B5-CB2AE74E5256}', 'ProgramMenuDir', 4, '')"
+ [ "$out" = "$exp" ]
+}
+
+@test "wixl - WiX tutorial SampleFragment" {
+ cd wixl
+ run "$wixl" -o out.msi SampleFragment.wxs Manual.wxs
+ test -f out.msi
+}
+
+@test "wixl - preprocessor variables" {
+ cd wixl
+ export MY_VAR="Hello!"
+ cat >variables.wxs <<EOF
+<?xml version="1.0"?>
+<?define Version = "0.2.0"?>
+<?define UpgradeCode = "ABCDDCBA-8392-0202-1993-199374829923"?>
+<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
+ <Property Id="Id0" Value="\$(var.UpgradeCode)"/>
+ <Property Id="Id0.1" Value="$\$(var.UpgradeCode)"/>
+ <Property Id="Id0.2" Value="$$\$(var.UpgradeCode)"/>
+ <?define UpgradeCode = "ABCDDCBA-8392-0202-1993-199374829924"?>
+ <Property Id="Id2" Value="\$(var.UpgradeCode)"/>
+ <Property Id="Id3" Value="\$(var.Version)"/>
+ <?define A = "A"?><?define B = "B"?>
+ <Property Id="IdAB" Value="\$(var.A)\$(var.B)"/>
+ <Property Id="IdHello" Value="\$(env.MY_VAR)"/>
+ <Property Id="IdSys" Value="(\$(sys.SOURCEFILEDIR))foo"/>
+</Wix>
+EOF
+ run "$wixl" -E variables.wxs
+
+ read -d '' exp <<EOF || true
+<?xml version="1.0"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Property Id="Id0" Value="ABCDDCBA-8392-0202-1993-199374829923"/>
+ <Property Id="Id0.1" Value="\$ABCDDCBA-8392-0202-1993-199374829923"/>
+ <Property Id="Id0.2" Value="$$ABCDDCBA-8392-0202-1993-199374829923"/>
+ <Property Id="Id2" Value="ABCDDCBA-8392-0202-1993-199374829924"/>
+ <Property Id="Id3" Value="0.2.0"/>
+ <Property Id="IdAB" Value="AB"/>
+ <Property Id="IdHello" Value="Hello!"/>
+ <Property Id="IdSys" Value="(variables.wxs)foo"/>
+</Wix>
+EOF
+ [ "$output" = "$exp" ]
+
+ cat >variables.wxs <<EOF
+<?xml version="1.0"?>
+<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
+ <Property Id="Id\$(var.Foo)" Value="\$(var.Foo)"/>
+ <Property Id="Id\$(var.Zig)" Value="\$(var.Zig)"/>
+</Wix>
+EOF
+ run "$wixl" -E variables.wxs -D Foo -D Zig=Zag
+ read -d '' exp <<EOF || true
+<?xml version="1.0"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Property Id="Id1" Value="1"/>
+ <Property Id="IdZag" Value="Zag"/>
+</Wix>
+EOF
+ [ "$output" = "$exp" ]
+}
+
+@test "wixl - preprocessor include & condition" {
+ cd wixl
+ run "$wixl" -o out.msi IncludeTest.wxs
+ [ "$output" = "IncludeWarn.wxi:3: warning: IncludeWarn is included" ]
+ run "$wixl" -D Bar -o out.msi IncludeTest.wxs
+ [ "$output" = "IncludeTest.wxs:11: warning: Bar" ]
+ run "$wixl" -D Foo -o out.msi IncludeTest.wxs
+ [ "$output" = "IncludeTest.wxs:4: warning: Foo" ]
+ run "$wixl" -o out.msi arch-condition.wxs
+ [ "$output" = "arch-condition.wxs:12: warning: no" ]
+ test -f out.msi
+}
+
+@test "wixl - system include directory" {
+ cd wixl
+ cat >include.wxs <<EOF
+<?xml version='1.0' encoding='windows-1252'?>
+<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
+ <?include zlib.wxi ?>
+</Wix>
+EOF
+ run "$wixl" --wxidir "$SRCDIR/data/wixl" -E include.wxs -D SourceDir=foo -D Win64=no
+ echo "$output" | grep -F zlib1.dll
+}
+
+@test "wixl - ARP example" {
+ cd wixl
+ run "$wixl" -o out.msi test-arp.wxs
+ test -f out.msi
+}
+
+@test "wixl - Binary/CustomAction" {
+ cd wixl
+ run "$wixl" -o out.msi binary.wxs
+ test -f out.msi
+}
+
+@test "wixl-heat - simple" {
+ mkdir -p test/a/b test/c
+ touch test/a/file test/c/file
+ find test > list
+ out=$(cat list | "$wixlheat" -p test/ | grep File | sort)
+ [ "$out" = ' <File Id="fil18D0F9984B0565992BE4B64E573B4237" KeyPath="yes"
Source="SourceDir/a/file"/>
+ <File Id="filD6217F3B9CF0F6E4697D603E4E611F1C" KeyPath="yes" Source="SourceDir/c/file"/>' ]
+ out=$(cat list | "$wixlheat" -p test/ -x c | grep File | sort)
+ [ "$out" = ' <File Id="fil18D0F9984B0565992BE4B64E573B4237" KeyPath="yes"
Source="SourceDir/a/file"/>' ]
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]