simplify_static_dir/t/freed-bytes-commas.t

32 lines
691 B
Perl
Raw Normal View History

#!perl
use strict;
use warnings;
2023-07-20 18:44:37 +00:00
use Test::More 'no_plan';
use Carp qw/ croak /;
use TestFunctions;
2023-07-20 17:41:07 +00:00
my $test_dir = mktempdir();
put_file(
"$test_dir/1",
"$test_dir/2",
);
2023-07-20 17:41:07 +00:00
my (undef, $stdout, $stderr) = run_script_capture('-f', $test_dir);
ok "freed 1,048,576 bytes (1 MB)\n" eq $stderr, 'prints freed bytes with commas';
sub put_file {
2023-07-20 17:37:07 +00:00
my @files = @_;
my $bytes = 1_048_576; # 1 MB
2023-07-20 17:37:07 +00:00
foreach my $file (@files) {
open my $fh, '>', $file
or croak("Failed to open file $file for writing: $!");
for (my $bytes_written = 0; $bytes_written < $bytes; ++$bytes_written) {
print $fh 'A';
}
2023-07-20 20:11:25 +00:00
close $fh;
}
2023-07-20 17:37:27 +00:00
return;
}