go: move tests to separate file for sharing between versions
This commit is contained in:
@@ -9,16 +9,13 @@
|
||||
buildPackages,
|
||||
pkgsBuildTarget,
|
||||
targetPackages,
|
||||
testers,
|
||||
skopeo,
|
||||
buildGo124Module,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
let
|
||||
goBootstrap = buildPackages.callPackage ./bootstrap122.nix { };
|
||||
|
||||
skopeoTest = skopeo.override { buildGoModule = buildGo124Module; };
|
||||
|
||||
# We need a target compiler which is still runnable at build time,
|
||||
# to handle the cross-building case where build != host == target
|
||||
targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
|
||||
@@ -195,14 +192,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
disallowedReferences = [ goBootstrap ];
|
||||
|
||||
passthru = {
|
||||
inherit goBootstrap skopeoTest;
|
||||
tests = {
|
||||
skopeo = testers.testVersion { package = skopeoTest; };
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
command = "go version";
|
||||
version = "go${finalAttrs.version}";
|
||||
};
|
||||
inherit goBootstrap;
|
||||
tests = callPackage ./tests.nix {
|
||||
go = finalAttrs.finalPackage;
|
||||
buildGoModule = buildGo124Module;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -10,20 +10,13 @@
|
||||
pkgsBuildTarget,
|
||||
targetPackages,
|
||||
# for testing
|
||||
testers,
|
||||
runCommand,
|
||||
bintools,
|
||||
skopeo,
|
||||
clickhouse-backup,
|
||||
buildGo125Module,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
let
|
||||
goBootstrap = buildPackages.callPackage ./bootstrap122.nix { };
|
||||
|
||||
skopeoTest = skopeo.override { buildGoModule = buildGo125Module; };
|
||||
clickhouse-backupTest = clickhouse-backup.override { buildGoModule = buildGo125Module; };
|
||||
|
||||
# We need a target compiler which is still runnable at build time,
|
||||
# to handle the cross-building case where build != host == target
|
||||
targetCC = pkgsBuildTarget.targetPackages.stdenv.cc;
|
||||
@@ -200,31 +193,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
disallowedReferences = [ goBootstrap ];
|
||||
|
||||
passthru = {
|
||||
inherit goBootstrap skopeoTest;
|
||||
tests = {
|
||||
skopeo = testers.testVersion { package = skopeoTest; };
|
||||
version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
command = "go version";
|
||||
version = "go${finalAttrs.version}";
|
||||
};
|
||||
# Picked clickhouse-backup as a package that sets CGO_ENABLED=0
|
||||
# Running and outputting the right version proves a working ELF interpreter was picked
|
||||
clickhouse-backup = testers.testVersion { package = clickhouse-backupTest; };
|
||||
clickhouse-backup-is-pie = runCommand "has-pie" { meta.broken = stdenv.hostPlatform.isStatic; } ''
|
||||
${lib.optionalString (!isCross) ''
|
||||
if ${lib.getExe' bintools "readelf"} -p .comment ${lib.getExe clickhouse-backup} | grep -Fq "GCC: (GNU)"; then
|
||||
echo "${lib.getExe clickhouse-backup} has a GCC .comment, but it should have used the internal go linker"
|
||||
exit 1
|
||||
fi
|
||||
''}
|
||||
if ${lib.getExe' bintools "readelf"} -h ${lib.getExe clickhouse-backup} | grep -q "Type:.*DYN"; then
|
||||
touch $out
|
||||
else
|
||||
echo "ERROR: clickhouse-backup is NOT PIE"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
inherit goBootstrap;
|
||||
tests = callPackage ./tests.nix {
|
||||
go = finalAttrs.finalPackage;
|
||||
buildGoModule = buildGo125Module;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
go,
|
||||
buildGoModule,
|
||||
skopeo,
|
||||
testers,
|
||||
runCommand,
|
||||
bintools,
|
||||
clickhouse-backup,
|
||||
}:
|
||||
let
|
||||
skopeo' = skopeo.override { buildGoModule = buildGoModule; };
|
||||
clickhouse-backup' = clickhouse-backup.override { buildGoModule = buildGoModule; };
|
||||
in
|
||||
{
|
||||
skopeo = testers.testVersion { package = skopeo'; };
|
||||
version = testers.testVersion {
|
||||
package = go;
|
||||
command = "go version";
|
||||
version = "go${go.version}";
|
||||
};
|
||||
# Picked clickhouse-backup as a package that sets CGO_ENABLED=0
|
||||
# Running and outputting the right version proves a working ELF interpreter was picked
|
||||
clickhouse-backup = testers.testVersion { package = clickhouse-backup'; };
|
||||
clickhouse-backup-is-pie = runCommand "has-pie" { meta.broken = stdenv.hostPlatform.isStatic; } ''
|
||||
${lib.optionalString (stdenv.buildPlatform == stdenv.targetPlatform) ''
|
||||
if ${lib.getExe' bintools "readelf"} -p .comment ${lib.getExe clickhouse-backup'} | grep -Fq "GCC: (GNU)"; then
|
||||
echo "${lib.getExe clickhouse-backup'} has a GCC .comment, but it should have used the internal go linker"
|
||||
exit 1
|
||||
fi
|
||||
''}
|
||||
if ${lib.getExe' bintools "readelf"} -h ${lib.getExe clickhouse-backup'} | grep -q "Type:.*DYN"; then
|
||||
touch $out
|
||||
else
|
||||
echo "ERROR: clickhouse-backup is NOT PIE"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user