Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add test for po/common/common.pot string count #10954

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/taxonomies/build_tags_taxonomy.pl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@
print STDERR "tagtype: $tagtype\n";

if ($tagtype eq '*') {
print "::group::Building all taxonomies\n";
my $errors_ref = ProductOpener::Tags::build_all_taxonomies($publish);
foreach my $taxonomy (keys %{$errors_ref}) {
if (@{$errors_ref->{$taxonomy}}) {
print STDERR (scalar @{$errors_ref->{$taxonomy}}) . " errors while building $taxonomy taxonomy\n";
print "::error::" . (scalar @{$errors_ref->{$taxonomy}}) . " errors while building $taxonomy taxonomy\n";
}
}
}
else {
print "::endgroup::\n";
} else {
print "::group::Building $tagtype taxonomy\n";
my @errors = ProductOpener::Tags::build_tags_taxonomy($tagtype, $publish);
if (@errors) {
print STDERR (scalar @errors) . " errors while building $tagtype taxonomy\n";
print "::error::" . (scalar @errors) . " errors while building $tagtype taxonomy\n";
}
print "::endgroup::\n";
}

print STDERR "done building tags taxonomy\n";
Expand Down
33 changes: 33 additions & 0 deletions t/po_common.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;

# Function to count the number of strings in a .po or .pot file
sub count_strings {
my ($file) = @_;
open my $fh, '<', $file or die "Could not open '$file' $!";
my $count = 0;
while (my $line = <$fh>) {
$count++ if $line =~ /^msgid\s+"/;
}
close $fh;
return $count;
}

# File paths
my $common_pot = 'po/common/common.pot';
my $en_po = 'po/common/en.po';
my $fr_po = 'po/common/fr.po';

# Count the number of strings in each file
my $common_pot_count = count_strings($common_pot);
my $en_po_count = count_strings($en_po);
my $fr_po_count = count_strings($fr_po);

# Test if the number of strings are equal
is($common_pot_count, $en_po_count, 'common.pot has the same number of strings as en.po');
is($common_pot_count, $fr_po_count, 'common.pot has the same number of strings as fr.po');

done_testing();
Loading