Skip to content

Commit

Permalink
[ci] refactoring tests to perl
Browse files Browse the repository at this point in the history
  • Loading branch information
M0ses committed May 2, 2017
1 parent b135c9e commit 2f4656a
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 108 deletions.
17 changes: 0 additions & 17 deletions dist/t/osc/0000_configure_osc.t

This file was deleted.

22 changes: 22 additions & 0 deletions dist/t/osc/0000_configure_osc.ts
@@ -0,0 +1,22 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More tests => 1;

eval {
my $oscrc="$::ENV{HOME}/.oscrc";
open(OSCRC,'>',$oscrc) || die "Could not open $oscrc: $!";
print OSCRC "[general]
apiurl = https://localhost
[https://localhost]
user=Admin
pass=opensuse
";
close OSCRC;
};

ok(!$@,"Configuring oscrc");

exit 0
19 changes: 0 additions & 19 deletions dist/t/osc/0010_create_interconnect.t

This file was deleted.

12 changes: 12 additions & 0 deletions dist/t/osc/0010_create_interconnect.ts
@@ -0,0 +1,12 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More tests => 1;
use FindBin;

system("osc meta prj openSUSE.org -F $FindBin::Bin/fixtures/openSUSE.org.xml");

ok(!$?,"Configuring interconnect");

exit 0;
17 changes: 0 additions & 17 deletions dist/t/osc/0020_create_home:Admin.t

This file was deleted.

12 changes: 12 additions & 0 deletions dist/t/osc/0020_create_home:Admin.ts
@@ -0,0 +1,12 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More tests => 1;
use FindBin;

system("osc meta prj home:Admin -F $FindBin::Bin/fixtures/home:Admin.xml");

ok(!$?,"Checking creation of home:Admin project");

exit 0
38 changes: 0 additions & 38 deletions dist/t/osc/0030_create_and_build_package.t

This file was deleted.

67 changes: 67 additions & 0 deletions dist/t/osc/0030_create_and_build_package.ts
@@ -0,0 +1,67 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More tests => 5;
use FindBin;
use File::Path qw(make_path remove_tree);
use File::Copy;
my $RCODE=0;

my $TMP_DIR="$FindBin::Bin/tmp";

# prepare TMP_DIR
remove_tree($TMP_DIR);
make_path($TMP_DIR);
chdir($TMP_DIR);

# checkout home:Admin
system("osc co home:Admin");

ok(!$?,"Checking preparation of project");

# prepare package
eval {
chdir("home:Admin") || die "Could not change to directory 'home:Admin': $!";
mkdir("obs-testpackage") || die "Could not create directory 'obs-testpackage':$!";
system("osc add obs-testpackage");
die "Could not add package 'obs-testpackage' via osc" if ($?);
chdir("obs-testpackage") || die "Could not change to directory '".cwd()."/obs-testpackage': $!";

my $src="$FindBin::Bin/fixtures/obs-testpackage._service";
my $dst="./_service";
copy($src,$dst) or die "Copy '$src' -> '$dst' failed: $!";
system("osc ar");
die "Could not add files to package via osc!" if ($?);
};

ok(!$@,"Checking preparation of package");

# commit package
system('osc ci -m "initial version"');
ok(!$?,"Checking initial commit of package obs-testpackage");

eval {
# wait for package to finish build
system("osc r -w");
die "Error while waiting for package to finish" if ($?);
};

ok(!$@,"Finished building of package");
my @succeed;

eval {
my @result = `osc r`;

# count succeed
my $succeed = 0;
@succeed = grep { /succeeded/ } @result;
};

my $r = ok(@succeed == 2,"Checking succeed builds");
if (! $r) {
open(F,">","$TMP_DIR/.SKIP") || die "Error while touching $TMP_DIR/.SKIP: $!";
close(F);
}

exit 0
17 changes: 0 additions & 17 deletions dist/t/osc/0040_delete_package_build.t

This file was deleted.

29 changes: 29 additions & 0 deletions dist/t/osc/0040_delete_package_build.ts
@@ -0,0 +1,29 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use FindBin;
use File::Path qw(make_path remove_tree);

my $TMP_DIR="$FindBin::Bin/tmp/";
if ( -f "$TMP_DIR/.SKIP" ) {
plan skip_all => "Previous tests failed - keeping results";
} else {
plan tests => 2;

chdir("$TMP_DIR/home:Admin");

system("osc delete obs-testpackage");

ok(!$?,"Deleting package obs-testpackage");

system("osc ci -m \"removed package obs-testpackage\"");
ok(!$?,"Commiting deleted package obs-testpackage");

# cleanup TMP_DIR
chdir($FindBin::Bin);
remove_tree($TMP_DIR);
}

exit 0;
5 changes: 5 additions & 0 deletions dist/t/osc/Makefile
@@ -0,0 +1,5 @@
check:
@for i in *.t;do perl -c $$i;done

test_system:
prove -v *.ts

0 comments on commit 2f4656a

Please sign in to comment.