* Cleanup build-files in case of an error + test

git-svn-id: trunk@36198 -
This commit is contained in:
joost 2017-05-12 20:50:05 +00:00
parent e9c40f5b24
commit 49d75902f6
4 changed files with 68 additions and 23 deletions

1
.gitattributes vendored
View File

@ -3436,6 +3436,7 @@ packages/fppkg/src/pkguninstalledsrcsrepo.pp svneol=native#text/plain
packages/fppkg/src/pkgwget.pp svneol=native#text/plain packages/fppkg/src/pkgwget.pp svneol=native#text/plain
packages/fppkg/tests/fppkg_tests.pp svneol=native#text/plain packages/fppkg/tests/fppkg_tests.pp svneol=native#text/plain
packages/fppkg/tests/fullfpcinstallationtests.pas svneol=native#text/plain packages/fppkg/tests/fullfpcinstallationtests.pas svneol=native#text/plain
packages/fppkg/tests/packages/base/brokenpackage/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/base/packagea/fpmake.pp svneol=native#text/plain packages/fppkg/tests/packages/base/packagea/fpmake.pp svneol=native#text/plain
packages/fppkg/tests/packages/base/packagea/src/PackageAUnitA.pas svneol=native#text/plain packages/fppkg/tests/packages/base/packagea/src/PackageAUnitA.pas svneol=native#text/plain
packages/fppkg/tests/packages/base/packageb/fpmake.pp svneol=native#text/plain packages/fppkg/tests/packages/base/packageb/fpmake.pp svneol=native#text/plain

View File

@ -308,29 +308,32 @@ begin
// Units in a directory for easy cleaning // Units in a directory for easy cleaning
DeleteDir(TempBuildDir); DeleteDir(TempBuildDir);
ForceDirectories(TempBuildDir); ForceDirectories(TempBuildDir);
// Compile options try
// -- default is to optimize, smartlink and strip to reduce // Compile options
// the executable size (there can be 100's of fpmake's on a system) // -- default is to optimize, smartlink and strip to reduce
if llInfo in LogLevels then // the executable size (there can be 100's of fpmake's on a system)
AddOption('-vi'); if llInfo in LogLevels then
AddOption('-O2'); AddOption('-vi');
AddOption('-XXs'); AddOption('-O2');
// Create fpmkunit.pp if needed AddOption('-XXs');
if NeedFPMKUnitSource then // Create fpmkunit.pp if needed
begin if NeedFPMKUnitSource then
Log(llWarning,SLogUseInternalFpmkunit); begin
CreateFPMKUnitSource(TempBuildDir+PathDelim+'fpmkunit.pp'); Log(llWarning,SLogUseInternalFpmkunit);
end; CreateFPMKUnitSource(TempBuildDir+PathDelim+'fpmkunit.pp');
// Call compiler end;
If ExecuteProcess(PackageManager.FPMakeCompilerOptions.Compiler,OOptions+' '+FPmakeSrc)<>0 then // Call compiler
begin If ExecuteProcess(PackageManager.FPMakeCompilerOptions.Compiler,OOptions+' '+FPmakeSrc)<>0 then
if not PackageManager.Options.CommandLineSection.RecoveryMode then begin
Error(SErrCompileFailureFPMakeTryRecovery) if not PackageManager.Options.CommandLineSection.RecoveryMode then
else Error(SErrCompileFailureFPMakeTryRecovery)
Error(SErrCompileFailureFPMake); else
end; Error(SErrCompileFailureFPMake);
// Cleanup units end;
DeleteDir(TempBuildDir); finally
// Cleanup units
DeleteDir(TempBuildDir);
end;
end end
else else
Log(llCommands,SLogNotCompilingFPMake); Log(llCommands,SLogNotCompilingFPMake);

View File

@ -38,6 +38,7 @@ type
procedure TestPackageVariantPackage; procedure TestPackageVariantPackage;
procedure TestFPMakeCommandLikePackageVariants; procedure TestFPMakeCommandLikePackageVariants;
procedure TestFpmakePluginDependencies; procedure TestFpmakePluginDependencies;
procedure TestCleanupOfTemporaryBuildpath;
end; end;
{ TFullFPCInstallationSetup } { TFullFPCInstallationSetup }
@ -338,6 +339,21 @@ begin
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packageusingplugin', ['install'], 'Install package that depends on plugin'); RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packageusingplugin', ['install'], 'Install package that depends on plugin');
end; end;
procedure TFullFPCInstallationTests.TestCleanupOfTemporaryBuildpath;
var
SR: TSearchRec;
begin
TFullFPCInstallationSetup.SyncPackageIntoCurrentTest('brokenpackage');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'brokenpackage', ['build'], 'Attempt to build brokenpackage', 1);
if FindFirst(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'brokenpackage'+PathDelim+AllFilesMask, faAnyFile, sr) = 0 then
begin
repeat
Check(not ((SR.Name<>'.') and (SR.Name<>'..') and (SR.Name<>'fpmake.pp') and (SR.Name<>'src')), 'Check for garbage-files after build ('+SR.Name+')');
until FindNext(SR) <> 0;
end;
end;
procedure TFullFPCInstallationTests.TestListPackages; procedure TFullFPCInstallationTests.TestListPackages;
var var
s: String; s: String;

View File

@ -0,0 +1,25 @@
{$mode objfpc}{$H+}
program fpmake;
This will not compile.
uses fpmkunit;
Var
P : TPackage;
T : TTarget;
begin
With Installer do
begin
P:=AddPackage('brokenpackage');
P.Version:='1.23.3';
P.Author := 'Joost van der Sluis';
P.License := 'GPL';
P.HomepageURL := 'www.freepascal.org';
P.Email := '';
P.Description := 'Package that does not work at all';
Run;
end;
end.