Skip to content

Commit

Permalink
Update external/os-autoinst-common
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "external/os-autoinst-common"
  merged:   "5d4b825ae"
upstream:
  origin:   "[email protected]:os-autoinst/os-autoinst-common.git"
  branch:   "master"
  commit:   "19057a06c"
git-subrepo:
  version:  "0.4.6"
  origin:   "???"
  commit:   "???"
Signed-off-by: ybonatakis <[email protected]>
  • Loading branch information
b10n1k committed Feb 14, 2024
1 parent 28145b7 commit d856386
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
image: perldocker/perl-tester
steps:
- uses: actions/checkout@v4
- run: ./tools/perlcritic --quiet .
- run: make test-critic
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions external/os-autoinst-common/.github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:os-autoinst/os-autoinst-common.git
branch = master
commit = e167bdf2bccb043d658da0cda7e63472ef6bff85
commit = 19057a06c228f0b557242611f237507f9fd87ae3
parent = da302936978e4d59020d8463bdd2b16d4f241c17
method = merge
cmdver = 0.4.6
23 changes: 23 additions & 0 deletions external/os-autoinst-common/Makefile
Original file line number Diff line number Diff line change
@@ -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/
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
7 changes: 7 additions & 0 deletions external/os-autoinst-common/xt/00-tidy.t
Original file line number Diff line number Diff line change
@@ -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();
20 changes: 20 additions & 0 deletions external/os-autoinst-common/xt/01-compile-check-all.t
Original file line number Diff line number Diff line change
@@ -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));

0 comments on commit d856386

Please sign in to comment.