IDE: compiler tests: added check for ambiguous units in project/package unit search path

git-svn-id: trunk@11690 -
This commit is contained in:
mattias 2007-07-31 16:25:24 +00:00
parent a21c0665be
commit 13b70fb444
2 changed files with 68 additions and 35 deletions

View File

@ -36,8 +36,13 @@ type
TCompilerOptionsTest = ( TCompilerOptionsTest = (
cotNone, cotNone,
cotCheckCompilerExe, cotCheckCompilerExe,
cotCompileBogusFiles, cotCheckAmbiguousFPCCfg,
cotCheckCompilerConfig // e.g. fpc.cfg cotCheckMissingFPCPPUs,
cotCheckCompilerDate,
cotCheckCompilerConfig, // e.g. fpc.cfg
cotCheckAmbiguousPPUsInUnitPath,
cotCheckFPCUnitPathsContainSources,
cotCompileBogusFiles
); );
TCompilerCheckMsgLvl = ( TCompilerCheckMsgLvl = (
@ -187,6 +192,9 @@ var
end; end;
begin begin
FTest:=cotCheckAmbiguousFPCCfg;
TestGroupbox.Caption:='Test: Checking fpc configs ...';
CfgFiles:=TStringList.Create; CfgFiles:=TStringList.Create;
// check $HOME/.fpc.cfg // check $HOME/.fpc.cfg
@ -245,6 +253,7 @@ begin
// compile bogus file // compile bogus file
FTest:=cotCompileBogusFiles; FTest:=cotCompileBogusFiles;
TestGroupbox.Caption:='Test: Compiling an empty file ...'; TestGroupbox.Caption:='Test: Compiling an empty file ...';
// get Test directory // get Test directory
TestDir:=AppendPathDelim(EnvironmentOptions.TestBuildDirectory); TestDir:=AppendPathDelim(EnvironmentOptions.TestBuildDirectory);
if not DirPathExists(TestDir) then begin if not DirPathExists(TestDir) then begin
@ -485,6 +494,9 @@ function TCheckCompilerOptsDlg.CheckMissingFPCPPUs(PPUs: TStrings
end; end;
begin begin
FTest:=cotCheckMissingFPCPPUs;
TestGroupbox.Caption:='Test: Checking missing fpc ppu ...';
Result:=mrCancel; Result:=mrCancel;
// rtl // rtl
if not Check('system',ccmlError) then exit; if not Check('system',ccmlError) then exit;
@ -537,6 +549,9 @@ var
end; end;
begin begin
FTest:=cotCheckCompilerDate;
TestGroupbox.Caption:='Test: Checking compiler date ...';
Result:=mrCancel; Result:=mrCancel;
CompilerDate:=FileAge(CompilerFilename); CompilerDate:=FileAge(CompilerFilename);
@ -638,6 +653,9 @@ var
FileInfo: TSearchRec; FileInfo: TSearchRec;
WarnedDirectories: TStringList; WarnedDirectories: TStringList;
begin begin
FTest:=cotCheckFPCUnitPathsContainSources;
TestGroupbox.Caption:='Test: Checking sources in fpc ppu search paths ...';
Result:=mrCancel; Result:=mrCancel;
WarnedDirectories:=TStringList.Create; WarnedDirectories:=TStringList.Create;
p:=1; p:=1;
@ -647,7 +665,7 @@ begin
Directory:=CleanAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p)); Directory:=CleanAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
if (Directory<>'') and (FilenameIsAbsolute(Directory)) if (Directory<>'') and (FilenameIsAbsolute(Directory))
and (WarnedDirectories.IndexOf(Directory)<0) then begin and (WarnedDirectories.IndexOf(Directory)<0) then begin
DebugLn(['TCheckCompilerOptsDlg.CheckFPCUnitPathsContainSources Directory="',Directory,'"']); //DebugLn(['TCheckCompilerOptsDlg.CheckFPCUnitPathsContainSources Directory="',Directory,'"']);
if SysUtils.FindFirst(Directory+GetAllFilesMask,faAnyFile,FileInfo)=0 if SysUtils.FindFirst(Directory+GetAllFilesMask,faAnyFile,FileInfo)=0
then begin then begin
repeat repeat
@ -682,14 +700,17 @@ var
CompileTool: TExternalToolOptions; CompileTool: TExternalToolOptions;
CompilerFiles: TStrings; CompilerFiles: TStrings;
FPCCfgUnitPath: string; FPCCfgUnitPath: string;
PPUs: TStrings; FPC_PPUs: TStrings;
TargetUnitPath: String;
Target_PPUs: TStrings;
begin begin
Result:=mrCancel; Result:=mrCancel;
if Test<>cotNone then exit; if Test<>cotNone then exit;
CompileTool:=nil; CompileTool:=nil;
TestMemo.Lines.Clear; TestMemo.Lines.Clear;
CompilerFiles:=nil; CompilerFiles:=nil;
PPUS:=nil; FPC_PPUs:=nil;
Target_PPUs:=nil;
try try
CompilerFilename:=Options.ParsedOpts.GetParsedValue(pcosCompilerPath); CompilerFilename:=Options.ParsedOpts.GetParsedValue(pcosCompilerPath);
@ -701,28 +722,36 @@ begin
Result:=CheckCompilerConfig(CompilerFilename,FPCCfgUnitPath); Result:=CheckCompilerConfig(CompilerFilename,FPCCfgUnitPath);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
PPUs:=FindAllPPUFiles(FPCCfgUnitPath); FPC_PPUs:=FindAllPPUFiles(FPCCfgUnitPath);
// check if compiler paths include base units // check if compiler paths include base units
Result:=CheckMissingFPCPPUs(PPUs); Result:=CheckMissingFPCPPUs(FPC_PPUs);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
// check if compiler is older than fpc ppu // check if compiler is older than fpc ppu
Result:=CheckCompilerDate(CompilerFilename,PPUs); Result:=CheckCompilerDate(CompilerFilename,FPC_PPUs);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
// check if there are ambiguous fpc ppu // check if there are ambiguous fpc ppu
Result:=CheckForAmbiguousPPUs(PPUs); Result:=CheckForAmbiguousPPUs(FPC_PPUs);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
// check if unit paths do not contain sources // check if unit paths do not contain sources
Result:=CheckFPCUnitPathsContainSources(FPCCfgUnitPath); Result:=CheckFPCUnitPathsContainSources(FPCCfgUnitPath);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
// gather PPUs in project/package unit search paths
TargetUnitPath:=Options.GetUnitPath(false);
Target_PPUs:=FindAllPPUFiles(TargetUnitPath);
// check if there are ambiguous ppu in project/package unit path
Result:=CheckForAmbiguousPPUs(Target_PPUs);
if not (Result in [mrOk,mrIgnore]) then exit;
// compile bogus file // compile bogus file
Result:=CheckCompileBogusFile(CompilerFilename); Result:=CheckCompileBogusFile(CompilerFilename);
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
if OutputListbox.Items.Count=0 then if OutputListbox.Items.Count=0 then
AddMsg('All tests succeeded.','',-1); AddMsg('All tests succeeded.','',-1);
@ -731,7 +760,8 @@ begin
CompileTool.Free; CompileTool.Free;
FTest:=cotNone; FTest:=cotNone;
TestGroupbox.Caption:='Test'; TestGroupbox.Caption:='Test';
PPUS.Free; FPC_PPUs.Free;
Target_PPUs.Free;
end; end;
Result:=mrOk; Result:=mrOk;
end; end;

View File

@ -210,24 +210,27 @@ begin
GDK2.gdk_region_xor(result, source2); GDK2.gdk_region_xor(result, source2);
end; end;
Procedure gdk_text_extents(FontDesc : PPangoFontDescription; Str : PChar; Procedure gdk_text_extents(FontDesc: PPangoFontDescription; Str: PChar;
LineLength : Longint; lbearing, rbearing, width, ascent, descent : Pgint); LineLength: Longint; lbearing, rbearing, width, ascent, descent: Pgint);
var var
Layout : PPangoLayout; Layout : PPangoLayout;
AttrList : PPangoAttrList; AttrList : PPangoAttrList;
Attr : PPangoAttribute; Attr : PPangoAttribute;
Extents : TPangoRectangle; Extents : TPangoRectangle;
AttrListAllocated: Boolean;
begin begin
GetStyle(lgsDefault); GetStyle(lgsDefault);
Layout := gtk_widget_create_pango_layout (GetStyleWidget(lgsDefault), nil); Layout := gtk_widget_create_pango_layout (GetStyleWidget(lgsDefault), nil);
pango_layout_set_font_description(Layout, FontDesc); pango_layout_set_font_description(Layout, FontDesc);
AttrList := pango_layout_get_attributes(Layout); AttrList := pango_layout_get_attributes(Layout);
If (AttrList = nil) then AttrListAllocated:=false;
if (AttrList = nil) then begin
AttrList := pango_attr_list_new(); AttrList := pango_attr_list_new();
AttrListAllocated:=true;
end;
Attr := pango_attr_underline_new(PANGO_UNDERLINE_NONE); Attr := pango_attr_underline_new(PANGO_UNDERLINE_NONE);
pango_attr_list_change(AttrList,Attr); pango_attr_list_change(AttrList,Attr);
Attr := pango_attr_strikethrough_new(False); Attr := pango_attr_strikethrough_new(False);
@ -240,31 +243,31 @@ begin
pango_layout_set_alignment(Layout, PANGO_ALIGN_LEFT); pango_layout_set_alignment(Layout, PANGO_ALIGN_LEFT);
//fix me... and what about UTF-8 conversion? pango_layout_set_text(Layout, Str, Linelength);
//this could be a massive problem since we
//will need to know before hand what the current
//locale is, and if we stored UTF-8 string this would break
//cross-compatibility with GTK1.2 and win32 interfaces.....
pango_layout_set_text(Layout, Str, Linelength);
if Assigned(width) then if Assigned(width) then
pango_layout_get_pixel_size(Layout, width, nil); pango_layout_get_pixel_size(Layout, width, nil);
pango_layout_get_extents(Layout, nil, @Extents); if Assigned(lbearing) or Assigned(rbearing)
or Assigned(ascent) or Assigned(descent) then begin
pango_layout_get_extents(Layout, nil, @Extents);
if Assigned(lbearing) then
lbearing^ := PANGO_LBEARING(extents) div PANGO_SCALE;
if Assigned(rbearing) then
rBearing^ := PANGO_RBEARING(extents) div PANGO_SCALE;
if Assigned(ascent) then
ascent^ := PANGO_ASCENT(extents) div PANGO_SCALE;
if Assigned(descent) then
descent^ := PANGO_DESCENT(extents) div PANGO_SCALE;
end;
if AttrListAllocated then
pango_attr_list_unref(AttrList);
g_object_unref(Layout); g_object_unref(Layout);
if Assigned(lbearing) then
lbearing^ := PANGO_LBEARING(extents) div PANGO_SCALE;
if Assigned(rbearing) then
rBearing^ := PANGO_RBEARING(extents) div PANGO_SCALE;
if Assigned(ascent) then
ascent^ := PANGO_ASCENT(extents) div PANGO_SCALE;
if Assigned(descent) then
descent^ := PANGO_DESCENT(extents) div PANGO_SCALE;
end; end;
{$EndIf Gtk2} {$EndIf Gtk2}