Skip to content

Commit

Permalink
Merge pull request #33 from shoo/fix_issue32
Browse files Browse the repository at this point in the history
Fix #32 - The config option will be ignored.
  • Loading branch information
shoo authored Sep 3, 2021
2 parents 3288e97 + 6196249 commit 8178d5f
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 4 deletions.
4 changes: 4 additions & 0 deletions scripts/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ void integrationTest(string[] exDubOpts = null)
writeln("#######################################");
foreach (pkgName; Defines.subPkgs)
{
// ターゲット指定がある場合は、ターゲット指定されている場合だけ実行
if (config.integrationTestTargets.length > 0
&& !config.integrationTestTargets.canFind("::" ~ pkgName))
continue;
dispLog("INFO", pkgName, "Subpackages test start");
auto res = Result(pkgName);
try
Expand Down
47 changes: 43 additions & 4 deletions source/gendoc/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ struct PackageConfig
///
PackageConfig[] subPackages;

private static string determineConfigName(Package pkg, BuildPlatform platform, string configName)
{
import std.algorithm: canFind;
import std.exception: enforce;
auto allCfgs = pkg.getPlatformConfigurations(platform, true);
if (configName.length > 0)
{
enforce(allCfgs.canFind(configName), "Cannot found configuration: " ~ configName);
return configName;
}
if (allCfgs.canFind("gendoc"))
return "gendoc";
return pkg.getDefaultConfiguration(platform, true);
}

/***************************************************************************
*
*/
Expand Down Expand Up @@ -54,10 +69,7 @@ struct PackageConfig
auto buildPlatform = compilerData.determinePlatform(buildSettings, compiler, archType);

GeneratorSettings settings;
if (pkg)
settings.config = pkg.getDefaultConfiguration(buildPlatform);
else
settings.config = dub.project.getDefaultConfiguration(buildPlatform);
settings.config = determineConfigName(pkg ? pkg : dub.project.rootPackage, buildPlatform, configName);
settings.force = true;
settings.buildType = buildType;
settings.compiler = compilerData;
Expand Down Expand Up @@ -138,6 +150,33 @@ struct PackageConfig
cfg.loadPackage("testcases/case002", "x86_64", "debug", null, compiler);
}
}

@system unittest
{
import std.file;
import std.path;
import std.algorithm;
import std.array;
if ("testcases/issue32".exists)
{
PackageConfig cfg;
string compiler;
cfg.loadPackage("testcases/issue32", "x86_64", "debug", "valid", compiler);
assert(cfg.files.length == 1);
assert(cfg.subPackages.length == 1);
assert(cfg.subPackages[0].name == "issue32:subpkg");
assert(cfg.subPackages[0].files.length == 2);
assert(cfg.subPackages[0].files.map!(a => a.baseName).array.sort().equal(["foo.d", "lib.d"]));

cfg = PackageConfig.init;
cfg.loadPackage("testcases/issue32", "x86_64", "debug", null, compiler);
assert(cfg.files.length == 1);
assert(cfg.subPackages.length == 1);
assert(cfg.subPackages[0].name == "issue32:subpkg");
assert(cfg.subPackages[0].files.length == 2);
assert(cfg.subPackages[0].files.map!(a => a.baseName).array.sort().equal(["bar.d", "lib.d"]));
}
}
}

private string _getHomeDirectory()
Expand Down
Empty file added testcases/issue32/.no_build
Empty file.
Empty file added testcases/issue32/.no_test
Empty file.
19 changes: 19 additions & 0 deletions testcases/issue32/.run_opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"name": "normal",
"dubWorkDir": "${project_root}",
"workDir": "${test_dir}",
"args": [
"--config=valid",
"--root=${test_dir}"
]
},
{
"name": "default_gendoc",
"dubWorkDir": "${project_root}",
"workDir": "${test_dir}",
"args": [
"--root=${test_dir}"
]
}
]
20 changes: 20 additions & 0 deletions testcases/issue32/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "issue32",
"subPackages": [
"subpkg"
],
"configurations": [
{
"name": "default",
"versions": ["Hoge"]
},
{
"name": "valid",
"versions": ["Foo"]
},
{
"name": "gendoc",
"versions": ["Bar"]
}
]
}
9 changes: 9 additions & 0 deletions testcases/issue32/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import std.stdio;

version (Hoge)
{
static assert(0, "The default configuration was selected.");
}
void main()
{
}
19 changes: 19 additions & 0 deletions testcases/issue32/subpkg/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "subpkg",
"configurations": [
{
"name": "default",
"versions": ["Hoge"]
},
{
"name": "valid",
"versions": ["Foo"],
"sourcePaths": ["source", "source_foo"]
},
{
"name": "gendoc",
"versions": ["Bar"],
"sourcePaths": ["source", "source_bar"]
}
]
}
7 changes: 7 additions & 0 deletions testcases/issue32/subpkg/source/lib.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module lib;

version (Hoge)
static assert(0, "The default configuration was selected.");
void hoge()
{
}
6 changes: 6 additions & 0 deletions testcases/issue32/subpkg/source_bar/bar.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module bar;

void bar()
{

}
6 changes: 6 additions & 0 deletions testcases/issue32/subpkg/source_foo/foo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module foo;

void foo()
{

}

0 comments on commit 8178d5f

Please sign in to comment.