1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 14:24: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();
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 ");

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 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;
}
}

View file

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

View file

@ -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.
""");
}
}

View file

@ -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";
}

View file

@ -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 _;

View file

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

View file

@ -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
};