diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 3fa87b2..81d054d 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -1182,16 +1182,8 @@ gensettings.single = m_single; logDiagnostic("Generating using %s", m_generator); - - // With an explicitly requested `unittest` config, switch to the special test - // runner config (which doesn't require an existing `unittest` configuration). - if (m_buildConfig == "unittest") - dub.testProject(m_generator, gensettings, null, NativePath()); - else - dub.generateProject(m_generator, gensettings); - + dub.generateProject(m_generator, gensettings); if (m_buildType == "ddox") dub.runDdox(gensettings.run, app_args); - return 0; } } @@ -1412,7 +1404,7 @@ settings.runArgs = app_args; settings.single = m_single; - dub.testProject("build", settings, m_buildConfig, NativePath(m_mainFile)); + dub.testProject(settings, m_buildConfig, NativePath(m_mainFile)); return 0; } } diff --git a/source/dub/dub.d b/source/dub/dub.d index ed1f337..833aa65 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -641,6 +641,13 @@ */ void generateProject(string ide, GeneratorSettings settings) { + // With a requested `unittest` config, switch to the special test runner + // config (which doesn't require an existing `unittest` configuration). + if (settings.config == "unittest") { + const test_config = m_project.addTestRunnerConfiguration(settings, !m_dryRun); + if (test_config) settings.config = test_config; + } + auto generator = createProjectGenerator(ide, m_project); if (m_dryRun) return; // TODO: pass m_dryRun to the generator generator.generate(settings); @@ -650,7 +657,7 @@ Any existing project files will be overridden. */ - void testProject(string ide, GeneratorSettings settings, string config, NativePath custom_main_file) + void testProject(GeneratorSettings settings, string config, NativePath custom_main_file) { if (!custom_main_file.empty && !custom_main_file.absolute) custom_main_file = getWorkingDirectory() ~ custom_main_file; @@ -659,8 +666,7 @@ settings.config = test_config; - auto generator = createProjectGenerator(ide, m_project); - if (m_dryRun) return; // TODO: pass m_dryRun to the generator + auto generator = createProjectGenerator("build", m_project); generator.generate(settings); }