1 module tests.it.buildgen; 2 3 4 public import tests.it; 5 import tests.utils; 6 7 8 private string projectToModule(in string project) { 9 return project ~ ".reggaefile"; 10 } 11 12 void generateBuild(string project)(string[] args = []) { 13 enum module_ = projectToModule(project); 14 auto options = _testProjectOptions!module_; 15 prepareTestBuild!module_(options); 16 17 // binary backend doesn't need to generate anything 18 if(options.backend != Backend.binary) { 19 auto cmdArgs = buildCmd(options, args); 20 doBuildFor!module_(options, cmdArgs); 21 } 22 } 23 24 25 // runs ninja, make, etc. in an integraton test 26 void shouldBuild(string project)(string[] args = [], 27 string file = __FILE__, 28 size_t line = __LINE__ ) { 29 import reggae.config; 30 enum module_ = projectToModule(project); 31 buildCmdShouldRunOk!module_(options, args, file, line); 32 } 33 34 35 // runs a command in the test sandbox, throws if it fails, 36 // returns the output 37 auto shouldSucceed(string[] args, string file = __FILE__, size_t line = __LINE__) { 38 import reggae.config; 39 import std.path; 40 return shouldExecuteOk(buildPath(options.workingDir, args[0]) ~ args[1..$], 41 options, file, line); 42 } 43 44 auto shouldSucceed(string arg, string file = __FILE__, size_t line = __LINE__) { 45 return shouldSucceed([arg], file, line); 46 } 47 48 49 // runs a command in the test sandbox, throws if it succeeds 50 void shouldFail(T)(T args, string file = __FILE__, size_t line = __LINE__) { 51 import reggae.config; 52 shouldFailToExecute(args, options.workingDir, file, line); 53 } 54 55 56 // read a file in the test sandbox and verify its contents 57 void shouldEqualLines(string fileName, string[] lines, 58 string file = __FILE__, size_t line = __LINE__) { 59 import reggae.config; 60 import std.file: readText; 61 import std.string: chomp, split; 62 import std.path: buildPath; 63 64 readText(buildPath(options.workingDir, fileName)).chomp.split("\n") 65 .shouldEqual(lines, file, line); 66 }