diff --git a/IDE/src/BuildContext.bf b/IDE/src/BuildContext.bf index 4616e365..d0872d64 100644 --- a/IDE/src/BuildContext.bf +++ b/IDE/src/BuildContext.bf @@ -191,11 +191,8 @@ namespace IDE //String error = scope String(); - TestManager.ProjectInfo testProjectInfo = null; - if (gApp.mTestManager != null) - testProjectInfo = gApp.mTestManager.GetProjectInfo(project); - - bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); + bool isTest = options.mBuildOptions.mBuildKind == .Test; + bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest); if (!isExe) return true; @@ -308,11 +305,8 @@ namespace IDE //String error = scope String(); - TestManager.ProjectInfo testProjectInfo = null; - if (gApp.mTestManager != null) - testProjectInfo = gApp.mTestManager.GetProjectInfo(project); - - bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); + bool isTest = options.mBuildOptions.mBuildKind == .Test; + bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest); bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib; if (isExe || isDynLib) @@ -535,11 +529,8 @@ namespace IDE //String error = scope String(); - TestManager.ProjectInfo testProjectInfo = null; - if (gApp.mTestManager != null) - testProjectInfo = gApp.mTestManager.GetProjectInfo(project); - - bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); + bool isTest = options.mBuildOptions.mBuildKind == .Test; + bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest); bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib; if (isExe || isDynLib) @@ -811,11 +802,8 @@ namespace IDE IDEUtils.FixFilePath(llvmDir); llvmDir.Append("llvm/"); - TestManager.ProjectInfo testProjectInfo = null; - if (gApp.mTestManager != null) - testProjectInfo = gApp.mTestManager.GetProjectInfo(project); - - bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null); + bool isTest = options.mBuildOptions.mBuildKind == .Test; + bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest); if (isExe) { String linkLine = scope String(); @@ -824,7 +812,7 @@ namespace IDE IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); linkLine.Append(" "); - if (testProjectInfo != null) + if (isTest) linkLine.Append("-subsystem:console "); else if (project.mGeneralOptions.mTargetType == .BeefGUIApplication) linkLine.Append("-subsystem:windows "); diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index e72ce7eb..65168e25 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -10249,6 +10249,12 @@ namespace IDE } } + if ((mWorkspace.mStartupProject != null) && (mWorkspace.mStartupProject.mGeneralOptions.mTargetType == .BeefTest)) + { + OutputErrorLine("Test project '{}' has been selected as the Startup Project. Use the 'Test' menu to run or debug tests.", mWorkspace.mStartupProject.mProjectName); + return false; + } + let platform = Workspace.PlatformType.GetFromName(mPlatformName); let hostPlatform = Workspace.PlatformType.GetHostPlatform(); if (platform == .Unknown) @@ -10382,7 +10388,7 @@ namespace IDE { if (workspaceOptions.mBuildKind == .Test) { - OutputErrorLine("Cannot directly run Test workspace configurations. Use the 'Test' menu to run or debug tests."); + OutputErrorLine("Cannot directly run Test workspace configurations. Use the 'Test' menu to run or debug tests."); return false; } } diff --git a/IDE/src/Project.bf b/IDE/src/Project.bf index 45d1aa74..efda4d9e 100644 --- a/IDE/src/Project.bf +++ b/IDE/src/Project.bf @@ -892,9 +892,9 @@ namespace IDE BeefLib, BeefDynLib, CustomBuild, + BeefTest, C_ConsoleApplication, C_GUIApplication, - BeefTest, BeefApplication_StaticLib, BeefApplication_DynamicLib; diff --git a/IDE/src/TestManager.bf b/IDE/src/TestManager.bf index 856503b3..3af1db36 100644 --- a/IDE/src/TestManager.bf +++ b/IDE/src/TestManager.bf @@ -362,7 +362,11 @@ namespace IDE } else if (testInstance.mTestEntries.IsEmpty) { - QueueOutputLine("WARNING: No test methods defined. Consider adding a [Test] attribute to a static method in a project whose build type is set to 'Test'."); + QueueOutputLine( + """ + WARNING: No test methods defined. Consider adding a [Test] attribute to a static method in a project whose build type is set to 'Test'. + If you do have test methods defined, make sure the Workspace properties has that project's 'Test' configuration selected. + """); } } diff --git a/IDE/src/Workspace.bf b/IDE/src/Workspace.bf index 2c220915..9e6db342 100644 --- a/IDE/src/Workspace.bf +++ b/IDE/src/Workspace.bf @@ -263,14 +263,6 @@ namespace IDE #endif } } - - public bool IsTestProject(Project project) - { - return ((mBuildKind == .Test) && - ((project.mGeneralOptions.mTargetType == .BeefConsoleApplication) || - (project.mGeneralOptions.mTargetType == .BeefGUIApplication) || - (project.mGeneralOptions.mTargetType == .BeefConsoleApplication))); - } public void CopyFrom(Workspace.Options prev) { @@ -686,16 +678,33 @@ namespace IDE for (var configPair in options.mConfigSelections) { let projectName = configPair.key.mProjectName; - using (data.CreateObject(projectName)) - { - String expectConfig = configName; - if (isTest) - { - if (projectName != mProjects[0].mProjectName) - expectConfig = "Debug"; - } + + var configSelection = configPair.value; + bool wantEntry = configSelection.mEnabled != true; + wantEntry |= configSelection.mPlatform != platformName; - var configSelection = configPair.value; + String expectConfig = configName; + if (isTest) + { + if (projectName != mProjects[0].mProjectName) + expectConfig = "Debug"; + + if (!wantEntry) + { + // If we are leaving this entry blank and we have the 'Test' type set for an explicitly-test project + // then just skip the whole entry + var project = FindProject(projectName); + if ((project != null) && (project.mGeneralOptions.mTargetType == .BeefTest) && (configName == "Test")) + continue; + } + } + wantEntry |= configSelection.mConfig != expectConfig; + + if (!wantEntry) + continue; + + using (data.CreateObject(projectName)) + { data.ConditionalAdd("Enabled", configSelection.mEnabled, true); data.ConditionalAdd("Config", configSelection.mConfig, expectConfig); data.ConditionalAdd("Platform", configSelection.mPlatform, platformName); @@ -1110,7 +1119,8 @@ namespace IDE if (isTest) { - if (project != mProjects[0]) + if ((project != mProjects[0]) && + (project.mGeneralOptions.mTargetType != .BeefTest)) { findConfig = "Debug"; } diff --git a/IDE/src/ui/NewProjectDialog.bf b/IDE/src/ui/NewProjectDialog.bf index 8b84ceda..06a1ed2a 100644 --- a/IDE/src/ui/NewProjectDialog.bf +++ b/IDE/src/ui/NewProjectDialog.bf @@ -16,12 +16,13 @@ namespace IDE.ui public PathEditWidget mDirectoryEdit; public EditWidget mNameEdit; public DarkComboBox mTargetComboBox; - static String[5] sApplicationTypeNames = + static String[6] sApplicationTypeNames = .("Console Application", "GUI Application", "Library", "Dynamic Library", - "Custom Build"); + "Custom Build", + "Test"); public bool mNameChanged; public String mDirBase ~ delete _; diff --git a/IDE/src/ui/ProjectProperties.bf b/IDE/src/ui/ProjectProperties.bf index 0e749041..8a01e2ba 100644 --- a/IDE/src/ui/ProjectProperties.bf +++ b/IDE/src/ui/ProjectProperties.bf @@ -623,7 +623,8 @@ namespace IDE.ui "GUI Application", "Library", "Dynamic Library", - "Custom Build" + "Custom Build", + "Test" )); AddPropertiesItem(root, "Project Name Aliases", "mAliases"); } diff --git a/IDEHelper/Compiler/BfSystem.h b/IDEHelper/Compiler/BfSystem.h index 7b244ed8..bbc97511 100644 --- a/IDEHelper/Compiler/BfSystem.h +++ b/IDEHelper/Compiler/BfSystem.h @@ -1028,9 +1028,9 @@ enum BfTargetType BfTargetType_BeefLib, BfTargetType_BeefDynLib, BfTargetType_CustomBuild, - BfTargetType_C_ConsoleApplication, - BfTargetType_C_WindowsApplication, BfTargetType_BeefTest, + BfTargetType_C_ConsoleApplication, + BfTargetType_C_WindowsApplication, BfTargetType_BeefApplication_StaticLib, BfTargetType_BeefApplication_DynamicLib };