From d8563869f6a666416d35eafea0c978c07534112f Mon Sep 17 00:00:00 2001 From: ybonatakis Date: Wed, 14 Feb 2024 21:50:03 +0100 Subject: [PATCH] Update external/os-autoinst-common subrepo: subdir: "external/os-autoinst-common" merged: "5d4b825ae" upstream: origin: "git@github.com:os-autoinst/os-autoinst-common.git" branch: "master" commit: "19057a06c" git-subrepo: version: "0.4.6" origin: "???" commit: "???" Signed-off-by: ybonatakis --- .../workflows/base-commit-message-checker.yml | 2 +- .../.github/workflows/perl-author-tests.yml | 14 ++++ .../.github/workflows/perl-critic.yml | 2 +- .../.github/workflows/perl-lint-checks.yml | 2 +- .../.github/workflows/yamllint.yml | 4 +- external/os-autoinst-common/.gitrepo | 2 +- external/os-autoinst-common/Makefile | 23 ++++++ .../Critic/Policy/SpaceAfterSubroutineName.pm | 70 +++++++++++++------ external/os-autoinst-common/xt/00-tidy.t | 7 ++ .../xt/01-compile-check-all.t | 20 ++++++ 10 files changed, 120 insertions(+), 26 deletions(-) create mode 100644 external/os-autoinst-common/.github/workflows/perl-author-tests.yml create mode 100755 external/os-autoinst-common/xt/00-tidy.t create mode 100755 external/os-autoinst-common/xt/01-compile-check-all.t diff --git a/external/os-autoinst-common/.github/workflows/base-commit-message-checker.yml b/external/os-autoinst-common/.github/workflows/base-commit-message-checker.yml index 480b718aa28..f83b61ac859 100644 --- a/external/os-autoinst-common/.github/workflows/base-commit-message-checker.yml +++ b/external/os-autoinst-common/.github/workflows/base-commit-message-checker.yml @@ -15,7 +15,7 @@ jobs: - name: Check subject beginning uses: gsactions/commit-message-checker@v2 with: - pattern: '^([A-Z]|\S+:|git subrepo pull)' + pattern: '^([A-Z]|\S+:|git subrepo (clone|pull))' flags: 'g' error: 'The subject does not start with a capital or tag.' excludeDescription: 'true' diff --git a/external/os-autoinst-common/.github/workflows/perl-author-tests.yml b/external/os-autoinst-common/.github/workflows/perl-author-tests.yml new file mode 100644 index 00000000000..8fe84db8318 --- /dev/null +++ b/external/os-autoinst-common/.github/workflows/perl-author-tests.yml @@ -0,0 +1,14 @@ +--- +name: 'Perl author tests' + +on: [push, pull_request] + +jobs: + perl-author-tests: + runs-on: ubuntu-latest + name: Perl author tests + container: + image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev + steps: + - uses: actions/checkout@v4 + - run: make test-author diff --git a/external/os-autoinst-common/.github/workflows/perl-critic.yml b/external/os-autoinst-common/.github/workflows/perl-critic.yml index 92cbcfc7fc0..840be05091a 100644 --- a/external/os-autoinst-common/.github/workflows/perl-critic.yml +++ b/external/os-autoinst-common/.github/workflows/perl-critic.yml @@ -11,4 +11,4 @@ jobs: image: perldocker/perl-tester steps: - uses: actions/checkout@v4 - - run: ./tools/perlcritic --quiet . + - run: make test-critic diff --git a/external/os-autoinst-common/.github/workflows/perl-lint-checks.yml b/external/os-autoinst-common/.github/workflows/perl-lint-checks.yml index 18085267880..73d4d5e79f8 100644 --- a/external/os-autoinst-common/.github/workflows/perl-lint-checks.yml +++ b/external/os-autoinst-common/.github/workflows/perl-lint-checks.yml @@ -11,4 +11,4 @@ jobs: image: registry.opensuse.org/devel/openqa/containers/os-autoinst_dev steps: - uses: actions/checkout@v4 - - run: GITHUB_ACTIONS=1 ./tools/tidyall --check-only --all --quiet + - run: GITHUB_ACTIONS=1 make test-tidy diff --git a/external/os-autoinst-common/.github/workflows/yamllint.yml b/external/os-autoinst-common/.github/workflows/yamllint.yml index 64d6b9461f0..246cd75b3e9 100644 --- a/external/os-autoinst-common/.github/workflows/yamllint.yml +++ b/external/os-autoinst-common/.github/workflows/yamllint.yml @@ -11,5 +11,5 @@ jobs: - uses: actions/checkout@v4 - uses: docker://registry.opensuse.org/home/okurz/container/containers/tumbleweed:yamllint with: - entrypoint: yamllint - args: -c .yamllint --strict ./ --format github + entrypoint: make + args: test-yaml diff --git a/external/os-autoinst-common/.gitrepo b/external/os-autoinst-common/.gitrepo index 0b899f75ec9..0d92678556f 100644 --- a/external/os-autoinst-common/.gitrepo +++ b/external/os-autoinst-common/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:os-autoinst/os-autoinst-common.git branch = master - commit = e167bdf2bccb043d658da0cda7e63472ef6bff85 + commit = 19057a06c228f0b557242611f237507f9fd87ae3 parent = da302936978e4d59020d8463bdd2b16d4f241c17 method = merge cmdver = 0.4.6 diff --git a/external/os-autoinst-common/Makefile b/external/os-autoinst-common/Makefile index 31a2fc0b40b..37e0d262e47 100644 --- a/external/os-autoinst-common/Makefile +++ b/external/os-autoinst-common/Makefile @@ -1,4 +1,27 @@ +.PHONY: help +help: + @echo Call one of the available targets: + @sed -n 's/\(^[^.#[:space:]A-Z]*\):.*$$/\1/p' Makefile | uniq + .PHONY: update-deps update-deps: tools/update-deps --cpanfile cpanfile +.PHONY: test +test: test-tidy test-critic test-yaml test-author + +.PHONY: test-tidy +test-tidy: + tools/tidyall --all --check-only + +.PHONY: test-critic +test-critic: + tools/perlcritic --quiet . + +.PHONY: test-yaml +test-yaml: + yamllint --strict ./ + +.PHONY: test-author +test-author: + prove -l -r xt/ diff --git a/external/os-autoinst-common/lib/perlcritic/Perl/Critic/Policy/SpaceAfterSubroutineName.pm b/external/os-autoinst-common/lib/perlcritic/Perl/Critic/Policy/SpaceAfterSubroutineName.pm index 7cae1e7c5a1..c79678588f7 100644 --- a/external/os-autoinst-common/lib/perlcritic/Perl/Critic/Policy/SpaceAfterSubroutineName.pm +++ b/external/os-autoinst-common/lib/perlcritic/Perl/Critic/Policy/SpaceAfterSubroutineName.pm @@ -24,30 +24,56 @@ sub applies_to { 'PPI::Statement::Sub' } # check that use strict/warnings is not present when equivalent modules are. sub violates ($self, $elem, $doc) { - # Grep the first 7 tokens: - # Case 1: bare sub - # 0. literal "sub" - # 1. :space: # must be 1 - # 2. sub_name - # 3. :space: # must be 1 - # 4. block/structure - # Case 2: sub with prototype/signature - # 0. literal "sub" - # 1. :space: # must be 1 - # 2. sub_name - # 3. :space: # must be 1 - # 4. prototype - # 5. :space: # must be 1 - # 6. block/structure - + # Grep the first 7 tokens: each function will validate the cases. my @tokens = ($elem->tokens())[0 .. 6]; - return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[2]); - return () if $tokens[4]->isa('PPI::Token::Structure'); + return () if $elem->forward(); + return $self->check_reserved_sub($elem, @tokens) if _is_reserved_sub($elem); + return $self->check_classic_sub($elem, @tokens) unless defined($elem->prototype); + return $self->check_complete_sub($elem, @tokens); +} - return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem) unless _is_surrounded_by_one_space($tokens[4]); +sub report_violation ($self, $elem) { + return $self->violation($DESC, sprintf($EXPL, $elem->name), $elem); +} - return (); +sub check_reserved_sub ($self, $elem, @tokens) { + # "Reserved Sub" token desired layout + # 0. Word - END/BEGIN/etc. + # 1. Whitespace + # 2. Structure - the actual code block. + return () if _is_only_one_space($tokens[1]) && _is_block($tokens[2]); + return $self->report_violation($elem); +} + +sub check_classic_sub ($self, $elem, @tokens) { + # "Classic Sub" token desired layout + # 0. Word "sub" + # 1. Whitespace - must be 1 + # 2. Word - the sub name + # 3. Whitespace - must be 1 + # 4. Structure - the actual code block + + return () if _is_surrounded_by_one_space($tokens[2]); + return $self->report_violation($elem); +} + +sub check_complete_sub ($self, $elem, @tokens) { + # "Complete Sub" token desired layout + # 0. Word "sub" + # 1. Whitespace - must be 1 + # 2. Word - the sub name + # 3. Whitespace - must be 1 + # 4. Prototype - sub's prototype/signature + # 5. Whitespace - must be 1 + # 6. Structure - the actual code block + + return () if _is_surrounded_by_one_space($tokens[2]) && _is_surrounded_by_one_space($tokens[4]); + return $self->report_violation($elem); +} + +sub _is_block ($token) { + return $token->isa('PPI::Token::Structure'); } sub _is_only_one_space ($token) { @@ -58,4 +84,8 @@ sub _is_surrounded_by_one_space ($token) { return _is_only_one_space($token->previous_sibling) && _is_only_one_space($token->next_sibling); } +sub _is_reserved_sub ($elem) { + return $elem->isa('PPI::Statement::Scheduled'); +} + 1; diff --git a/external/os-autoinst-common/xt/00-tidy.t b/external/os-autoinst-common/xt/00-tidy.t new file mode 100755 index 00000000000..c7daa9e1b9c --- /dev/null +++ b/external/os-autoinst-common/xt/00-tidy.t @@ -0,0 +1,7 @@ +#!/usr/bin/perl +# Copyright SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +use Test::Most; +use Test::Code::TidyAll; +tidyall_ok(); diff --git a/external/os-autoinst-common/xt/01-compile-check-all.t b/external/os-autoinst-common/xt/01-compile-check-all.t new file mode 100755 index 00000000000..04643f04ed6 --- /dev/null +++ b/external/os-autoinst-common/xt/01-compile-check-all.t @@ -0,0 +1,20 @@ +# Copyright SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +use Test::Most; +# We need :no_end_test here because otherwise it would output a no warnings +# test for each of the modules, but with the same test number +use Test::Warnings qw(:no_end_test :report_warnings); +use FindBin; +use lib "$FindBin::Bin/lib"; +use OpenQA::Test::TimeLimit '400'; + +use Test::Strict; + +push @Test::Strict::MODULES_ENABLING_STRICT, 'Test::Most'; +push @Test::Strict::MODULES_ENABLING_WARNINGS, 'Test::Most'; + +$Test::Strict::TEST_SYNTAX = 1; +$Test::Strict::TEST_STRICT = 1; +$Test::Strict::TEST_WARNINGS = 1; +all_perl_files_ok(qw(lib tools xt));