1 module tests.drules; 2 3 4 import reggae; 5 import unit_threaded; 6 import std.algorithm; 7 8 9 void testDCompileNoIncludePathsNinja() { 10 const build = Build(dCompile("path/to/src/foo.d")); 11 const ninja = Ninja(build, "/tmp/myproject"); 12 ninja.buildEntries.shouldEqual( 13 [NinjaEntry("build path/to/src/foo.o: _dcompile /tmp/myproject/path/to/src/foo.d", 14 ["includes = ", 15 "flags = ", 16 "stringImports = ", 17 "DEPFILE = path/to/src/foo.o.d"])]); 18 } 19 20 21 void testDCompileIncludePathsNinja() { 22 const build = Build(dCompile("path/to/src/foo.d", "-O", ["path/to/src", "other/path"])); 23 const ninja = Ninja(build, "/tmp/myproject"); 24 ninja.buildEntries.shouldEqual( 25 [NinjaEntry("build path/to/src/foo.o: _dcompile /tmp/myproject/path/to/src/foo.d", 26 ["includes = -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path", 27 "flags = -O", 28 "stringImports = ", 29 "DEPFILE = path/to/src/foo.o.d"])]); 30 } 31 32 void testDCompileIncludePathsMake() { 33 const build = Build(dCompile("path/to/src/foo.d", "-O", ["path/to/src", "other/path"])); 34 const make = Makefile(build, "/tmp/myproject"); 35 make.command(build.targets[0]).startsWith(".reggae/dcompile --objFile=path/to/src/foo.o --depFile=path/to/src/foo.o.d dmd -O -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path path/to/src/foo.d").shouldBeTrue; 36 } 37 38 39 void testDLinkNinja() { 40 const build = Build(dLink("bin/lefoo", [Target("leobj.o")], "-lib")); 41 const ninja = Ninja(build, "/dir/stuff"); 42 ninja.buildEntries.shouldEqual( 43 [NinjaEntry("build bin/lefoo: _dlink /dir/stuff/leobj.o", 44 ["flags = -lib"])]); 45 } 46 47 void testDCompileWithMultipleFilesMake() { 48 const build = Build(dCompilePerPackage(["path/to/src/foo.d", "path/to/src/bar.d", "other/weird.d"], 49 "-O", ["path/to/src", "other/path"])); 50 const make = Makefile(build, "/tmp/myproject"); 51 52 make.command(build.targets[0]).startsWith(".reggae/dcompile --objFile=other.o --depFile=other.o.d dmd -O -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path other/weird.d").shouldBeTrue; 53 54 make.command(build.targets[1]).startsWith(".reggae/dcompile --objFile=path/to/src.o --depFile=path/to/src.o.d dmd -O -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path path/to/src/foo.d path/to/src/bar.d").shouldBeTrue; 55 56 } 57 58 void testDCompileWithMultipleFilesNinja() { 59 const build = Build(dCompilePerPackage(["path/to/src/foo.d", "path/to/src/bar.d", "other/weird.d"], 60 "-O", ["path/to/src", "other/path"])); 61 const ninja = Ninja(build, "/tmp/myproject"); 62 63 ninja.buildEntries.shouldEqual( 64 [ 65 66 NinjaEntry("build other.o: _dcompile /tmp/myproject/other/weird.d", 67 ["includes = -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path", 68 "flags = -O", 69 "stringImports = ", 70 "DEPFILE = other.o.d"]), 71 72 NinjaEntry("build path/to/src.o: _dcompile /tmp/myproject/path/to/src/foo.d /tmp/myproject/path/to/src/bar.d", 73 ["includes = -I/tmp/myproject/path/to/src -I/tmp/myproject/other/path", 74 "flags = -O", 75 "stringImports = ", 76 "DEPFILE = path/to/src.o.d"]), 77 78 ]); 79 }