Thread (50 messages) 50 messages, 7 authors, 2022-11-22

Re: [PATCH 01/18] t: add skeleton chainlint.pl

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2022-09-01 12:32:48

On Thu, Sep 01 2022, Eric Sunshine via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
From: Eric Sunshine <redacted>
[...]
diff --git a/t/chainlint.pl b/t/chainlint.pl
I really like this overall direction...
+use warnings;
+use strict;
I think that in general we're way overdue for at least a :

	use v5.10.1;

Or even something more aggresive, I think we can definitely depend on a
newer version for this bit of dev tooling.

That makes a lot of things in this series more pleasing to look
at. E.g. you could use named $+{} variables for regexes.
+package ScriptParser;
I really wish this could be changed to just put this in
t/chainlint/ScriptParser.pm early on, we could set @INC appropriately
and "use" these, which...
+my $getnow = sub { return time(); };
+my $interval = sub { return time() - shift; };
Would eliminate any scoping concerns about this sort of thing.
+if (eval {require Time::HiRes; Time::HiRes->import(); 1;}) {
+	$getnow = sub { return [Time::HiRes::gettimeofday()]; };
+	$interval = sub { return Time::HiRes::tv_interval(shift); };
+}
Is this "require" even needed, Time::HiRes is there since 5.7.* says
"corelist -l Time::HIRes".
[...]
+sub check_script {
+	my ($id, $next_script, $emit) = @_;
+	my ($nscripts, $ntests, $nerrs) = (0, 0, 0);
+	while (my $path = $next_script->()) {
+		$nscripts++;
+		my $fh;
+		unless (open($fh, "<", $path)) {
+			$emit->("?!ERR?! $path: $!\n");
If we can depend on v5.10.1 this can surely become:

	use autodie qw(open close);

No?
+			$nerrs += () = $s =~ /\?![^?]+\?!/g;
y'know if we add some whitespace there we can conform to
https://metacpan.org/dist/perlsecret/view/lib/perlsecret.pod >:) (not
serious...)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help