Skip to content

Commit dadc7aa

Browse files
committed
Regression test for recent fixed output derivation bug
It turns out that the hydra test suite was not testing fixed output derivations at all! I tested that this test fails before the fix, and suceeds after. Also, delete a generated file that I accidentally committed by mistake when moving things around.
1 parent 447a7a1 commit dadc7aa

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

subprojects/hydra-tests/jobs/config.nix

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/sh
2+
3+
echo -n hello > $out
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
with import ./config.nix;
2+
{
3+
# A flat-hash fixed-output derivation.
4+
# sha256 of "hello" (no newline).
5+
fod = derivation {
6+
name = "test-fod";
7+
system = builtins.currentSystem;
8+
builder = ./fod-builder.sh;
9+
outputHashMode = "flat";
10+
outputHashAlgo = "sha256";
11+
outputHash = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824";
12+
};
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use strict;
2+
use warnings;
3+
use Setup;
4+
use Test2::V0;
5+
6+
# Regression test for the harmonia-store-core bug fixed in 2f09d76:
7+
# a missing trailing colon in the FOD fingerprint
8+
# "fixed:out:<hashAlgo>:<hex>:" caused output_paths() to compute wrong
9+
# store paths for fixed-output derivations.
10+
11+
my $ctx = test_context();
12+
13+
my $builds = $ctx->makeAndEvaluateJobset(
14+
expression => "fod.nix",
15+
build => 1,
16+
);
17+
18+
subtest "FOD build succeeds with correct output path" => sub {
19+
my $build = $builds->{"fod"};
20+
is($build->finished, 1, "Build should be finished.");
21+
is($build->buildstatus, 0, "Build should have succeeded.");
22+
23+
my $out = $build->buildoutputs->find({ name => "out" });
24+
ok(defined $out, "Build should have an 'out' output");
25+
like($out->path, qr|/nix/store/|, "Output path should be a store path");
26+
};
27+
28+
done_testing;

0 commit comments

Comments
 (0)