File: mtime-zero.t

package info (click to toggle)
libtemplate-perl 3.102-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,680 kB
  • sloc: perl: 14,945; makefile: 11; sh: 5
file content (45 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download
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
#============================================================= -*-perl-*-
#
# t/mtime-zero.t
#
# Test template process with . in INCLUDE_PATH
#
# Written by Nicolas R. <atoomic@cpan.org>
#
# Copyright (C) 2018 cPanel Inc.  All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id$
#
#========================================================================

use strict;
use warnings;

use Template;

use File::Temp qw(tempfile tempdir);

use Test::More tests => 4;

my $content = "hello, world\n";

my ( $tmpfh, $tmpfile ) = tempfile( UNLINK => 1 );
print $tmpfh $content;
close $tmpfh or die $!;

{
    my $out;
    ok( Template->new( { ABSOLUTE => 1 } )->process( $tmpfile, {}, \$out ), "process tmpfile" );
    is( $out, $content, "content as expected" );
}

{
    utime 0, 0, $tmpfile or die $!;

    my $out;
    ok( Template->new( { ABSOLUTE => 1 } )->process( $tmpfile, {}, \$out ), "process tmpfile [utime=0]" );
    is( $out, $content, "content as expected [utime=0]" );
}