1#! /usr/bin/env perl
2#
3#	Compile a single executable from a single .c file in the
4#	local directory.  Update the source and recompile.
5#
6
7# $Id: t0001.t,v 1.5 2000/09/10 05:01:27 knight Exp $
8
9# Copyright (c) 1996-2000 Free Software Foundation, Inc.
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; see the file COPYING.  If not, write to
23# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24# Boston, MA 02111-1307, USA.
25
26use Test::Cmd::Cons qw($_exe);
27
28$test = Test::Cmd::Cons->new(string => 'single-module Program');
29
30#
31$foo_exe = "foo$_exe";
32
33#
34$test->write("Construct", <<_EOF_);
35\$env = new cons ( ${\$test->cons_env} );
36Program \$env '$foo_exe', 'foo.c';
37_EOF_
38
39$test->write("foo.c", <<'_EOF_');
40main(int argc, char *argv[])
41{
42	printf("foo.c #1\n");
43	exit (0);
44}
45_EOF_
46
47#
48$test->run(targets => ".");
49
50$test->execute(prog => 'foo', stdout => <<_EOF_);
51foo.c #1
52_EOF_
53
54#
55$test->write("Construct", <<_EOF_);
56\$env = new cons ( ${\$test->cons_env} );
57Program \$env 'foo', 'foo.c';
58_EOF_
59
60$test->up_to_date(targets => ".");
61
62#
63$test->write("foo.c", <<'_EOF_');
64int
65main(int argc, char *argv[])
66{
67	printf("foo.c #2\n");
68	exit (0);
69}
70_EOF_
71#
72$test->run(targets => ".");
73
74$test->execute(prog => 'foo', stdout => <<_EOF_);
75foo.c #2
76_EOF_
77
78#
79$test->write("Construct", <<_EOF_);
80\$env = new cons ( ${\$test->cons_env} );
81Program \$env 'foo%SUFEXE', 'foo.c';
82_EOF_
83
84$test->up_to_date(targets => ".");
85
86#
87$test->write("foo.c", <<'_EOF_');
88int
89main(int argc, char *argv[])
90{
91	printf("foo.c #3\n");
92	exit (0);
93}
94_EOF_
95#
96$test->run(targets => ".");
97
98$test->execute(prog => 'foo', stdout => <<_EOF_);
99foo.c #3
100_EOF_
101
102#
103$test->pass;
104__END__
105