1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-15 06:44:10 +02:00

Made 'Test' a project type

This commit is contained in:
Brian Fiete 2020-09-27 22:20:26 -07:00
parent ee71c8c97b
commit 784bd6d374
8 changed files with 57 additions and 47 deletions

View file

@ -191,11 +191,8 @@ namespace IDE
//String error = scope String(); //String error = scope String();
TestManager.ProjectInfo testProjectInfo = null; bool isTest = options.mBuildOptions.mBuildKind == .Test;
if (gApp.mTestManager != null) bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
testProjectInfo = gApp.mTestManager.GetProjectInfo(project);
bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null);
if (!isExe) if (!isExe)
return true; return true;
@ -308,11 +305,8 @@ namespace IDE
//String error = scope String(); //String error = scope String();
TestManager.ProjectInfo testProjectInfo = null; bool isTest = options.mBuildOptions.mBuildKind == .Test;
if (gApp.mTestManager != null) bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
testProjectInfo = gApp.mTestManager.GetProjectInfo(project);
bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null);
bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib; bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib;
if (isExe || isDynLib) if (isExe || isDynLib)
@ -535,11 +529,8 @@ namespace IDE
//String error = scope String(); //String error = scope String();
TestManager.ProjectInfo testProjectInfo = null; bool isTest = options.mBuildOptions.mBuildKind == .Test;
if (gApp.mTestManager != null) bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
testProjectInfo = gApp.mTestManager.GetProjectInfo(project);
bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null);
bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib; bool isDynLib = project.mGeneralOptions.mTargetType == Project.TargetType.BeefDynLib;
if (isExe || isDynLib) if (isExe || isDynLib)
@ -811,11 +802,8 @@ namespace IDE
IDEUtils.FixFilePath(llvmDir); IDEUtils.FixFilePath(llvmDir);
llvmDir.Append("llvm/"); llvmDir.Append("llvm/");
TestManager.ProjectInfo testProjectInfo = null; bool isTest = options.mBuildOptions.mBuildKind == .Test;
if (gApp.mTestManager != null) bool isExe = ((project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) && (project.mGeneralOptions.mTargetType != Project.TargetType.BeefTest)) || (isTest);
testProjectInfo = gApp.mTestManager.GetProjectInfo(project);
bool isExe = (project.mGeneralOptions.mTargetType != Project.TargetType.BeefLib) || (testProjectInfo != null);
if (isExe) if (isExe)
{ {
String linkLine = scope String(); String linkLine = scope String();
@ -824,7 +812,7 @@ namespace IDE
IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath); IDEUtils.AppendWithOptionalQuotes(linkLine, targetPath);
linkLine.Append(" "); linkLine.Append(" ");
if (testProjectInfo != null) if (isTest)
linkLine.Append("-subsystem:console "); linkLine.Append("-subsystem:console ");
else if (project.mGeneralOptions.mTargetType == .BeefGUIApplication) else if (project.mGeneralOptions.mTargetType == .BeefGUIApplication)
linkLine.Append("-subsystem:windows "); linkLine.Append("-subsystem:windows ");

View file

@ -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 platform = Workspace.PlatformType.GetFromName(mPlatformName);
let hostPlatform = Workspace.PlatformType.GetHostPlatform(); let hostPlatform = Workspace.PlatformType.GetHostPlatform();
if (platform == .Unknown) if (platform == .Unknown)

View file

@ -892,9 +892,9 @@ namespace IDE
BeefLib, BeefLib,
BeefDynLib, BeefDynLib,
CustomBuild, CustomBuild,
BeefTest,
C_ConsoleApplication, C_ConsoleApplication,
C_GUIApplication, C_GUIApplication,
BeefTest,
BeefApplication_StaticLib, BeefApplication_StaticLib,
BeefApplication_DynamicLib; BeefApplication_DynamicLib;

View file

@ -362,7 +362,11 @@ namespace IDE
} }
else if (testInstance.mTestEntries.IsEmpty) 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.
""");
} }
} }

View file

@ -264,14 +264,6 @@ namespace IDE
} }
} }
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) public void CopyFrom(Workspace.Options prev)
{ {
mToolsetType = prev.mToolsetType; mToolsetType = prev.mToolsetType;
@ -686,16 +678,33 @@ namespace IDE
for (var configPair in options.mConfigSelections) for (var configPair in options.mConfigSelections)
{ {
let projectName = configPair.key.mProjectName; let projectName = configPair.key.mProjectName;
using (data.CreateObject(projectName))
{ var configSelection = configPair.value;
bool wantEntry = configSelection.mEnabled != true;
wantEntry |= configSelection.mPlatform != platformName;
String expectConfig = configName; String expectConfig = configName;
if (isTest) if (isTest)
{ {
if (projectName != mProjects[0].mProjectName) if (projectName != mProjects[0].mProjectName)
expectConfig = "Debug"; expectConfig = "Debug";
}
var configSelection = configPair.value; 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("Enabled", configSelection.mEnabled, true);
data.ConditionalAdd("Config", configSelection.mConfig, expectConfig); data.ConditionalAdd("Config", configSelection.mConfig, expectConfig);
data.ConditionalAdd("Platform", configSelection.mPlatform, platformName); data.ConditionalAdd("Platform", configSelection.mPlatform, platformName);
@ -1110,7 +1119,8 @@ namespace IDE
if (isTest) if (isTest)
{ {
if (project != mProjects[0]) if ((project != mProjects[0]) &&
(project.mGeneralOptions.mTargetType != .BeefTest))
{ {
findConfig = "Debug"; findConfig = "Debug";
} }

View file

@ -16,12 +16,13 @@ namespace IDE.ui
public PathEditWidget mDirectoryEdit; public PathEditWidget mDirectoryEdit;
public EditWidget mNameEdit; public EditWidget mNameEdit;
public DarkComboBox mTargetComboBox; public DarkComboBox mTargetComboBox;
static String[5] sApplicationTypeNames = static String[6] sApplicationTypeNames =
.("Console Application", .("Console Application",
"GUI Application", "GUI Application",
"Library", "Library",
"Dynamic Library", "Dynamic Library",
"Custom Build"); "Custom Build",
"Test");
public bool mNameChanged; public bool mNameChanged;
public String mDirBase ~ delete _; public String mDirBase ~ delete _;

View file

@ -623,7 +623,8 @@ namespace IDE.ui
"GUI Application", "GUI Application",
"Library", "Library",
"Dynamic Library", "Dynamic Library",
"Custom Build" "Custom Build",
"Test"
)); ));
AddPropertiesItem(root, "Project Name Aliases", "mAliases"); AddPropertiesItem(root, "Project Name Aliases", "mAliases");
} }

View file

@ -1028,9 +1028,9 @@ enum BfTargetType
BfTargetType_BeefLib, BfTargetType_BeefLib,
BfTargetType_BeefDynLib, BfTargetType_BeefDynLib,
BfTargetType_CustomBuild, BfTargetType_CustomBuild,
BfTargetType_BeefTest,
BfTargetType_C_ConsoleApplication, BfTargetType_C_ConsoleApplication,
BfTargetType_C_WindowsApplication, BfTargetType_C_WindowsApplication,
BfTargetType_BeefTest,
BfTargetType_BeefApplication_StaticLib, BfTargetType_BeefApplication_StaticLib,
BfTargetType_BeefApplication_DynamicLib BfTargetType_BeefApplication_DynamicLib
}; };