public static void CheckForAndRunTest() { string TestName = Environment.GetEnvironmentVariable(MonsterTestCore.MonsterStarterTestNameEnvVariable); // MonsterDebug.Log("Checking for test " + TestName); if (TestName != null && TestName != "" && (TestRunnerInst == null || TestName != CurrentTestName)) { if (TestRunnerInst == null) { TestRunnerInst = new MonsterTestRunner(); } TestRunnerInst.PreloadTest(TestName); TestRunnerInst.StartTest(TestName); MonsterDebug.Log("Starting test " + TestName); CurrentTestName = TestName; } if (TestRunnerInst != null && TestRunnerInst.RunTests()) { MonsterDebug.Log("Finished running test " + TestName); Application.Quit(); } }
public virtual bool RunTest(string TestName) { MonsterDebug.Log("Attempting to run test " + TestName + " on a standalone copy of the game."); Environment.SetEnvironmentVariable(MonsterTestCore.MonsterStarterTestNameEnvVariable, TestName); string AppPath = ""; if (IgorJobConfig.IsStringParamSet(MonsterTestCore.ExplicitAppPathFlag)) { AppPath = IgorJobConfig.GetStringParam(MonsterTestCore.ExplicitAppPathFlag); } else { foreach (string CurrentProduct in IgorCore.GetModuleProducts()) { if (CurrentProduct.Contains(".app")) { AppPath = CurrentProduct.Substring(0, CurrentProduct.IndexOf(".app") + 4); } else if (CurrentProduct.EndsWith(".exe")) { AppPath = CurrentProduct; } } } if (AppPath.EndsWith(".app")) { AppPath = Path.Combine(AppPath, Path.Combine("Contents", Path.Combine("MacOS", AppPath.Substring(AppPath.LastIndexOf('/') + 1, AppPath.Length - AppPath.LastIndexOf('/') - 5)))); IgorRuntimeUtils.SetFileExecutable(AppPath); } string AppOutput = ""; string AppError = ""; int RunAppRC = IgorRuntimeUtils.RunProcessCrossPlatform(AppPath, AppPath, "", Path.GetFullPath("."), ref AppOutput, ref AppError); if (RunAppRC != 0) { MonsterDebug.LogError("Failed to run test. App retruned RC " + RunAppRC + "!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError); return(true); } MonsterDebug.Log("Test ran successfully!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError); return(true); }
public static void CheckForAndRunJobs() { string JobName = Environment.GetEnvironmentVariable(MonsterTestCore.MonsterLauncherJobNameEnvVariable); MonsterDebug.Log("Checking for job " + JobName); if (JobName != null && JobName != "" && JobName != CurrentJobName) { IgorConfig.SetJobToRunByName(JobName); MonsterDebug.Log("Starting job " + JobName); CurrentJobName = JobName; } IgorCore.HandleJobStatus(IgorCore.RunJob(false)); }
public virtual bool InternalBuildTestable(bool bRunningTestInEditor = false) { if (!bRunningTestInEditor) { if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("MONSTER_TEST_RUNTIME")) { IgorSetScriptingDefines.ExtraModuleParams += ";MONSTER_TEST_RUNTIME"; } if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("IGOR_RUNTIME")) { IgorSetScriptingDefines.ExtraModuleParams += ";IGOR_RUNTIME"; } IgorJobConfig.SetStringParam(LastDisplayResolutionDialogFlag, PlayerSettings.displayResolutionDialog.ToString()); PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; } if (!bRunningTestInEditor || (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bForceLoadToFirstSceneInEditor)) { string FirstLevelName = IgorUtils.GetFirstLevelName(); if (FirstLevelName != "") { if (EditorApplication.currentScene != FirstLevelName) { EditorApplication.OpenScene(FirstLevelName); return(false); } } } if (MonsterStarter.GetInstance() == null) { GameObject MonsterStarterInst = new GameObject("MonsterTestStarter"); MonsterStarterInst.AddComponent <MonsterStarter>(); EditorApplication.SaveScene(); } if (!bRunningTestInEditor) { string StreamingAssetsFolder = Path.Combine("Assets", Path.Combine("StreamingAssets", Path.Combine("Igor", Path.Combine("Monster", "Config")))); if (Directory.Exists(StreamingAssetsFolder)) { MonsterDebug.LogError("Attempting to overwrite the " + StreamingAssetsFolder + ", but it already exists!"); IgorRuntimeUtils.DeleteDirectory(StreamingAssetsFolder); Directory.CreateDirectory(StreamingAssetsFolder); } else { Directory.CreateDirectory(StreamingAssetsFolder); } string ConfigRoot = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Config"); if (Directory.Exists(ConfigRoot)) { IgorRuntimeUtils.DirectoryCopy(ConfigRoot, StreamingAssetsFolder, true); } } return(true); }
public virtual void BuildLauncher(BuildTarget TargetTestPlatform) { MonsterDebug.Log("Building launcher for platform " + TargetTestPlatform); string MethodName = GetBuildMethodName(TargetTestPlatform); if (MethodName == "") { MonsterDebug.LogError("Test platform " + TargetTestPlatform + " is not supported yet. Please add support for it!"); } string MonsterLauncherProjectPath = Path.Combine(Application.temporaryCachePath, "MonsterLauncher"); MonsterDebug.Log("Creating new project at " + MonsterLauncherProjectPath); if (Directory.Exists(MonsterLauncherProjectPath)) { MonsterDebug.Log("Cleaning up old project first!"); IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath); } Directory.CreateDirectory(MonsterLauncherProjectPath); string LauncherProjectAssetsIgorFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", "Igor")); Directory.CreateDirectory(LauncherProjectAssetsIgorFolder); MonsterDebug.Log("Copying project files."); IgorRuntimeUtils.DirectoryCopy(Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", "Igor")), LauncherProjectAssetsIgorFolder, true); string OldLaunchersFolder = Path.Combine(LauncherProjectAssetsIgorFolder, Path.Combine("Monster", "Launchers")); IgorRuntimeUtils.DeleteDirectory(OldLaunchersFolder); MonsterDebug.Log("Copying Igor config."); string StreamingAssetsFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", Path.Combine("StreamingAssets", "Igor"))); Directory.CreateDirectory(StreamingAssetsFolder); if (File.Exists(IgorConfig.DefaultConfigPath)) { IgorRuntimeUtils.CopyFile(IgorConfig.DefaultConfigPath, Path.Combine(StreamingAssetsFolder, IgorConfig.IgorConfigFilename)); } string BuildLauncherOutput = ""; string BuildLauncherError = ""; MonsterDebug.Log("Attempting to build launcher."); int ReturnCode = IgorRuntimeUtils.RunProcessCrossPlatform(EditorApplication.applicationPath + "/Contents/MacOS/Unity", EditorApplication.applicationPath, "-projectPath \"" + MonsterLauncherProjectPath + "\" -buildmachine -executeMethod " + MethodName + " -logfile Monster.log", MonsterLauncherProjectPath, ref BuildLauncherOutput, ref BuildLauncherError); if (ReturnCode != 0) { MonsterDebug.LogError("Something went wrong with the build! Returned error code " + ReturnCode + "\n\nOutput:\n" + BuildLauncherOutput + "\n\nError:\n" + BuildLauncherError); return; } MonsterDebug.Log("Launcher successfully built!"); string MonsterLauncherPath = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Launchers"); if (!Directory.Exists(MonsterLauncherPath)) { Directory.CreateDirectory(MonsterLauncherPath); } MonsterDebug.Log("Copying launcher back to project."); CopyLauncherToProjectPath(TargetTestPlatform, MonsterLauncherProjectPath, MonsterLauncherPath); IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath); string MonsterRunPyFile = Path.Combine(MonsterLauncherPath, "MonsterRun.py"); if (File.Exists(MonsterRunPyFile)) { IgorRuntimeUtils.DeleteFile(MonsterRunPyFile); } string MonsterRunPyFileLatest = Path.Combine(IgorUpdater.LocalModuleRoot, Path.Combine("MonsterTest", Path.Combine("Core", Path.Combine("Runtime", "MonsterRun.py")))); if (File.Exists(MonsterRunPyFileLatest)) { MonsterDebug.Log("Copying latest MonsterRun.py to the Launchers folder."); IgorRuntimeUtils.CopyFile(MonsterRunPyFileLatest, MonsterRunPyFile); } MonsterDebug.Log("Done building launcher for platform " + TargetTestPlatform); }
public virtual void BrokenConnection() { MonsterDebug.LogError("There was a broken connection in the dialogue!"); bProblemEncountered = true; }
public virtual void NewLine(string LineID) { MonsterDebug.Log("New line \"" + LineID + "\""); WaitTimeLeft = Random.Range(1.0f, 2.0f); }
public virtual void TestFailed() { MonsterDebug.Log("Test failed!"); }
public virtual void TestSucceeded() { MonsterDebug.Log("Test succeeded!"); }