-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66ccf0d
commit 0ea5430
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.IO; | ||
using System.Runtime.CompilerServices; | ||
using UnityEditor; | ||
using UnityEditor.Build.Player; | ||
|
||
namespace MinimalUtility.Editor | ||
{ | ||
/// <summary> | ||
/// テスト関連のユーティリティ. | ||
/// </summary> | ||
public static class TestUtils | ||
{ | ||
/// <summary> | ||
/// 指定したビルドターゲットでスクリプトをコンパイルし、成功したかどうかを返す. | ||
/// </summary> | ||
/// <param name="buildTarget">テスト対象環境.</param> | ||
/// <param name="outputPath">出力先パス.</param> | ||
/// <param name="scriptingDefines">スクリプト条件コンパイル定義があれば登録.</param> | ||
/// <returns>成功したかどうか.</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static bool SuccessCompile(BuildTarget buildTarget, string outputPath = "Temp/TestOutput", params string[] scriptingDefines) | ||
{ | ||
ScriptCompilationSettings settings = new () | ||
{ | ||
extraScriptingDefines = scriptingDefines, | ||
group = BuildPipeline.GetBuildTargetGroup(buildTarget), | ||
target = buildTarget, | ||
}; | ||
try | ||
{ | ||
ScriptCompilationResult result = PlayerBuildInterface.CompilePlayerScripts(settings, outputPath); | ||
return result is { assemblies: { Count: > 0 }, typeDB: not null }; | ||
} | ||
catch | ||
{ | ||
throw; | ||
} | ||
finally | ||
{ | ||
if (Directory.Exists(outputPath)) | ||
{ | ||
Directory.Delete(outputPath, true); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.