~ubuntu-branches/ubuntu/precise/padre/precise

« back to all changes in this revision

Viewing changes to t/04-config.t

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-05-08 09:17:22 UTC
  • mfrom: (1.2.1 upstream) (10.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100508091722-y6008jtk0ap6znyn
Tags: 0.60.ds1-3
rules: run tests with HOME=$fake_home to avoud failing when $HOME points
to a non-existent location. Closes: #579289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
 
3
3
use strict;
4
 
 
5
 
BEGIN {
6
 
        $|  = 1;
7
 
        $^W = 1;
8
 
 
9
 
}
10
 
 
11
 
use constant CONFIG_OPTIONS => 98;
 
4
use warnings;
 
5
use constant CONFIG_OPTIONS => 115;
12
6
 
13
7
# Move of Debug to Run Menu
14
 
use Test::More tests => CONFIG_OPTIONS * 2 + 17;
 
8
use Test::More tests => CONFIG_OPTIONS * 2 + 21;
15
9
use Test::NoWarnings;
16
10
use File::Spec::Functions ':ALL';
17
11
use File::Temp ();
22
16
use Padre::Constant ();
23
17
use Padre::Config   ();
24
18
 
 
19
# Loading the configuration subsystem should NOT result in loading Wx
 
20
is( $Wx::VERSION, undef, 'Wx was not loaded during config load' );
 
21
 
25
22
# Create the empty config file
26
23
my $empty = Padre::Constant::CONFIG_HUMAN;
27
 
open( FILE, '>', $empty ) or die "Failed to open $empty";
28
 
print FILE "--- {}\n";
29
 
close(FILE);
 
24
open( my $FILE, '>', $empty ) or die "Failed to open $empty";
 
25
print $FILE "--- {}\n";
 
26
close($FILE);
30
27
 
31
28
# Load the config
32
29
my $config = Padre::Config->read;
37
34
is( $config->host->version,  undef, '->host->version is undef' );
38
35
is( $config->human->version, undef, '->human->version is undef' );
39
36
 
 
37
# Loading the config file should not result in Wx loading
 
38
is( $Wx::VERSION, undef, 'Wx was not loaded during config read' );
 
39
 
40
40
# Check that the defaults work
41
41
my @names =
42
42
        sort { length($a) <=> length($b) or $a cmp $b } keys %Padre::Config::SETTING;
51
51
 
52
52
# The config version number is a requirement for every config and
53
53
# the only key which is allowed to live in an empty config.
54
 
my %Test_Config = ( Version => $Padre::Config::VERSION );
 
54
my %test_config = ( Version => $Padre::Config::VERSION );
55
55
 
56
56
# ... and that they don't leave a permanent state.
57
57
is_deeply(
58
 
        +{ %{ $config->human } }, \%Test_Config,
 
58
        +{ %{ $config->human } }, \%test_config,
59
59
        'Defaults do not leave permanent state (human)',
60
60
);
61
61
is_deeply(
62
 
        +{ %{ $config->host } }, \%Test_Config,
 
62
        +{ %{ $config->host } }, \%test_config,
63
63
        'Defaults do not leave permanent state (host)',
64
64
);
65
65
 
66
66
# Store the config again
67
67
ok( $config->write, '->write ok' );
68
68
 
 
69
# Saving the config file should not result in Wx loading
 
70
is( $Wx::VERSION, undef, 'Wx was not loaded during config write' );
 
71
 
69
72
# Check that we have a version for the parts now
70
73
is( $config->host->version,  1, '->host->version is set' );
71
74
is( $config->human->version, 1, '->human->version is set' );
86
89
 
87
90
# Confirm the config is round-trip safe
88
91
is_deeply( $config2, $config, 'Config round-trips ok' );
 
92
 
 
93
# No configuration operations require loading Wx
 
94
is( $Wx::VERSION, undef, 'Wx is never loaded during config operations' );