mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-05-02 15:41:33 +00:00
Add a perltidy check and apply it to the entire codebase
Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
ad5eb54715
commit
1a65993d36
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
.tox/
|
||||
.coverage
|
||||
coverage.xml
|
||||
.tidyall.d/
|
||||
|
16
.perltidyrc
Normal file
16
.perltidyrc
Normal file
@ -0,0 +1,16 @@
|
||||
# Workaround needed for handling non-ASCII in files.
|
||||
# # See <https://github.com/houseabsolute/perl-code-tidyall/issues/84>.
|
||||
--character-encoding=none
|
||||
--no-valign
|
||||
# 120 characters would be desired but it is not feasible right now
|
||||
#-l=120 # 120 characters per line
|
||||
-l=160
|
||||
-fbl # don't change blank lines
|
||||
-fnl # don't remove new lines
|
||||
-nsfs # no spaces before semicolons
|
||||
-baao # space after operators
|
||||
-bbao # space before operators
|
||||
-pt=2 # no spaces around ()
|
||||
-bt=2 # no spaces around []
|
||||
-sbt=2 # no spaces around {}
|
||||
-sct # stack closing tokens )}
|
3
.tidyallrc
Normal file
3
.tidyallrc
Normal file
@ -0,0 +1,3 @@
|
||||
[PerlTidy]
|
||||
select = **/*.pm
|
||||
argv = --profile=$ROOT/.perltidyrc
|
@ -6,7 +6,7 @@
|
||||
- job:
|
||||
name: os-autoinst-perl
|
||||
run: ci/perl.yaml
|
||||
nodeset: fedora-latest-container
|
||||
nodeset: fedora-36-vm
|
||||
|
||||
- project:
|
||||
check:
|
||||
|
@ -2,7 +2,7 @@
|
||||
tasks:
|
||||
- name: Install required packages
|
||||
package:
|
||||
name: ['os-autoinst', 'perl-Test-Strict', 'perl-Test-Harness', 'perl-JSON', 'perl-REST-Client']
|
||||
name: ['os-autoinst', 'perl-Test-Strict', 'perl-Test-Harness', 'perl-JSON', 'perl-REST-Client', 'perl-Code-TidyAll']
|
||||
state: present
|
||||
become: yes
|
||||
- name: Run perl tests
|
||||
|
@ -28,7 +28,7 @@ sub select_disks {
|
||||
);
|
||||
my %iscsi = %{$args{iscsi}};
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
# Damn animation delay can cause bad clicks here too - wait for it
|
||||
sleep 1;
|
||||
assert_and_click "anaconda_main_hub_install_destination";
|
||||
|
@ -21,7 +21,8 @@ sub post_fail_hook {
|
||||
if (check_screen "anaconda_error_report", 10) {
|
||||
assert_and_click "anaconda_error_report";
|
||||
$has_traceback = 1;
|
||||
} elsif (check_screen "anaconda_text_error", 10) { # also for text install
|
||||
} elsif (check_screen "anaconda_text_error", 10) {
|
||||
# also for text install
|
||||
type_string "1\n";
|
||||
$has_traceback = 1;
|
||||
}
|
||||
@ -128,7 +129,8 @@ sub root_console {
|
||||
# 0 means use console_login's default, non-zero values
|
||||
# passed to console_login
|
||||
timeout => 0,
|
||||
@_);
|
||||
@_
|
||||
);
|
||||
if (get_var("SERIAL_CONSOLE")) {
|
||||
# select first virtio terminal, we rely on anaconda having run
|
||||
# a root shell on it for us
|
||||
|
@ -18,7 +18,8 @@ sub root_console {
|
||||
my %args = (
|
||||
tty => 1, # what TTY to login to
|
||||
timeout => 0, # passed through to console_login
|
||||
@_);
|
||||
@_
|
||||
);
|
||||
if (get_var("SERIAL_CONSOLE")) {
|
||||
# select the first virtio terminal, for now we assume we can
|
||||
# always use that (we may have to make this smarter in future)
|
||||
|
@ -59,7 +59,7 @@ sub get_release_number {
|
||||
my $version = get_var("VERSION");
|
||||
my $rawrel = get_var("RAWREL", "Rawhide");
|
||||
return $rawrel if ($version eq "Rawhide");
|
||||
return $version
|
||||
return $version;
|
||||
}
|
||||
|
||||
# Wait for login screen to appear. Handle the annoying GPU buffer
|
||||
@ -150,7 +150,8 @@ sub console_login {
|
||||
password => get_var("ROOT_PASSWORD", "weakpassword"),
|
||||
# default is 10 seconds, set below, 0 means 'default'
|
||||
timeout => 0,
|
||||
@_);
|
||||
@_
|
||||
);
|
||||
$args{timeout} ||= 10;
|
||||
|
||||
# Since we do not test many serial console tests, and we probably
|
||||
@ -382,7 +383,8 @@ sub do_bootloader {
|
||||
# in SLOF usb-xhci driver failed sometimes in powerpc
|
||||
type_safely " $args{params}";
|
||||
}
|
||||
save_screenshot; # for debug purpose
|
||||
# for debug purpose
|
||||
save_screenshot;
|
||||
# ctrl-X boots from grub editor mode
|
||||
send_key "ctrl-x";
|
||||
# return boots all other cases
|
||||
|
2
main.pm
2
main.pm
@ -85,7 +85,7 @@ sub cleanup_needles() {
|
||||
|
||||
# Unregister desktop needles of other desktops when DESKTOP is specified
|
||||
if (get_var('DESKTOP')) {
|
||||
unregister_prefix_tags('DESKTOP', [ get_var('DESKTOP') ])
|
||||
unregister_prefix_tags('DESKTOP', [get_var('DESKTOP')]);
|
||||
}
|
||||
|
||||
# Unregister non-language-appropriate needles. See unregister_except_
|
||||
|
7
t/00-tidy.t
Executable file
7
t/00-tidy.t
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright 2021 SUSE LLC
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
use Test::Strict;
|
||||
use Test::Code::TidyAll;
|
||||
tidyall_ok();
|
@ -188,7 +188,7 @@ sub run {
|
||||
# didn't match anything: if the Rawhide warning didn't
|
||||
# show by now it never will, so we'll just wait for the
|
||||
# hub to show up.
|
||||
assert_screen "anaconda_main_hub", 900; #
|
||||
assert_screen "anaconda_main_hub", 900;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ sub run {
|
||||
send_key "ctrl-alt-f6";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 30; #
|
||||
assert_screen "anaconda_main_hub", 30;
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ use testapi;
|
||||
sub run {
|
||||
my $self = shift;
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
# Select package set. Minimal is the default, if 'default' is specified, skip selection,
|
||||
# but verify correct default in some cases
|
||||
@ -53,7 +53,7 @@ sub run {
|
||||
assert_and_click "anaconda_spoke_done";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 50; #
|
||||
assert_screen "anaconda_main_hub", 50;
|
||||
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ sub run {
|
||||
assert_and_click "anaconda_part_accept_changes";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ sub run {
|
||||
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ sub run {
|
||||
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,8 @@ sub run {
|
||||
# Here the self identification test code is placed.
|
||||
my $branched = get_var('VERSION');
|
||||
if ($identification eq 'true' or $branched ne "Rawhide") {
|
||||
check_top_bar(); # See utils.pm
|
||||
# See utils.pm
|
||||
check_top_bar();
|
||||
# we don't check version or pre-release because here those
|
||||
# texts appear on the banner which makes the needling
|
||||
# complex and fragile (banner is different between variants,
|
||||
@ -32,7 +33,7 @@ sub run {
|
||||
assert_and_click "anaconda_spoke_done";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ sub run {
|
||||
assert_and_click "anaconda_install_destination_save_passphrase";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ sub run {
|
||||
assert_and_click "anaconda_spoke_done";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ sub run {
|
||||
assert_and_click "anaconda_spoke_done";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ sub run {
|
||||
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||
|
||||
# Anaconda hub
|
||||
assert_screen "anaconda_main_hub", 300; #
|
||||
assert_screen "anaconda_main_hub", 300;
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ sub run {
|
||||
|
||||
# if testing the current release, rebase to devel
|
||||
unless (script_run "rpm-ostree status -b | grep stable") {
|
||||
$rebase = "devel"
|
||||
$rebase = "devel";
|
||||
}
|
||||
# rebase to the appropriate release, arch
|
||||
validate_script_output "rpm-ostree rebase fedora/${rebase}/${arch}/iot", sub { m/systemctl reboot/ }, 300;
|
||||
|
@ -33,7 +33,8 @@ sub run {
|
||||
# Now, we have all the data ready and we can start testing, first let us get
|
||||
# correct variables to compare the system data with.
|
||||
# First, we know the basic stuff
|
||||
my $id = get_var("DISTRI"); # Should be "fedora"
|
||||
# Should be "fedora"
|
||||
my $id = get_var("DISTRI");
|
||||
# extract expected version components from ISO name for canned variants,
|
||||
# which have their os-release rewritten by rpm-ostree, see:
|
||||
# https://github.com/projectatomic/rpm-ostree/blob/master/docs/manual/treefile.md
|
||||
@ -63,7 +64,8 @@ sub run {
|
||||
my $relnum = get_release_number;
|
||||
my $fullname = $relnum > 34 ? $name . " Linux" : $name;
|
||||
my $rawrel = get_var("RAWREL", '');
|
||||
my $version_id = get_var("VERSION"); # Should be the version number or Rawhide.
|
||||
# Should be the version number or Rawhide.
|
||||
my $version_id = get_var("VERSION");
|
||||
# IoT has a branch that acts more or less like Rawhide, but has
|
||||
# its version as the Rawhide release number, not 'Rawhide'. This
|
||||
# handles that
|
||||
|
61
tidy
Executable file
61
tidy
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# perltidy rules can be found in ../.perltidyrc
|
||||
#
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage:
|
||||
tidy [-c|--check] [-f|--force] [-o|--only-changed] [-l|--list] [path/to/file]
|
||||
|
||||
Options:
|
||||
-h, -?, --help display this help
|
||||
-c, --check Only check for style check differences
|
||||
-f, --force Force check even if tidy version mismatches
|
||||
-o --only-changed Only tidy files with uncommitted changes in git. This can
|
||||
speed up execution a lot.
|
||||
-l --list List files tidy would touch
|
||||
path/to/file When passing a file as argument, tidy will run perltidy
|
||||
wether it is added to the git tree or not
|
||||
|
||||
perltidy rules can be found in .perltidyrc
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
set -eo pipefail
|
||||
dir="$(dirname "$0")"
|
||||
|
||||
args=""
|
||||
selection='--all'
|
||||
[[ -e "$dir/perlfiles" ]] && selection=$("$dir"/perlfiles)
|
||||
opts=$(getopt -o hcfol --long help,check,force,only-changed,list -n "$0" -- "$@") || usage
|
||||
eval set -- "$opts"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h | --help ) usage; shift ;;
|
||||
-c | --check ) args+=' --check-only'; shift ;;
|
||||
-f | --force ) force=true; shift ;;
|
||||
-o | --only-changed ) selection='--git'; shift ;;
|
||||
-l | --list ) args+='--list'; shift ;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND - 1))
|
||||
filename=${*:-"$selection"}
|
||||
|
||||
if ! command -v perltidy > /dev/null 2>&1; then
|
||||
echo "No perltidy found, install it first!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# go to caller directory
|
||||
cd "$dir"
|
||||
|
||||
# just to make sure we are at the right location
|
||||
test -e tidy || exit 1
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
tidyall $args $filename
|
Loading…
Reference in New Issue
Block a user