From 1eb4e3dca525a2cef44dfb6b3942f630ad201507 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 13 Feb 2020 13:31:05 -0800 Subject: [PATCH] Add perl syntax check test, add it to CI Inspired by openQA's 01-compile-check-all.t, this adds a perl test which checks the syntax of main.pm and all lib and test files, and hooks it up to CI. Requires os-autoinst and perl-Test-Strict. Signed-off-by: Adam Williamson --- .zuul.yaml | 6 ++++++ ci/perl.yaml | 11 +++++++++++ lib/anacondatest.pm | 3 +++ lib/fedoradistribution.pm | 3 +++ lib/installedtest.pm | 3 +++ t/01-syntax.t | 7 +++++++ 6 files changed, 33 insertions(+) create mode 100644 ci/perl.yaml create mode 100644 t/01-syntax.t diff --git a/.zuul.yaml b/.zuul.yaml index 5b518d10..b785c86e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,7 +3,13 @@ run: ci/tox.yaml nodeset: fedora-31-vm +- job: + name: os-autoinst-perl + run: ci/perl.yaml + nodeset: fedora-31-vm + - project: check: jobs: - os-autoinst-tox + - os-autoinst-perl diff --git a/ci/perl.yaml b/ci/perl.yaml new file mode 100644 index 00000000..ba3b376b --- /dev/null +++ b/ci/perl.yaml @@ -0,0 +1,11 @@ +- hosts: all + tasks: + - name: Install required packages + package: + name: ['os-autoinst', 'perl-Test-Strict', 'perl-Test-Harness'] + state: present + become: yes + - name: Run perl tests + command: prove t/ + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/lib/anacondatest.pm b/lib/anacondatest.pm index 366ce7e1..2ac190db 100644 --- a/lib/anacondatest.pm +++ b/lib/anacondatest.pm @@ -1,4 +1,7 @@ package anacondatest; + +use strict; + use base 'basetest'; # base class for all Anaconda (installation) tests diff --git a/lib/fedoradistribution.pm b/lib/fedoradistribution.pm index da9f4c68..9c59ca0f 100644 --- a/lib/fedoradistribution.pm +++ b/lib/fedoradistribution.pm @@ -1,4 +1,7 @@ package fedoradistribution; + +use strict; + use base 'distribution'; use Cwd; diff --git a/lib/installedtest.pm b/lib/installedtest.pm index 09277208..ba1182c9 100644 --- a/lib/installedtest.pm +++ b/lib/installedtest.pm @@ -1,4 +1,7 @@ package installedtest; + +use strict; + use base 'basetest'; # base class for tests that run on installed system diff --git a/t/01-syntax.t b/t/01-syntax.t new file mode 100644 index 00000000..20aa7d50 --- /dev/null +++ b/t/01-syntax.t @@ -0,0 +1,7 @@ +#!/bin/perl + +use FindBin; +unshift @INC, "/usr/libexec/os-autoinst", "$FindBin::Bin/../lib", "$FindBin::Bin/lib"; + +use Test::Strict; +all_perl_files_ok(qw 'main.pm lib tests');