diff --git a/packages/fpmkunit/src/fpmkunit.pp b/packages/fpmkunit/src/fpmkunit.pp index 679d33cadd..79bf36cb2b 100644 --- a/packages/fpmkunit/src/fpmkunit.pp +++ b/packages/fpmkunit/src/fpmkunit.pp @@ -1682,7 +1682,8 @@ ResourceString SInfoDestDoesNotExist = 'Destination file "%s" does not exist.'; SInfoFallbackBuildmode = 'Buildmode not supported by package, falling back to one by one unit compilation'; SInfoFallbackBuildmodeBU= 'Buildmode not supported by package, falling back to compilation using a buildunit'; - SInfoDirectoryNoPackage = 'Found directory "%s" which does not contain a package'; + SInfoDirectoryNoPackage = 'Found directory "%s" while searching for package "%s" which does not contain a package'; + SInfoSrcDirectoryNoPkg = 'Found source-directory "%s" while searching for package "%s" but the package is not compiled or has the wrong name'; SDbgComparingFileTimes = 'Comparing file "%s" time "%s" to "%s" time "%s".'; SDbgCompilingDependenciesOfTarget = 'Compiling dependencies of target %s'; @@ -2811,7 +2812,7 @@ begin AnUnitConfigFilename:=APackage.Dictionary.ReplaceStrings(AnUnitConfigFilename); if ABuildEngine.SysFileExists(AnUnitConfigFilename) then APackage.UnitConfigFileName:=AnUnitConfigFilename - else if not IsPackageSourceLocation then + else begin // To avoid that directories which do not contain installed packages // check that there is an unit-configfile, or Packages.fpc file. (The @@ -2820,8 +2821,22 @@ begin // Lazarus-source-repositories. if not ABuildEngine.SysFileExists(ConcatPaths([PackageBaseDir, 'Package.fpc'])) then begin - Installer.Log(vlInfo,Format(SInfoDirectoryNoPackage,[PackageBaseDir])); - Exit; + if IsPackageSourceLocation then + begin + // There is no way that I know of to confirm that a directory + // contains the compiled sources of the rtl. So we need a + // workaround. This test is skipped in case of the rtl. + if APackage.Name<>'rtl' then + begin + Installer.Log(vlInfo,Format(SInfoSrcDirectoryNoPkg,[PackageBaseDir, APackage.Name])); + Exit; + end; + end + else + begin + Installer.Log(vlInfo,Format(SInfoDirectoryNoPackage,[PackageBaseDir, APackage.Name])); + Exit; + end; end; end; diff --git a/packages/fppkg/tests/fullfpcinstallationtests.pas b/packages/fppkg/tests/fullfpcinstallationtests.pas index e5349f1ef0..a63e00a1ac 100644 --- a/packages/fppkg/tests/fullfpcinstallationtests.pas +++ b/packages/fppkg/tests/fullfpcinstallationtests.pas @@ -462,6 +462,8 @@ begin end; procedure TFullFPCInstallationTests.TestSourceDependency; +var + s: String; begin // This is to test if fpmkunit works correctly when a dependency is available // not as an installed but as a (compiled) source-package. This happens for @@ -475,6 +477,17 @@ begin RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packageb', ['build'], 'create fpmake-executable', 1); RunFPMakeIndir(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath,'packageb']), ['build'], 'build packageb'); + + // When there is no .fpm file, fpmake should complain that the package is not + // compiled. (Another possibility is that another packages is mistakenly being + // used, for example when the package-name does not match the directory-name) + // This has to be enforced because without the .fpm, the dependencies are + // not handled. + s := ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath,'packagea','packagea-'+TFullFPCInstallationSetup.GetTargetString+'.fpm']); + DeleteFile(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath,'packagea','packagea-'+TFullFPCInstallationSetup.GetTargetString+'.fpm'])); + s := RunFPMakeIndir(ConcatPaths([TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath,'packageb']), ['build', '-d'], 'build packageb without fpm', 1); + Check(pos('the package is not compiled', s) > 0, 'Missing .fpm-file detection did not trigger'); + Check(pos('Could not find unit directory for dependency package', s) > 0, 'Incorrect error message'); end; procedure TFullFPCInstallationTests.TestTransmitOptions;