File: 03_run.t

package info (click to toggle)
libfile-desktopentry-perl 0.22-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 434; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,279 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;
use warnings;

use File::DesktopEntry;

$| = 1;
#$File::DesktopEntry::VERBOSE = 1;

# Because this test runs external processes we can not use Test::More.
# Parts taking place in external processes do not show in testcover

print "1..4\n";

my $perl = $^X;

my $entry = File::DesktopEntry->new();
$entry->set(
	Name => 'test',
	Type => 'Application',
	Exec => qq#"$perl" -e 'print "ok 1 - system() works\n"'#);
#warn ">>>\n", $entry->text(), "<<<\n";
$entry->system();

$entry->set(
	Exec => qq#"$perl" -e 'print "ok 2 - run() works\n"'#
);
my $pid = $entry->run();
if ($^O eq 'MSWin32') {
		$pid->Wait(&Win32::Process::INFINITE);
}
else { waitpid($pid, 0) }

$entry->set(
	Exec => qq#"$perl" -e 'print ""'#,
	Path => 't/applications'
);
$entry->system();
print( (-f 'MANIFEST' ? 'ok' : 'nok'),
	" 3 - directory reset properly when using Path\n" );

$entry->set(
	Exec => qq#"$perl" -e 'print( (-f "foo.desktop" ? "ok" : "nok"), " 4 - exec() works using Path\n")'#
);

if ($^O eq 'MSWin32') {
	print "ok 4 # skip fork() not supported\n";
}
else {
	# not sure why, but gives ugly result on Win32
	# probably due to fork() emulation
	$pid = fork;
	unless ($pid) {
		$entry->exec();
		print "nok 4"; # not supposed to make it this far
		exit 1;
	}
	waitpid($pid, 0);
}