mirror of
https://github.com/xcat2/xcat-dep.git
synced 2026-09-25 01:04:06 +00:00
test(genesis): cover dirty release sources
This commit is contained in:
@@ -14,6 +14,8 @@ use XCAT::GenesisReleaseTest qw(
|
||||
command_exists
|
||||
file_sha
|
||||
make_export
|
||||
read_file
|
||||
run_capture
|
||||
write_checksums
|
||||
write_file
|
||||
write_release_manifest
|
||||
@@ -214,21 +216,6 @@ sub make_package_release {
|
||||
return $release_root;
|
||||
}
|
||||
|
||||
sub run_capture {
|
||||
my ($log, @command) = @_;
|
||||
my $pid = fork();
|
||||
die "Cannot fork: $!\n" unless defined $pid;
|
||||
if ($pid == 0) {
|
||||
open(STDOUT, '>:raw', $log) or die $!;
|
||||
open(STDERR, '>&', STDOUT) or die $!;
|
||||
exec(@command) or die "Cannot run $command[0]: $!\n";
|
||||
}
|
||||
waitpid($pid, 0);
|
||||
return 255 if $? == -1;
|
||||
return 128 + ($? & 127) if $? & 127;
|
||||
return $? >> 8;
|
||||
}
|
||||
|
||||
sub capture {
|
||||
my (@command) = @_;
|
||||
open(my $fh, '-|', @command) or die $!;
|
||||
@@ -237,12 +224,3 @@ sub capture {
|
||||
chomp($output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub read_file {
|
||||
my ($path) = @_;
|
||||
open(my $fh, '<:raw', $path) or die $!;
|
||||
local $/;
|
||||
my $content = <$fh> // '';
|
||||
close($fh) or die $!;
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ use XCAT::GenesisReleaseTest qw(
|
||||
dies_like
|
||||
file_sha
|
||||
make_export
|
||||
read_file
|
||||
run_capture
|
||||
write_checksums
|
||||
write_file
|
||||
write_release_manifest
|
||||
@@ -30,6 +32,7 @@ use XCAT::GenesisReleaseTest qw(
|
||||
|
||||
my $repo_root = abs_path("$FindBin::Bin/..");
|
||||
my $packager = "$repo_root/genesis-openembedded/package";
|
||||
my $builder = "$repo_root/genesis-openembedded/build";
|
||||
my $verifier = "$repo_root/genesis-openembedded/verify-release";
|
||||
my $revision = 'a' x 40;
|
||||
my $version = '2.19.0';
|
||||
@@ -112,6 +115,36 @@ write_checksums($missing_release);
|
||||
dies_like(sub { validate_release($missing_release) }, qr/Genesis release is missing/,
|
||||
'incomplete architecture set fails');
|
||||
|
||||
SKIP: {
|
||||
skip 'git is not installed', 2 unless command_exists('git');
|
||||
my $source = "$tmp/dirty-xcat-core";
|
||||
make_path("$source/xCAT-genesis-builder/oe");
|
||||
write_file("$source/Version", "$version\n");
|
||||
write_file("$source/xCAT-genesis-builder/oe/build", "#!/bin/sh\nexit 99\n");
|
||||
write_file("$source/xCAT-genesis-builder/oe/export", "#!/bin/sh\nexit 99\n");
|
||||
for my $command (
|
||||
[ 'git', '-C', $source, 'init', '-q' ],
|
||||
[ 'git', '-C', $source, 'add', '.' ],
|
||||
[ 'git', '-C', $source, '-c', 'user.name=xCAT test',
|
||||
'-c', 'user.email=xcat-test@example.invalid', 'commit', '-qm', 'fixture' ],
|
||||
) {
|
||||
die "Cannot prepare test repository\n"
|
||||
if run_capture("$tmp/git-fixture.log", @{$command});
|
||||
}
|
||||
write_file("$source/untracked", "not part of the commit\n");
|
||||
my $log = "$tmp/dirty-source.log";
|
||||
isnt(
|
||||
run_capture(
|
||||
$log, $builder, '--xcat-source', $source,
|
||||
'--output-dir', "$tmp/dirty-output",
|
||||
),
|
||||
0,
|
||||
'release builder rejects untracked source files',
|
||||
);
|
||||
like(read_file($log), qr/xcat-core checkout is not clean/,
|
||||
'dirty checkout failure is explicit');
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip 'rpmbuild and rpm are not installed', 8
|
||||
unless command_exists('rpmbuild') && command_exists('rpm');
|
||||
|
||||
@@ -18,6 +18,8 @@ our @EXPORT_OK = qw(
|
||||
dies_like
|
||||
file_sha
|
||||
make_export
|
||||
read_file
|
||||
run_capture
|
||||
write_checksums
|
||||
write_file
|
||||
write_release_manifest
|
||||
@@ -123,6 +125,30 @@ sub command_exists {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub run_capture {
|
||||
my ($log, @command) = @_;
|
||||
my $pid = fork();
|
||||
die "Cannot fork: $!\n" unless defined $pid;
|
||||
if ($pid == 0) {
|
||||
open(STDOUT, '>:raw', $log) or die $!;
|
||||
open(STDERR, '>&', STDOUT) or die $!;
|
||||
exec(@command) or die "Cannot run $command[0]: $!\n";
|
||||
}
|
||||
waitpid($pid, 0);
|
||||
return 255 if $? == -1;
|
||||
return 128 + ($? & 127) if $? & 127;
|
||||
return $? >> 8;
|
||||
}
|
||||
|
||||
sub read_file {
|
||||
my ($path) = @_;
|
||||
open(my $fh, '<:raw', $path) or die $!;
|
||||
local $/;
|
||||
my $content = <$fh> // '';
|
||||
close($fh) or die $!;
|
||||
return $content;
|
||||
}
|
||||
|
||||
sub dies_like {
|
||||
my ($code, $pattern, $name) = @_;
|
||||
my $error = '';
|
||||
|
||||
Reference in New Issue
Block a user