[perl-Gtk2] use File::Temp in several test scripts
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk2] use File::Temp in several test scripts
- Date: Sat, 7 Dec 2013 23:26:50 +0000 (UTC)
commit fb0c9b9904569752c3a869acc5e92ae86a6b44b6
Author: Gabor Szabo <szabgab gmail com>
Date: Sat Oct 5 20:03:15 2013 +0300
use File::Temp in several test scripts
t/GdkPixbuf.t | 10 ++++------
t/GtkBuilder.t | 7 ++++---
t/GtkPageSetup.t | 9 +++++----
t/GtkPrintContext.t | 7 ++++---
t/GtkPrintOperation.t | 7 ++++---
t/GtkPrintSettings.t | 11 +++++------
t/GtkRecentChooser.t | 8 ++++----
7 files changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/t/GdkPixbuf.t b/t/GdkPixbuf.t
index f00f938..ebb6645 100644
--- a/t/GdkPixbuf.t
+++ b/t/GdkPixbuf.t
@@ -5,7 +5,8 @@ use Gtk2::TestHelper tests => 112, noinit => 1;
my $show = 0;
-
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
my $gif = 'gtk-demo/floppybuddy.gif';
@@ -195,7 +196,7 @@ $vbox->add (Gtk2::Image->new_from_pixbuf ($pixbuf)) if $show;
# these functions can throw Gtk2::Gdk::Pixbuf::Error and Glib::File::Error
# exceptions.
#
-my $filename = 'testsave.jpg';
+my $filename = "$dir/testsave1.jpg";
$pixbuf->save ($filename, 'jpeg', quality => 75.0);
ok (1);
@@ -232,10 +233,9 @@ SKIP: {
is ($height, 5);
}
-unlink $filename;
-$filename = 'testsave.png';
+$filename = "$dir/testsaves.png";
eval {
$pixbuf->save ($filename, 'png',
'key_arg_without_value_arg');
@@ -289,8 +289,6 @@ SKIP: {
is ($pixbuf->get_option ('tEXt::woot'), 'whee');
}
-unlink $filename;
-
# raw pixel values to make the xpm above, but with green for the
# transparent pixels, so we can use add_alpha.
diff --git a/t/GtkBuilder.t b/t/GtkBuilder.t
index 96f8ba5..f9ce0f6 100644
--- a/t/GtkBuilder.t
+++ b/t/GtkBuilder.t
@@ -7,6 +7,9 @@ use Gtk2::TestHelper
# $Id$
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
my $builder;
my $ui = <<EOD;
<interface>
@@ -27,7 +30,7 @@ EOD
# --------------------------------------------------------------------------- #
-my $ui_file = 'tmp.ui';
+my $ui_file = "$dir/tmp.ui";
open my $fh, '>', $ui_file or plan skip_all => 'unable to create ui file';
print $fh $ui;
@@ -83,8 +86,6 @@ SKIP: {
like ($@, qr/bla/);
}
-unlink $ui_file;
-
# --------------------------------------------------------------------------- #
$builder = Gtk2::Builder->new;
diff --git a/t/GtkPageSetup.t b/t/GtkPageSetup.t
index 4c8e562..d88d1e8 100644
--- a/t/GtkPageSetup.t
+++ b/t/GtkPageSetup.t
@@ -6,6 +6,9 @@ use Gtk2::TestHelper
# $Id$
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
my $setup = Gtk2::PageSetup -> new();
isa_ok($setup, "Gtk2::PageSetup");
@@ -43,7 +46,7 @@ SKIP: {
my $new_setup;
$setup -> set_top_margin(23, 'mm');
- my $file = 'tmp.setup';
+ my $file = "$dir/tmp.setup";
eval {
$setup -> to_file($file);
@@ -73,14 +76,13 @@ SKIP: {
isa_ok($new_setup, 'Gtk2::PageSetup');
is($new_setup -> get_top_margin('mm'), 23);
- unlink $file;
}
SKIP: {
skip 'new 2.14 stuff', 5
unless Gtk2->CHECK_VERSION(2, 14, 0);
- my $file = 'tmp.setup';
+ my $file = "$dir/tmp.setup";
my $setup = Gtk2::PageSetup -> new();
$setup -> set_top_margin(23, 'mm');
@@ -110,7 +112,6 @@ SKIP: {
is($@, '');
is($copy -> get_top_margin('mm'), 23);
- unlink $file;
}
__END__
diff --git a/t/GtkPrintContext.t b/t/GtkPrintContext.t
index 4f1f13e..50b9891 100644
--- a/t/GtkPrintContext.t
+++ b/t/GtkPrintContext.t
@@ -6,6 +6,9 @@ use Gtk2::TestHelper
# $Id$
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
# I hope that signal will always fire ...
my $op = Gtk2::PrintOperation -> new();
@@ -37,13 +40,11 @@ $op -> signal_connect(begin_print => sub {
$op -> set_n_pages(1);
$op -> set_allow_async(TRUE);
-$op -> set_export_filename("test.pdf");
+$op -> set_export_filename("$dir/test.pdf");
$op -> run("export", undef);
$op -> cancel();
-unlink "test.pdf";
-
__END__
Copyright (C) 2006 by the gtk2-perl team (see the file AUTHORS for the
diff --git a/t/GtkPrintOperation.t b/t/GtkPrintOperation.t
index fb5c508..ddcff51 100644
--- a/t/GtkPrintOperation.t
+++ b/t/GtkPrintOperation.t
@@ -6,6 +6,9 @@ use Gtk2::TestHelper
# $Id$
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
my $op = Gtk2::PrintOperation -> new();
isa_ok($op, "Gtk2::PrintOperation");
@@ -32,7 +35,7 @@ sub get_op {
$op -> set_current_page(1);
$op -> set_use_full_page(TRUE);
$op -> set_unit("mm");
- $op -> set_export_filename("test.pdf");
+ $op -> set_export_filename("$dir/test.pdf");
$op -> set_track_print_status(TRUE);
$op -> set_show_progress(FALSE);
$op -> set_allow_async(TRUE);
@@ -40,8 +43,6 @@ sub get_op {
return $op;
}
-END { unlink "test.pdf"; }
-
$op = get_op();
ok(defined $op -> run("export", undef));
$op -> cancel();
diff --git a/t/GtkPrintSettings.t b/t/GtkPrintSettings.t
index 2bd7a1d..ede461f 100644
--- a/t/GtkPrintSettings.t
+++ b/t/GtkPrintSettings.t
@@ -6,6 +6,9 @@ use Gtk2::TestHelper
# $Id$
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
my $settings = Gtk2::PrintSettings -> new();
isa_ok($settings, 'Gtk2::PrintSettings');
@@ -42,7 +45,7 @@ SKIP: {
$settings -> set($key, $value);
my $new_settings;
- my $file = 'tmp.settings';
+ my $file = "$dir/tmp.settings";
eval {
$settings -> to_file($file);
@@ -71,15 +74,13 @@ SKIP: {
is($@, '');
isa_ok($new_settings, 'Gtk2::PrintSettings');
is($new_settings -> get($key), $value);
-
- unlink $file;
}
SKIP: {
skip 'new 2.14 stuff', 5
unless Gtk2->CHECK_VERSION(2, 14, 0);
- my $file = 'tmp.settings';
+ my $file = "$dir/tmp.settings2";
my $settings = Gtk2::PrintSettings -> new();
$settings -> set($key, $value);
@@ -108,8 +109,6 @@ SKIP: {
};
is($@, '');
is($copy -> get($key), $value);
-
- unlink $file;
}
SKIP: {
diff --git a/t/GtkRecentChooser.t b/t/GtkRecentChooser.t
index c59614a..4fe3928 100644
--- a/t/GtkRecentChooser.t
+++ b/t/GtkRecentChooser.t
@@ -6,8 +6,10 @@ use Gtk2::TestHelper
# $Id$
-unlink "./test.xbel"; # in case of an aborted run
-my $manager = Glib::Object::new("Gtk2::RecentManager", filename => "./test.xbel");
+use File::Temp qw(tempdir);
+my $dir = tempdir(CLEANUP => 1);
+
+my $manager = Glib::Object::new("Gtk2::RecentManager", filename => "$dir/test.xbel");
my $chooser = Gtk2::RecentChooserWidget -> new_for_manager($manager);
isa_ok($chooser, "Gtk2::RecentChooser");
@@ -88,8 +90,6 @@ $chooser -> remove_filter($filter_one);
$chooser -> set_filter($filter_one);
is($chooser -> get_filter(), $filter_one);
-unlink "./test.xbel";
-
__END__
Copyright (C) 2006 by the gtk2-perl team (see the file AUTHORS for the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]