1 module tests.make;
2 
3 import unit_threaded;
4 import reggae;
5 
6 
7 void testMakefileNoPath() {
8     const build = Build(Target("leapp",
9                                "dmd -ofleapp objs/leapp.objs/foo.o objs/leapp.objs/bar.o",
10                                [Target("foo.o", "dmd -c -ofobjs/leapp.objs/foo.o foo.d", [Target("foo.d")]),
11                                 Target("bar.o", "dmd -c -ofobjs/leapp.objs/bar.o bar.d", [Target("bar.d")])],
12                             ));
13     auto backend = Makefile(build);
14     backend.fileName.shouldEqual("Makefile");
15     backend.simpleOutput.shouldEqual(
16         "all: leapp\n"
17         "objs/leapp.objs/foo.o: foo.d Makefile\n"
18         "\tdmd -c -ofobjs/leapp.objs/foo.o foo.d\n"
19         "objs/leapp.objs/bar.o: bar.d Makefile\n"
20         "\tdmd -c -ofobjs/leapp.objs/bar.o bar.d\n"
21         "leapp: objs/leapp.objs/foo.o objs/leapp.objs/bar.o Makefile\n"
22         "\tdmd -ofleapp objs/leapp.objs/foo.o objs/leapp.objs/bar.o\n"
23         );
24 }
25 
26 
27 void testMakefilePath() {
28     const build = Build(Target("otherapp",
29                                "gcc -o $out $in",
30                                [Target("boo.o", "gcc -c -o $out $in", [Target("boo.c")]),
31                                 Target("baz.o", "gcc -c -o $out $in", [Target("baz.c")])],
32                             ));
33     auto backend = Makefile(build, "/global/path/to/");
34     backend.fileName.shouldEqual("Makefile");
35     backend.simpleOutput.shouldEqual(
36         "all: otherapp\n"
37         "objs/otherapp.objs/boo.o: /global/path/to/boo.c Makefile\n"
38         "\tgcc -c -o objs/otherapp.objs/boo.o /global/path/to/boo.c\n"
39         "objs/otherapp.objs/baz.o: /global/path/to/baz.c Makefile\n"
40         "\tgcc -c -o objs/otherapp.objs/baz.o /global/path/to/baz.c\n"
41         "otherapp: objs/otherapp.objs/boo.o objs/otherapp.objs/baz.o Makefile\n"
42         "\tgcc -o otherapp objs/otherapp.objs/boo.o objs/otherapp.objs/baz.o\n"
43         );
44 }
45 
46 
47 void testImplicitDependencies() {
48     const target = Target("foo.o", "gcc -o $out -c $in", [Target("foo.c")], [Target("foo.h")]);
49     const make = Makefile(Build(target));
50     make.simpleOutput.shouldEqual(
51         "all: foo.o\n"
52         "foo.o: foo.c foo.h Makefile\n"
53         "\tgcc -o foo.o -c foo.c\n"
54         );
55 }