mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-16 01:53:20 +00:00
Cmake tests: Add test for possible wrong used constants in our ui-files
This commit is contained in:
parent
d75ab6d6f0
commit
695b2f485c
@ -127,3 +127,9 @@ if (LYX_ENABLE_EXPORT_TESTS)
|
||||
message(STATUS "Number of ignored export tests now ${lyx_ignored_count}")
|
||||
set(LYX_ignored_count ${lyx_ignored_count} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
set(CHECK_QT_CONSTANTS_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/checkQtConstants.pl")
|
||||
add_test(NAME "check_Qt_ui_Constants"
|
||||
WORKING_DIRECTORY ${TOP_SRC_DIR}
|
||||
COMMAND ${PERL_EXECUTABLE} ${CHECK_QT_CONSTANTS_SCRIPT}
|
||||
)
|
||||
|
64
development/autotests/checkQtConstants.pl
Normal file
64
development/autotests/checkQtConstants.pl
Normal file
@ -0,0 +1,64 @@
|
||||
#! /usr/bin/env perl
|
||||
# -*- mode: perl; -*-
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
BEGIN {
|
||||
use File::Spec;
|
||||
my $p = File::Spec->rel2abs(__FILE__);
|
||||
$p =~ s/[\/\\]?[^\/\\]+$//;
|
||||
unshift(@INC, "$p");
|
||||
}
|
||||
|
||||
my $no_founds = 0;
|
||||
sub checkConstants($);
|
||||
sub collectUiFiles($$);
|
||||
|
||||
my @UIFiles = ();
|
||||
|
||||
collectUiFiles('.', \@UIFiles);
|
||||
|
||||
for my $ui (@UIFiles) {
|
||||
checkConstants($ui);
|
||||
}
|
||||
exit($no_founds);
|
||||
|
||||
###########################################
|
||||
|
||||
sub checkConstants($) {
|
||||
my ($ui) = @_;
|
||||
#print "Checking $ui\n";
|
||||
if (open(my $FI, '<', $ui)) {
|
||||
my $lineno = 0;
|
||||
while (my $l = <$FI>) {
|
||||
$lineno += 1;
|
||||
if ($l =~ /\bQ[a-zA-Z]+\:\:[a-zA-Z]+\:\:/) {
|
||||
print "$ui:$lineno $l";
|
||||
$no_founds += 1;
|
||||
}
|
||||
}
|
||||
close($FI);
|
||||
}
|
||||
}
|
||||
|
||||
# Recursive collect UI files
|
||||
sub collectUiFiles($$) {
|
||||
my ($dir, $rFiles) = @_;
|
||||
my @subdirs = ();
|
||||
if (opendir(my $DI, $dir)) {
|
||||
while (my $f = readdir($DI)) {
|
||||
if (-d "$dir/$f") {
|
||||
next if ($f =~ /^\.(\.)?$/);
|
||||
push(@subdirs, "$dir/$f");
|
||||
}
|
||||
elsif ($f =~ /\.ui$/) {
|
||||
push(@{$rFiles}, "$dir/$f");
|
||||
}
|
||||
}
|
||||
closedir($DI);
|
||||
}
|
||||
for my $d (@subdirs) {
|
||||
collectUiFiles($d, $rFiles);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user