1 module tests.ut.json_build.simple; 2 3 4 import reggae; 5 import reggae.json_build; 6 import unit_threaded; 7 8 9 immutable fooObjJson = ` 10 [ 11 { 12 "type": "fixed", 13 "outputs": ["foo.o"], 14 "command": {"type": "shell", "cmd": "dmd -of$out -c $in"}, 15 "dependencies": { 16 "type": "fixed", 17 "targets": [ 18 {"type": "fixed", 19 "outputs": ["foo.d"], 20 "command": {}, 21 "dependencies": {"type": "fixed", "targets": []}, 22 "implicits": {"type": "fixed", "targets": []}}]}, 23 "implicits": {"type": "fixed", "targets": []} 24 } 25 ]`; 26 27 void testFooObj() { 28 jsonToBuild("", fooObjJson).shouldEqual( 29 Build(Target("foo.o", "dmd -of$out -c $in", Target("foo.d")))); 30 } 31 32 33 immutable optionalJson = ` 34 [ 35 { 36 "type": "fixed", 37 "outputs": ["foo.o"], 38 "command": {"type": "shell", "cmd": "dmd -of$out -c $in"}, 39 "dependencies": { 40 "type": "fixed", 41 "targets": [ 42 {"type": "fixed", 43 "outputs": ["foo.d"], 44 "command": {}, 45 "dependencies": {"type": "fixed", "targets": []}, 46 "implicits": {"type": "fixed", "targets": []}}]}, 47 "implicits": {"type": "fixed", "targets": []} 48 }, 49 { 50 "type": "fixed", 51 "outputs": ["bar.o"], 52 "command": {"type": "shell", "cmd": "dmd -of$out -c $in"}, 53 "dependencies": { 54 "type": "fixed", 55 "targets": [ 56 {"type": "fixed", 57 "outputs": ["bar.d"], 58 "command": {}, 59 "dependencies": {"type": "fixed", "targets": []}, 60 "implicits": {"type": "fixed", "targets": []}}]}, 61 "implicits": {"type": "fixed", "targets": []}, 62 "optional": true 63 } 64 ] 65 `; 66 67 @("Optional target") 68 unittest { 69 jsonToBuild("", optionalJson).shouldEqual( 70 Build(Target("foo.o", "dmd -of$out -c $in", Target("foo.d")), 71 optional(Target("bar.o", "dmd -of$out -c $in", Target("bar.d"))))); 72 } 73 74 immutable fooObjJson2 = ` 75 { 76 "version": 1, 77 "defaultOptions": {}, 78 "dependencies": [], 79 "build": [ 80 { 81 "type": "fixed", 82 "outputs": ["foo.o"], 83 "command": {"type": "shell", "cmd": "dmd -of$out -c $in"}, 84 "dependencies": { 85 "type": "fixed", 86 "targets": [ 87 {"type": "fixed", 88 "outputs": ["foo.d"], 89 "command": {}, 90 "dependencies": {"type": "fixed", "targets": []}, 91 "implicits": {"type": "fixed", "targets": []}}]}, 92 "implicits": {"type": "fixed", "targets": []} 93 } 94 ] 95 } 96 `; 97 98 99 @("version2") 100 unittest { 101 jsonToBuild("", fooObjJson2).shouldEqual( 102 Build(Target("foo.o", "dmd -of$out -c $in", Target("foo.d")))); 103 }