1 module dud.pkgdescription.platformselectiontest; 2 3 import std.stdio; 4 import std.range : tee; 5 import std.format; 6 7 import dud.pkgdescription; 8 import dud.pkgdescription.joining; 9 import dud.pkgdescription.sdl; 10 import dud.pkgdescription.output; 11 import dud.pkgdescription.platformselection; 12 13 unittest { 14 string input = ` 15 name "pkgdescription" 16 dependency "semver" path="../semver" 17 dependency "semver" path="../semver" version=">=1.0.0" platform="posix" 18 dependency "semver" path="../semver" version=">=2.0.0" platform="android" 19 dependency "path" path="../path" platform="windows" 20 dependency "sdlang" path="../sdlang" 21 dependency "graphqld" version=">=1.0.0" default=true optional=false 22 targetType "library" 23 targetName "foobar" 24 preGenerateCommands "rm -rf /" "install windows" platform="posix" 25 preGenerateCommands "format C:" "install linux" platform="windows" 26 targetPath "outDir" 27 importPaths "source_win" "source1_win" "source2_win" platform="windows" 28 importPaths "source_pos86" "source1_pos86" "source2_pos86" platform="posix-x86" 29 importPaths "source_pos" "source1_pos" "source2_pos" platform="posix" 30 buildRequirements "allowWarnings" "disallowInlining" platform="windows" 31 buildRequirements "allowWarnings" platform="posix" 32 subConfiguration "semver" "subConf_posix" platform="posix" 33 subConfiguration "semver" "subConf_windows" platform="windows" 34 subConfiguration "graphql" "the_fast_version" 35 license "LGPL3" 36 configuration "test-win" { 37 platforms "windows" 38 libs "libc" 39 } 40 configuration "test-posix" { 41 platforms "posix" 42 libs "glibc" 43 } 44 `; 45 46 string inputPosixExp = ` 47 name "pkgdescription" 48 dependency "semver" path="../semver" version=">=1.0.0" 49 dependency "sdlang" path="../sdlang" 50 dependency "graphqld" version=">=1.0.0" default=true optional=false 51 targetType "library" 52 targetName "foobar" 53 preGenerateCommands "rm -rf /" "install windows" 54 targetPath "outDir" 55 importPaths "source_pos" "source1_pos" "source2_pos" 56 buildRequirements "allowWarnings" 57 subConfiguration "semver" "subConf_posix" 58 subConfiguration "graphql" "the_fast_version" 59 license "LGPL3" 60 libs "glibc" 61 `; 62 63 PackageDescription pkg = sdlToPackageDescription(input); 64 PackageDescription afterExpands = pkg.expandConfiguration("test-posix"); 65 PackageDescriptionNoPlatform posix = afterExpands.select([Platform.posix]); 66 writeln(afterExpands); 67 68 PackageDescription posixExp = sdlToPackageDescription(inputPosixExp); 69 PackageDescriptionNoPlatform posixExpNP = posixExp 70 .select([]); 71 string output = toSDL(afterExpands); 72 writeln(output); 73 74 assert(posix == posixExpNP, 75 format("\ngot:\n%s\nexp:\n%s", posix, posixExpNP)); 76 77 //PackageDescriptionNoPlatform win = pkg 78 // .expandConfiguration("test-win") 79 // .select([Platform.windows]); 80 //writeln(win); 81 }