diff --git a/.gitattributes b/.gitattributes index 5cb266c492..f99d78ad39 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3436,6 +3436,7 @@ packages/fppkg/src/pkguninstalledsrcsrepo.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/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/src/PackageAUnitA.pas svneol=native#text/plain packages/fppkg/tests/packages/base/packageb/fpmake.pp svneol=native#text/plain diff --git a/packages/fppkg/src/pkgfpmake.pp b/packages/fppkg/src/pkgfpmake.pp index aba8c620db..27607584d3 100644 --- a/packages/fppkg/src/pkgfpmake.pp +++ b/packages/fppkg/src/pkgfpmake.pp @@ -308,29 +308,32 @@ begin // Units in a directory for easy cleaning DeleteDir(TempBuildDir); ForceDirectories(TempBuildDir); - // Compile options - // -- default is to optimize, smartlink and strip to reduce - // the executable size (there can be 100's of fpmake's on a system) - if llInfo in LogLevels then - AddOption('-vi'); - AddOption('-O2'); - AddOption('-XXs'); - // Create fpmkunit.pp if needed - if NeedFPMKUnitSource then - begin - Log(llWarning,SLogUseInternalFpmkunit); - CreateFPMKUnitSource(TempBuildDir+PathDelim+'fpmkunit.pp'); - end; - // Call compiler - If ExecuteProcess(PackageManager.FPMakeCompilerOptions.Compiler,OOptions+' '+FPmakeSrc)<>0 then - begin - if not PackageManager.Options.CommandLineSection.RecoveryMode then - Error(SErrCompileFailureFPMakeTryRecovery) - else - Error(SErrCompileFailureFPMake); - end; - // Cleanup units - DeleteDir(TempBuildDir); + try + // Compile options + // -- default is to optimize, smartlink and strip to reduce + // the executable size (there can be 100's of fpmake's on a system) + if llInfo in LogLevels then + AddOption('-vi'); + AddOption('-O2'); + AddOption('-XXs'); + // Create fpmkunit.pp if needed + if NeedFPMKUnitSource then + begin + Log(llWarning,SLogUseInternalFpmkunit); + CreateFPMKUnitSource(TempBuildDir+PathDelim+'fpmkunit.pp'); + end; + // Call compiler + If ExecuteProcess(PackageManager.FPMakeCompilerOptions.Compiler,OOptions+' '+FPmakeSrc)<>0 then + begin + if not PackageManager.Options.CommandLineSection.RecoveryMode then + Error(SErrCompileFailureFPMakeTryRecovery) + else + Error(SErrCompileFailureFPMake); + end; + finally + // Cleanup units + DeleteDir(TempBuildDir); + end; end else Log(llCommands,SLogNotCompilingFPMake); diff --git a/packages/fppkg/tests/fullfpcinstallationtests.pas b/packages/fppkg/tests/fullfpcinstallationtests.pas index 878c4ccaac..06121f3035 100644 --- a/packages/fppkg/tests/fullfpcinstallationtests.pas +++ b/packages/fppkg/tests/fullfpcinstallationtests.pas @@ -38,6 +38,7 @@ type procedure TestPackageVariantPackage; procedure TestFPMakeCommandLikePackageVariants; procedure TestFpmakePluginDependencies; + procedure TestCleanupOfTemporaryBuildpath; end; { TFullFPCInstallationSetup } @@ -338,6 +339,21 @@ begin RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packageusingplugin', ['install'], 'Install package that depends on plugin'); 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; var s: String; diff --git a/packages/fppkg/tests/packages/base/brokenpackage/fpmake.pp b/packages/fppkg/tests/packages/base/brokenpackage/fpmake.pp new file mode 100644 index 0000000000..33b28bdeb6 --- /dev/null +++ b/packages/fppkg/tests/packages/base/brokenpackage/fpmake.pp @@ -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.