mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2025-05-03 08:01: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/
|
.tox/
|
||||||
.coverage
|
.coverage
|
||||||
coverage.xml
|
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:
|
- job:
|
||||||
name: os-autoinst-perl
|
name: os-autoinst-perl
|
||||||
run: ci/perl.yaml
|
run: ci/perl.yaml
|
||||||
nodeset: fedora-latest-container
|
nodeset: fedora-36-vm
|
||||||
|
|
||||||
- project:
|
- project:
|
||||||
check:
|
check:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: Install required packages
|
- name: Install required packages
|
||||||
package:
|
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
|
state: present
|
||||||
become: yes
|
become: yes
|
||||||
- name: Run perl tests
|
- name: Run perl tests
|
||||||
|
@ -28,7 +28,7 @@ sub select_disks {
|
|||||||
);
|
);
|
||||||
my %iscsi = %{$args{iscsi}};
|
my %iscsi = %{$args{iscsi}};
|
||||||
# Anaconda hub
|
# 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
|
# Damn animation delay can cause bad clicks here too - wait for it
|
||||||
sleep 1;
|
sleep 1;
|
||||||
assert_and_click "anaconda_main_hub_install_destination";
|
assert_and_click "anaconda_main_hub_install_destination";
|
||||||
|
@ -21,7 +21,8 @@ sub post_fail_hook {
|
|||||||
if (check_screen "anaconda_error_report", 10) {
|
if (check_screen "anaconda_error_report", 10) {
|
||||||
assert_and_click "anaconda_error_report";
|
assert_and_click "anaconda_error_report";
|
||||||
$has_traceback = 1;
|
$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";
|
type_string "1\n";
|
||||||
$has_traceback = 1;
|
$has_traceback = 1;
|
||||||
}
|
}
|
||||||
@ -128,7 +129,8 @@ sub root_console {
|
|||||||
# 0 means use console_login's default, non-zero values
|
# 0 means use console_login's default, non-zero values
|
||||||
# passed to console_login
|
# passed to console_login
|
||||||
timeout => 0,
|
timeout => 0,
|
||||||
@_);
|
@_
|
||||||
|
);
|
||||||
if (get_var("SERIAL_CONSOLE")) {
|
if (get_var("SERIAL_CONSOLE")) {
|
||||||
# select first virtio terminal, we rely on anaconda having run
|
# select first virtio terminal, we rely on anaconda having run
|
||||||
# a root shell on it for us
|
# a root shell on it for us
|
||||||
|
@ -18,7 +18,8 @@ sub root_console {
|
|||||||
my %args = (
|
my %args = (
|
||||||
tty => 1, # what TTY to login to
|
tty => 1, # what TTY to login to
|
||||||
timeout => 0, # passed through to console_login
|
timeout => 0, # passed through to console_login
|
||||||
@_);
|
@_
|
||||||
|
);
|
||||||
if (get_var("SERIAL_CONSOLE")) {
|
if (get_var("SERIAL_CONSOLE")) {
|
||||||
# select the first virtio terminal, for now we assume we can
|
# select the first virtio terminal, for now we assume we can
|
||||||
# always use that (we may have to make this smarter in future)
|
# 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 $version = get_var("VERSION");
|
||||||
my $rawrel = get_var("RAWREL", "Rawhide");
|
my $rawrel = get_var("RAWREL", "Rawhide");
|
||||||
return $rawrel if ($version eq "Rawhide");
|
return $rawrel if ($version eq "Rawhide");
|
||||||
return $version
|
return $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wait for login screen to appear. Handle the annoying GPU buffer
|
# Wait for login screen to appear. Handle the annoying GPU buffer
|
||||||
@ -150,7 +150,8 @@ sub console_login {
|
|||||||
password => get_var("ROOT_PASSWORD", "weakpassword"),
|
password => get_var("ROOT_PASSWORD", "weakpassword"),
|
||||||
# default is 10 seconds, set below, 0 means 'default'
|
# default is 10 seconds, set below, 0 means 'default'
|
||||||
timeout => 0,
|
timeout => 0,
|
||||||
@_);
|
@_
|
||||||
|
);
|
||||||
$args{timeout} ||= 10;
|
$args{timeout} ||= 10;
|
||||||
|
|
||||||
# Since we do not test many serial console tests, and we probably
|
# 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
|
# in SLOF usb-xhci driver failed sometimes in powerpc
|
||||||
type_safely " $args{params}";
|
type_safely " $args{params}";
|
||||||
}
|
}
|
||||||
save_screenshot; # for debug purpose
|
# for debug purpose
|
||||||
|
save_screenshot;
|
||||||
# ctrl-X boots from grub editor mode
|
# ctrl-X boots from grub editor mode
|
||||||
send_key "ctrl-x";
|
send_key "ctrl-x";
|
||||||
# return boots all other cases
|
# 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
|
# Unregister desktop needles of other desktops when DESKTOP is specified
|
||||||
if (get_var('DESKTOP')) {
|
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_
|
# 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
|
# didn't match anything: if the Rawhide warning didn't
|
||||||
# show by now it never will, so we'll just wait for the
|
# show by now it never will, so we'll just wait for the
|
||||||
# hub to show up.
|
# 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";
|
send_key "ctrl-alt-f6";
|
||||||
|
|
||||||
# Anaconda hub
|
# Anaconda hub
|
||||||
assert_screen "anaconda_main_hub", 30; #
|
assert_screen "anaconda_main_hub", 30;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use testapi;
|
|||||||
sub run {
|
sub run {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
# Anaconda hub
|
# 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,
|
# Select package set. Minimal is the default, if 'default' is specified, skip selection,
|
||||||
# but verify correct default in some cases
|
# but verify correct default in some cases
|
||||||
@ -53,7 +53,7 @@ sub run {
|
|||||||
assert_and_click "anaconda_spoke_done";
|
assert_and_click "anaconda_spoke_done";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_part_accept_changes";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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.
|
# Here the self identification test code is placed.
|
||||||
my $branched = get_var('VERSION');
|
my $branched = get_var('VERSION');
|
||||||
if ($identification eq 'true' or $branched ne "Rawhide") {
|
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
|
# we don't check version or pre-release because here those
|
||||||
# texts appear on the banner which makes the needling
|
# texts appear on the banner which makes the needling
|
||||||
# complex and fragile (banner is different between variants,
|
# complex and fragile (banner is different between variants,
|
||||||
@ -32,7 +33,7 @@ sub run {
|
|||||||
assert_and_click "anaconda_spoke_done";
|
assert_and_click "anaconda_spoke_done";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_install_destination_save_passphrase";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_spoke_done";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_spoke_done";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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";
|
assert_and_click "anaconda_install_destination_reclaim_space_btn";
|
||||||
|
|
||||||
# Anaconda hub
|
# 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
|
# if testing the current release, rebase to devel
|
||||||
unless (script_run "rpm-ostree status -b | grep stable") {
|
unless (script_run "rpm-ostree status -b | grep stable") {
|
||||||
$rebase = "devel"
|
$rebase = "devel";
|
||||||
}
|
}
|
||||||
# rebase to the appropriate release, arch
|
# rebase to the appropriate release, arch
|
||||||
validate_script_output "rpm-ostree rebase fedora/${rebase}/${arch}/iot", sub { m/systemctl reboot/ }, 300;
|
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
|
# Now, we have all the data ready and we can start testing, first let us get
|
||||||
# correct variables to compare the system data with.
|
# correct variables to compare the system data with.
|
||||||
# First, we know the basic stuff
|
# 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,
|
# extract expected version components from ISO name for canned variants,
|
||||||
# which have their os-release rewritten by rpm-ostree, see:
|
# which have their os-release rewritten by rpm-ostree, see:
|
||||||
# https://github.com/projectatomic/rpm-ostree/blob/master/docs/manual/treefile.md
|
# https://github.com/projectatomic/rpm-ostree/blob/master/docs/manual/treefile.md
|
||||||
@ -63,7 +64,8 @@ sub run {
|
|||||||
my $relnum = get_release_number;
|
my $relnum = get_release_number;
|
||||||
my $fullname = $relnum > 34 ? $name . " Linux" : $name;
|
my $fullname = $relnum > 34 ? $name . " Linux" : $name;
|
||||||
my $rawrel = get_var("RAWREL", '');
|
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
|
# IoT has a branch that acts more or less like Rawhide, but has
|
||||||
# its version as the Rawhide release number, not 'Rawhide'. This
|
# its version as the Rawhide release number, not 'Rawhide'. This
|
||||||
# handles that
|
# 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