From 6d110a03892bf164826b27bd9f92ef396f36d1b3 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 8 Oct 2019 19:27:17 -0500 Subject: tests: Now with 100% more automated testing --- tests/.rspec | 2 + tests/fixtures/0001-basic.installfile | 5 ++ tests/fixtures/0002-basic-commented.installfile | 17 +++++ tests/fixtures/0003-basic-whitespace.installfile | 7 ++ tests/fixtures/0004-blank.installfile | 0 tests/fixtures/0005-only-comments.installfile | 1 + tests/fixtures/0006-no-network.installfile | 4 ++ tests/fixtures/0007-no-hostname.installfile | 4 ++ tests/fixtures/0008-no-pkginstall.installfile | 4 ++ tests/fixtures/0009-no-rootpw.installfile | 4 ++ tests/fixtures/0010-no-mount.installfile | 4 ++ tests/fixtures/0011-invalid-network.installfile | 5 ++ tests/fixtures/0012-invalid-hostname.installfile | 5 ++ tests/fixtures/0013-invalid-rootpw.installfile | 5 ++ tests/fixtures/0014-invalid-mount.installfile | 5 ++ .../fixtures/0015-keys-without-values.installfile | 5 ++ tests/fixtures/0016-invalid-key.installfile | 6 ++ tests/fixtures/0017-line-too-long.installfile | 5 ++ tests/fixtures/0018-duplicate-network.installfile | 6 ++ tests/fixtures/0019-duplicate-hostname.installfile | 6 ++ tests/fixtures/0020-duplicate-rootpw.installfile | 6 ++ .../fixtures/0021-duplicate-root-mount.installfile | 6 ++ tests/scripts/0001-basic.installfile | 5 -- tests/scripts/0002-basic-commented.installfile | 17 ----- tests/scripts/0003-basic-whitespace.installfile | 7 -- tests/scripts/0004-blank.installfile | 0 tests/scripts/0005-only-comments.installfile | 1 - tests/scripts/0006-no-network.installfile | 4 -- tests/scripts/0007-no-hostname.installfile | 4 -- tests/scripts/0008-no-pkginstall.installfile | 4 -- tests/scripts/0009-no-rootpw.installfile | 4 -- tests/scripts/0010-no-mount.installfile | 4 -- tests/scripts/0011-invalid-network.installfile | 5 -- tests/scripts/0012-invalid-hostname.installfile | 5 -- tests/scripts/0013-invalid-rootpw.installfile | 5 -- tests/scripts/0014-invalid-mount.installfile | 5 -- tests/scripts/0015-keys-without-values.installfile | 5 -- tests/scripts/0016-invalid-key.installfile | 6 -- tests/scripts/0017-line-too-long.installfile | 5 -- tests/scripts/0018-duplicate-network.installfile | 6 -- tests/scripts/0019-duplicate-hostname.installfile | 6 -- tests/scripts/0020-duplicate-rootpw.installfile | 6 -- .../scripts/0021-duplicate-root-mount.installfile | 6 -- tests/spec/spec_helper.rb | 52 ++++++++++++++ tests/spec/validator.rb | 81 ++++++++++++++++++++++ 45 files changed, 245 insertions(+), 110 deletions(-) create mode 100644 tests/.rspec create mode 100644 tests/fixtures/0001-basic.installfile create mode 100644 tests/fixtures/0002-basic-commented.installfile create mode 100644 tests/fixtures/0003-basic-whitespace.installfile create mode 100644 tests/fixtures/0004-blank.installfile create mode 100644 tests/fixtures/0005-only-comments.installfile create mode 100644 tests/fixtures/0006-no-network.installfile create mode 100644 tests/fixtures/0007-no-hostname.installfile create mode 100644 tests/fixtures/0008-no-pkginstall.installfile create mode 100644 tests/fixtures/0009-no-rootpw.installfile create mode 100644 tests/fixtures/0010-no-mount.installfile create mode 100644 tests/fixtures/0011-invalid-network.installfile create mode 100644 tests/fixtures/0012-invalid-hostname.installfile create mode 100644 tests/fixtures/0013-invalid-rootpw.installfile create mode 100644 tests/fixtures/0014-invalid-mount.installfile create mode 100644 tests/fixtures/0015-keys-without-values.installfile create mode 100644 tests/fixtures/0016-invalid-key.installfile create mode 100644 tests/fixtures/0017-line-too-long.installfile create mode 100644 tests/fixtures/0018-duplicate-network.installfile create mode 100644 tests/fixtures/0019-duplicate-hostname.installfile create mode 100644 tests/fixtures/0020-duplicate-rootpw.installfile create mode 100644 tests/fixtures/0021-duplicate-root-mount.installfile delete mode 100644 tests/scripts/0001-basic.installfile delete mode 100644 tests/scripts/0002-basic-commented.installfile delete mode 100644 tests/scripts/0003-basic-whitespace.installfile delete mode 100644 tests/scripts/0004-blank.installfile delete mode 100644 tests/scripts/0005-only-comments.installfile delete mode 100644 tests/scripts/0006-no-network.installfile delete mode 100644 tests/scripts/0007-no-hostname.installfile delete mode 100644 tests/scripts/0008-no-pkginstall.installfile delete mode 100644 tests/scripts/0009-no-rootpw.installfile delete mode 100644 tests/scripts/0010-no-mount.installfile delete mode 100644 tests/scripts/0011-invalid-network.installfile delete mode 100644 tests/scripts/0012-invalid-hostname.installfile delete mode 100644 tests/scripts/0013-invalid-rootpw.installfile delete mode 100644 tests/scripts/0014-invalid-mount.installfile delete mode 100644 tests/scripts/0015-keys-without-values.installfile delete mode 100644 tests/scripts/0016-invalid-key.installfile delete mode 100644 tests/scripts/0017-line-too-long.installfile delete mode 100644 tests/scripts/0018-duplicate-network.installfile delete mode 100644 tests/scripts/0019-duplicate-hostname.installfile delete mode 100644 tests/scripts/0020-duplicate-rootpw.installfile delete mode 100644 tests/scripts/0021-duplicate-root-mount.installfile create mode 100644 tests/spec/spec_helper.rb create mode 100644 tests/spec/validator.rb (limited to 'tests') diff --git a/tests/.rspec b/tests/.rspec new file mode 100644 index 0000000..83e16f8 --- /dev/null +++ b/tests/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/tests/fixtures/0001-basic.installfile b/tests/fixtures/0001-basic.installfile new file mode 100644 index 0000000..a87b8f1 --- /dev/null +++ b/tests/fixtures/0001-basic.installfile @@ -0,0 +1,5 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0002-basic-commented.installfile b/tests/fixtures/0002-basic-commented.installfile new file mode 100644 index 0000000..fd9a5e8 --- /dev/null +++ b/tests/fixtures/0002-basic-commented.installfile @@ -0,0 +1,17 @@ +# This file contains comments. + +# And blank lines. +network true + +hostname test.machine +pkginstall adelie-base + +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ + + + + + + + +mount /dev/sda1 / diff --git a/tests/fixtures/0003-basic-whitespace.installfile b/tests/fixtures/0003-basic-whitespace.installfile new file mode 100644 index 0000000..4754458 --- /dev/null +++ b/tests/fixtures/0003-basic-whitespace.installfile @@ -0,0 +1,7 @@ +# This file has whitespace everywhere before keys, and even on otherwise-empty lines. + network true + hostname test.machine +pkginstall adelie-base + rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ + + mount /dev/sda1 / diff --git a/tests/fixtures/0004-blank.installfile b/tests/fixtures/0004-blank.installfile new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixtures/0005-only-comments.installfile b/tests/fixtures/0005-only-comments.installfile new file mode 100644 index 0000000..72985bf --- /dev/null +++ b/tests/fixtures/0005-only-comments.installfile @@ -0,0 +1 @@ +# This file is invalid, because it only contains comments. diff --git a/tests/fixtures/0006-no-network.installfile b/tests/fixtures/0006-no-network.installfile new file mode 100644 index 0000000..fcf0943 --- /dev/null +++ b/tests/fixtures/0006-no-network.installfile @@ -0,0 +1,4 @@ +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0007-no-hostname.installfile b/tests/fixtures/0007-no-hostname.installfile new file mode 100644 index 0000000..5e314e5 --- /dev/null +++ b/tests/fixtures/0007-no-hostname.installfile @@ -0,0 +1,4 @@ +network true +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0008-no-pkginstall.installfile b/tests/fixtures/0008-no-pkginstall.installfile new file mode 100644 index 0000000..2751414 --- /dev/null +++ b/tests/fixtures/0008-no-pkginstall.installfile @@ -0,0 +1,4 @@ +network true +hostname test.machine +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0009-no-rootpw.installfile b/tests/fixtures/0009-no-rootpw.installfile new file mode 100644 index 0000000..d15d6b1 --- /dev/null +++ b/tests/fixtures/0009-no-rootpw.installfile @@ -0,0 +1,4 @@ +network true +hostname test.machine +pkginstall adelie-base +mount /dev/sda1 / diff --git a/tests/fixtures/0010-no-mount.installfile b/tests/fixtures/0010-no-mount.installfile new file mode 100644 index 0000000..99fc1da --- /dev/null +++ b/tests/fixtures/0010-no-mount.installfile @@ -0,0 +1,4 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ diff --git a/tests/fixtures/0011-invalid-network.installfile b/tests/fixtures/0011-invalid-network.installfile new file mode 100644 index 0000000..77de188 --- /dev/null +++ b/tests/fixtures/0011-invalid-network.installfile @@ -0,0 +1,5 @@ +network ture +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0012-invalid-hostname.installfile b/tests/fixtures/0012-invalid-hostname.installfile new file mode 100644 index 0000000..6ea1fbc --- /dev/null +++ b/tests/fixtures/0012-invalid-hostname.installfile @@ -0,0 +1,5 @@ +network true +hostname This is not valid!!!! +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0013-invalid-rootpw.installfile b/tests/fixtures/0013-invalid-rootpw.installfile new file mode 100644 index 0000000..aeeda68 --- /dev/null +++ b/tests/fixtures/0013-invalid-rootpw.installfile @@ -0,0 +1,5 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $It's a password +mount /dev/sda1 / diff --git a/tests/fixtures/0014-invalid-mount.installfile b/tests/fixtures/0014-invalid-mount.installfile new file mode 100644 index 0000000..cf3d44a --- /dev/null +++ b/tests/fixtures/0014-invalid-mount.installfile @@ -0,0 +1,5 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount / diff --git a/tests/fixtures/0015-keys-without-values.installfile b/tests/fixtures/0015-keys-without-values.installfile new file mode 100644 index 0000000..7cb7aff --- /dev/null +++ b/tests/fixtures/0015-keys-without-values.installfile @@ -0,0 +1,5 @@ +network +hostname +pkginstall +rootpw +mount diff --git a/tests/fixtures/0016-invalid-key.installfile b/tests/fixtures/0016-invalid-key.installfile new file mode 100644 index 0000000..9a7002e --- /dev/null +++ b/tests/fixtures/0016-invalid-key.installfile @@ -0,0 +1,6 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +chat #adelie diff --git a/tests/fixtures/0017-line-too-long.installfile b/tests/fixtures/0017-line-too-long.installfile new file mode 100644 index 0000000..f208b5f --- /dev/null +++ b/tests/fixtures/0017-line-too-long.installfile @@ -0,0 +1,5 @@ +network true +hostname test.machine +pkginstall abiword abuild-doc adelie-base adelie-keys adelie-wallpapers alegreya alsa-utils anonymous-pro apk-tools-static at at-doc audacious audacious-dbg audacious-dev audacious-plugins audacious-plugins-dbg bash-binsh bash-doc bc bind-tools binutils-doc bsdwhois bubblewrap-nosuid build-tools calligra cargo checkbashisms chelf chrony clearsans cmd:mkfs.vfat cmd:wish command-not-found console-keymaps console-setup-doc consolekit2 consolekit2-dbg cryptsetup cups dash debianutils-which dejagnu dhcpcd dosfstools dracut dracut-doc dracut-lvm e2fsprogs e2fsprogs-doc easy-kernel-power8 easy-kernel-power8-modules ebgaramond emacs-nox essays1743 eudev-dev evince fantasque-sans-mono fastjar ffmpeg ffmpeg-doc ffmpeg-libs fifth-leg fira fira-code firefox-esr flex free42 fuse-exfat gcc-doc gcompat gdb git-doc git-email gnumeric gnupg gptfdisk grub grub-ieee1275 gutenprint gwenview hdparm heirloom-devtools hermit heuristica-otf htop hunkyfonts hunspell imagemagick iproute2 iproute2-doc iputils iso-codes jpegoptim kate-dbg kbd kbd-keymaps kcachegrind kde-graphics kde-gtk-config kde-system kde-utilities kdeplasma-addons kgpg khelpcenter klickety kmix kolourpaint konsole kpat krdc krita ksysguard-lang ktorrent ktorrent-doc kwin kwrite lame libedit-dbg libertine-fonts libreoffice-calc libx11-dbg lighttpd links linux-firmware-amdgpu linux-firmware-radeon linux-headers linux-pam-doc lm_sensors lmms lsof lvm2-doc lxqt-desktop lynx lz4 mac-fdisk make-doc marble mednaffe mesa-dbg mesa-demos mesa-demos-dbg mesa-dri-swrast meson minicom mkfontscale-doc modemmanager monoid montecarlo mozjs mtr mtr-gtk musl-dbg nano ncurses-terminfo netcat netifrc netifrc-doc netsurf nmap nmap-ncat node nvi oclock okteta okular opal-utils openjdk8 openrc openrc-doc openssh openssh-doc openssl oprofile oprofile-doc optipng otf-source-code-pro otf-source-sans-pro oxygen-icons5 papirus-icons parted parted-dev partitionmanager pciutils perl-app-licensecheck perl-json phonon-vlc php7 php7-curl php7-dom php7-json php7-openssl php7-simplexml pidgin pidgin-otr pigz pinentry-gtk pkgconf plasma-desktop plasma-desktop-doc postgresql procps-doc pulseaudio pulseaudio-alsa pulseaudio-dev purple-plugin-pack py3-docutils py3-lxml py3-mako py3-packaging py3-tox qastools qemu-riscv64 qemu-system-riscv64 qemu-user qpdfview qt-creator qt5-qtbase-dbg qt5-qtbase-dev qt5-qtdeclarative-dev qt5-qtpositioning qt5-qttools qt5-qtwebchannel quassel-client quassel-dbg rdesktop rpm2targz rsync ruby ruby-dbg ruby-irb rust s6-linux-init screen sg3_utils shadow-doc socat spectacle sqlite squashfs-tools ssmtp stdman strace systemsettings tcpdump tcpdump-doc texinfo the_silver_searcher thunderbird tigervnc tmux traceroute tree trigger-rally trojita ttc-iosevka ttf-dejavu ttf-liberation ttf-noto tzdata umbrello umbrello-doc urw-base35-fonts usbutils user-manager util-linux-doc utmps utmps-libs valgrind vimdiff vlc-plugins-lua vlc-pulse vlc-qt weechat weechat-python x11 x11vnc x264 xclip xf86-input-evdev xf86-video-ati xf86-video-ati-doc xf86-video-fbdev xfsprogs xfsprogs-doc xfwm4 xmlto xmoto xorg-fonts xorg-server xorg-server-xephyr xorg-server-xnest xorriso xterm youtube-dl zsh-doc +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0018-duplicate-network.installfile b/tests/fixtures/0018-duplicate-network.installfile new file mode 100644 index 0000000..bce490c --- /dev/null +++ b/tests/fixtures/0018-duplicate-network.installfile @@ -0,0 +1,6 @@ +network true +hostname test.machine +pkginstall adelie-base +network false +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0019-duplicate-hostname.installfile b/tests/fixtures/0019-duplicate-hostname.installfile new file mode 100644 index 0000000..ae7f199 --- /dev/null +++ b/tests/fixtures/0019-duplicate-hostname.installfile @@ -0,0 +1,6 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +hostname foo.bar diff --git a/tests/fixtures/0020-duplicate-rootpw.installfile b/tests/fixtures/0020-duplicate-rootpw.installfile new file mode 100644 index 0000000..c3727d2 --- /dev/null +++ b/tests/fixtures/0020-duplicate-rootpw.installfile @@ -0,0 +1,6 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ diff --git a/tests/fixtures/0021-duplicate-root-mount.installfile b/tests/fixtures/0021-duplicate-root-mount.installfile new file mode 100644 index 0000000..0d009cd --- /dev/null +++ b/tests/fixtures/0021-duplicate-root-mount.installfile @@ -0,0 +1,6 @@ +network true +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +mount /dev/sda2 / diff --git a/tests/scripts/0001-basic.installfile b/tests/scripts/0001-basic.installfile deleted file mode 100644 index a87b8f1..0000000 --- a/tests/scripts/0001-basic.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0002-basic-commented.installfile b/tests/scripts/0002-basic-commented.installfile deleted file mode 100644 index fd9a5e8..0000000 --- a/tests/scripts/0002-basic-commented.installfile +++ /dev/null @@ -1,17 +0,0 @@ -# This file contains comments. - -# And blank lines. -network true - -hostname test.machine -pkginstall adelie-base - -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ - - - - - - - -mount /dev/sda1 / diff --git a/tests/scripts/0003-basic-whitespace.installfile b/tests/scripts/0003-basic-whitespace.installfile deleted file mode 100644 index 4754458..0000000 --- a/tests/scripts/0003-basic-whitespace.installfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file has whitespace everywhere before keys, and even on otherwise-empty lines. - network true - hostname test.machine -pkginstall adelie-base - rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ - - mount /dev/sda1 / diff --git a/tests/scripts/0004-blank.installfile b/tests/scripts/0004-blank.installfile deleted file mode 100644 index e69de29..0000000 diff --git a/tests/scripts/0005-only-comments.installfile b/tests/scripts/0005-only-comments.installfile deleted file mode 100644 index 72985bf..0000000 --- a/tests/scripts/0005-only-comments.installfile +++ /dev/null @@ -1 +0,0 @@ -# This file is invalid, because it only contains comments. diff --git a/tests/scripts/0006-no-network.installfile b/tests/scripts/0006-no-network.installfile deleted file mode 100644 index fcf0943..0000000 --- a/tests/scripts/0006-no-network.installfile +++ /dev/null @@ -1,4 +0,0 @@ -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0007-no-hostname.installfile b/tests/scripts/0007-no-hostname.installfile deleted file mode 100644 index 5e314e5..0000000 --- a/tests/scripts/0007-no-hostname.installfile +++ /dev/null @@ -1,4 +0,0 @@ -network true -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0008-no-pkginstall.installfile b/tests/scripts/0008-no-pkginstall.installfile deleted file mode 100644 index 2751414..0000000 --- a/tests/scripts/0008-no-pkginstall.installfile +++ /dev/null @@ -1,4 +0,0 @@ -network true -hostname test.machine -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0009-no-rootpw.installfile b/tests/scripts/0009-no-rootpw.installfile deleted file mode 100644 index d15d6b1..0000000 --- a/tests/scripts/0009-no-rootpw.installfile +++ /dev/null @@ -1,4 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -mount /dev/sda1 / diff --git a/tests/scripts/0010-no-mount.installfile b/tests/scripts/0010-no-mount.installfile deleted file mode 100644 index 99fc1da..0000000 --- a/tests/scripts/0010-no-mount.installfile +++ /dev/null @@ -1,4 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ diff --git a/tests/scripts/0011-invalid-network.installfile b/tests/scripts/0011-invalid-network.installfile deleted file mode 100644 index 77de188..0000000 --- a/tests/scripts/0011-invalid-network.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network ture -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0012-invalid-hostname.installfile b/tests/scripts/0012-invalid-hostname.installfile deleted file mode 100644 index 6ea1fbc..0000000 --- a/tests/scripts/0012-invalid-hostname.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network true -hostname This is not valid!!!! -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0013-invalid-rootpw.installfile b/tests/scripts/0013-invalid-rootpw.installfile deleted file mode 100644 index aeeda68..0000000 --- a/tests/scripts/0013-invalid-rootpw.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $It's a password -mount /dev/sda1 / diff --git a/tests/scripts/0014-invalid-mount.installfile b/tests/scripts/0014-invalid-mount.installfile deleted file mode 100644 index cf3d44a..0000000 --- a/tests/scripts/0014-invalid-mount.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount / diff --git a/tests/scripts/0015-keys-without-values.installfile b/tests/scripts/0015-keys-without-values.installfile deleted file mode 100644 index 7cb7aff..0000000 --- a/tests/scripts/0015-keys-without-values.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network -hostname -pkginstall -rootpw -mount diff --git a/tests/scripts/0016-invalid-key.installfile b/tests/scripts/0016-invalid-key.installfile deleted file mode 100644 index 9a7002e..0000000 --- a/tests/scripts/0016-invalid-key.installfile +++ /dev/null @@ -1,6 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / -chat #adelie diff --git a/tests/scripts/0017-line-too-long.installfile b/tests/scripts/0017-line-too-long.installfile deleted file mode 100644 index f208b5f..0000000 --- a/tests/scripts/0017-line-too-long.installfile +++ /dev/null @@ -1,5 +0,0 @@ -network true -hostname test.machine -pkginstall abiword abuild-doc adelie-base adelie-keys adelie-wallpapers alegreya alsa-utils anonymous-pro apk-tools-static at at-doc audacious audacious-dbg audacious-dev audacious-plugins audacious-plugins-dbg bash-binsh bash-doc bc bind-tools binutils-doc bsdwhois bubblewrap-nosuid build-tools calligra cargo checkbashisms chelf chrony clearsans cmd:mkfs.vfat cmd:wish command-not-found console-keymaps console-setup-doc consolekit2 consolekit2-dbg cryptsetup cups dash debianutils-which dejagnu dhcpcd dosfstools dracut dracut-doc dracut-lvm e2fsprogs e2fsprogs-doc easy-kernel-power8 easy-kernel-power8-modules ebgaramond emacs-nox essays1743 eudev-dev evince fantasque-sans-mono fastjar ffmpeg ffmpeg-doc ffmpeg-libs fifth-leg fira fira-code firefox-esr flex free42 fuse-exfat gcc-doc gcompat gdb git-doc git-email gnumeric gnupg gptfdisk grub grub-ieee1275 gutenprint gwenview hdparm heirloom-devtools hermit heuristica-otf htop hunkyfonts hunspell imagemagick iproute2 iproute2-doc iputils iso-codes jpegoptim kate-dbg kbd kbd-keymaps kcachegrind kde-graphics kde-gtk-config kde-system kde-utilities kdeplasma-addons kgpg khelpcenter klickety kmix kolourpaint konsole kpat krdc krita ksysguard-lang ktorrent ktorrent-doc kwin kwrite lame libedit-dbg libertine-fonts libreoffice-calc libx11-dbg lighttpd links linux-firmware-amdgpu linux-firmware-radeon linux-headers linux-pam-doc lm_sensors lmms lsof lvm2-doc lxqt-desktop lynx lz4 mac-fdisk make-doc marble mednaffe mesa-dbg mesa-demos mesa-demos-dbg mesa-dri-swrast meson minicom mkfontscale-doc modemmanager monoid montecarlo mozjs mtr mtr-gtk musl-dbg nano ncurses-terminfo netcat netifrc netifrc-doc netsurf nmap nmap-ncat node nvi oclock okteta okular opal-utils openjdk8 openrc openrc-doc openssh openssh-doc openssl oprofile oprofile-doc optipng otf-source-code-pro otf-source-sans-pro oxygen-icons5 papirus-icons parted parted-dev partitionmanager pciutils perl-app-licensecheck perl-json phonon-vlc php7 php7-curl php7-dom php7-json php7-openssl php7-simplexml pidgin pidgin-otr pigz pinentry-gtk pkgconf plasma-desktop plasma-desktop-doc postgresql procps-doc pulseaudio pulseaudio-alsa pulseaudio-dev purple-plugin-pack py3-docutils py3-lxml py3-mako py3-packaging py3-tox qastools qemu-riscv64 qemu-system-riscv64 qemu-user qpdfview qt-creator qt5-qtbase-dbg qt5-qtbase-dev qt5-qtdeclarative-dev qt5-qtpositioning qt5-qttools qt5-qtwebchannel quassel-client quassel-dbg rdesktop rpm2targz rsync ruby ruby-dbg ruby-irb rust s6-linux-init screen sg3_utils shadow-doc socat spectacle sqlite squashfs-tools ssmtp stdman strace systemsettings tcpdump tcpdump-doc texinfo the_silver_searcher thunderbird tigervnc tmux traceroute tree trigger-rally trojita ttc-iosevka ttf-dejavu ttf-liberation ttf-noto tzdata umbrello umbrello-doc urw-base35-fonts usbutils user-manager util-linux-doc utmps utmps-libs valgrind vimdiff vlc-plugins-lua vlc-pulse vlc-qt weechat weechat-python x11 x11vnc x264 xclip xf86-input-evdev xf86-video-ati xf86-video-ati-doc xf86-video-fbdev xfsprogs xfsprogs-doc xfwm4 xmlto xmoto xorg-fonts xorg-server xorg-server-xephyr xorg-server-xnest xorriso xterm youtube-dl zsh-doc -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0018-duplicate-network.installfile b/tests/scripts/0018-duplicate-network.installfile deleted file mode 100644 index bce490c..0000000 --- a/tests/scripts/0018-duplicate-network.installfile +++ /dev/null @@ -1,6 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -network false -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / diff --git a/tests/scripts/0019-duplicate-hostname.installfile b/tests/scripts/0019-duplicate-hostname.installfile deleted file mode 100644 index ae7f199..0000000 --- a/tests/scripts/0019-duplicate-hostname.installfile +++ /dev/null @@ -1,6 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / -hostname foo.bar diff --git a/tests/scripts/0020-duplicate-rootpw.installfile b/tests/scripts/0020-duplicate-rootpw.installfile deleted file mode 100644 index c3727d2..0000000 --- a/tests/scripts/0020-duplicate-rootpw.installfile +++ /dev/null @@ -1,6 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ diff --git a/tests/scripts/0021-duplicate-root-mount.installfile b/tests/scripts/0021-duplicate-root-mount.installfile deleted file mode 100644 index 0d009cd..0000000 --- a/tests/scripts/0021-duplicate-root-mount.installfile +++ /dev/null @@ -1,6 +0,0 @@ -network true -hostname test.machine -pkginstall adelie-base -rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ -mount /dev/sda1 / -mount /dev/sda2 / diff --git a/tests/spec/spec_helper.rb b/tests/spec/spec_helper.rb new file mode 100644 index 0000000..ab821ba --- /dev/null +++ b/tests/spec/spec_helper.rb @@ -0,0 +1,52 @@ +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. + config.example_status_persistence_file_path = "spec/examples.txt" + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +end diff --git a/tests/spec/validator.rb b/tests/spec/validator.rb new file mode 100644 index 0000000..69fe0d1 --- /dev/null +++ b/tests/spec/validator.rb @@ -0,0 +1,81 @@ +require 'aruba/rspec' + +IFILE_PATH = 'installfile' + +def run_validate(extra = '') + run_command 'hscript-validate ' + IFILE_PATH + extra +end + +def use_fixture(fixture) + copy '%/' + fixture, IFILE_PATH +end + +SUCCESS_OUTPUT = '0 error(s), 0 warning(s)' + +RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do + context "argument passing" do + it "requires an installfile to be specified" do + run_command 'hscript-validate' + expect(last_command_started).to have_output(/usage/) + end + it "doesn't output ANSI colours when redirected" do + run_command 'hscript-validate foo 2>/dev/null' + expect(last_command_started).to_not have_output(/\033/) + end + end + context "on invalid keys" do + before(:each) { use_fixture '0016-invalid-key.installfile' } + it "warns on invalid keys by default" do + run_validate + expect(last_command_started).to have_output(/warning: .*chat.* not defined/) + end + it "errors on invalid keys in strict mode" do + run_validate ' --strict' + expect(last_command_started).to have_output(/error: .*chat.* not defined/) + end + end + context "parsing" do + it "successfully reads a basic installfile" do + use_fixture '0001-basic.installfile' + run_validate + expect(last_command_started).to have_output(SUCCESS_OUTPUT) + end + it "handles comments" do + use_fixture '0002-basic-commented.installfile' + run_validate + expect(last_command_started).to have_output(SUCCESS_OUTPUT) + end + it "handles blank lines and indentation" do + use_fixture '0003-basic-whitespace.installfile' + run_validate + expect(last_command_started).to have_output(SUCCESS_OUTPUT) + end + context "required keys" do + it "fails without a 'network' key" do + use_fixture '0006-no-network.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*network.*/) + end + it "fails without a 'hostname' key" do + use_fixture '0007-no-hostname.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*hostname.*/) + end + it "fails without a 'pkginstall' key" do + use_fixture '0008-no-pkginstall.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*pkginstall.*/) + end + it "fails without a 'rootpw' key" do + use_fixture '0009-no-rootpw.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*rootpw.*/) + end + it "fails without a 'mount' key" do + use_fixture '0010-no-mount.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*mount.*/) + end + end + end +end -- cgit v1.2.3-70-g09d2