1 module tests.high_rules;
2 
3 
4 import reggae;
5 import unit_threaded;
6 
7 
8 void testCObjectFile() {
9     immutable fileName = "foo.c";
10     const obj = objectFile(fileName, "-g -O0", ["myhdrs", "otherhdrs"]);
11     const cmd = Command(CommandType.compile,
12                         assocListT("includes", ["-I$project/myhdrs", "-I$project/otherhdrs"],
13                                    "flags", ["-g", "-O0"],
14                                    "DEPFILE", ["$out.dep"]));
15 
16     obj.shouldEqual(Target("foo.o", cmd, [Target(fileName)]));
17 
18 }
19 
20 void testCppObjectFile() {
21     foreach(ext; ["cpp", "CPP", "cc", "cxx", "C", "c++"]) {
22         immutable fileName = "foo." ~ ext;
23         const obj = objectFile(fileName, "-g -O0", ["myhdrs", "otherhdrs"]);
24         const cmd = Command(CommandType.compile,
25                             assocListT("includes", ["-I$project/myhdrs", "-I$project/otherhdrs"],
26                                        "flags", ["-g", "-O0"],
27                                        "DEPFILE", ["$out.dep"]));
28 
29         obj.shouldEqual(Target("foo.o", cmd, [Target(fileName)]));
30     }
31 }
32 
33 
34 void testDObjectFile() {
35     const obj = objectFile("foo.d", "-g -debug", ["myhdrs", "otherhdrs"], ["strings", "otherstrings"]);
36     const cmd = Command(CommandType.compile,
37                         assocListT("includes", ["-I$project/myhdrs", "-I$project/otherhdrs"],
38                                    "flags", ["-g", "-debug"],
39                                    "stringImports", ["-J$project/strings", "-J$project/otherstrings"],
40                                    "DEPFILE", ["$out.dep"]));
41 
42     obj.shouldEqual(Target("foo.o", cmd, [Target("foo.d")]));
43 }
44 
45 
46 void testBuiltinTemplateDeps() {
47     Command.builtinTemplate(CommandType.compile, Language.C).shouldEqual(
48         "gcc $flags $includes -MMD -MT $out -MF $DEPFILE -o $out -c $in");
49 
50     Command.builtinTemplate(CommandType.compile, Language.D).shouldEqual(
51         ".reggae/dcompile --objFile=$out --depFile=$DEPFILE " ~
52          "dmd $flags $includes $stringImports $in");
53 
54 }
55 
56 void testBuiltinTemplateNoDeps() {
57     Command.builtinTemplate(CommandType.compile, Language.C, No.dependencies).shouldEqual(
58         "gcc $flags $includes -o $out -c $in");
59 
60     Command.builtinTemplate(CommandType.compile, Language.D, No.dependencies).shouldEqual(
61         "dmd $flags $includes $stringImports -of$out -c $in");
62 
63 }