Beispiel #1
0
        public static void Main(string[] args)
        {
            var launcherArgs = new LauncherArgs(args);

            if (launcherArgs.IsDebugging || launcherArgs.IsRunFromEditor)
            {
                ShowConsole();
            }

            using (var launcher = new DualityLauncher(launcherArgs))
            {
                launcher.Run();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes this DualityApp. Should be called before performing any operations within Duality.
        /// </summary>
        /// <param name="env"></param>
        /// <param name="context">The <see cref="ExecutionContext"/> in which Duality runs.</param>
        /// <param name="plugins"></param>
        /// <param name="launcherArgs">
        /// Command line arguments to run this DualityApp with.
        /// Usually these are just the ones from the host application, passed on.
        /// </param>
        public static void Init(ExecutionEnvironment env, ExecutionContext context, IAssemblyLoader plugins, LauncherArgs launcherArgs)
        {
            if (initialized)
            {
                return;
            }

            // Process command line options
            if (launcherArgs.IsDebugging)
            {
                System.Diagnostics.Debugger.Launch();
            }
            // Run from editor
            if (launcherArgs.IsRunFromEditor)
            {
                runFromEditor = true;
            }

            // If the core was compiled in debug mode and a debugger is attached, log
            // to the Debug channel, so we can put the VS output window to good use.
#if DEBUG
            bool isDebugging = System.Diagnostics.Debugger.IsAttached;
            if (isDebugging)
            {
                // Only add a new Debug output if we don't already have one, and don't
                // log to a Console channel either. VS will automatically redirect Console
                // output to the Output window when debugging a non-Console application,
                // and we don't want to end up with double log entries.
                bool hasDebugOut   = Logs.GlobalOutput.OfType <DebugLogOutput>().Any();
                bool hasConsoleOut = Logs.GlobalOutput.OfType <TextWriterLogOutput>().Any(w => w.GetType().Name.Contains("Console"));
                if (!hasDebugOut && !hasConsoleOut)
                {
                    Logs.AddGlobalOutput(new DebugLogOutput());
                }
            }
                        #endif

            environment = env;
            execContext = context;

            // Initialize the plugin manager
            {
                assemblyLoader = plugins ?? new Duality.Backend.Dummy.DummyAssemblyLoader();
                Logs.Core.Write("Using '{0}' to load plugins.", assemblyLoader.GetType().Name);

                assemblyLoader.Init();

                // Log assembly loading data for diagnostic purposes
                {
                    Logs.Core.Write("Currently Loaded Assemblies:" + Environment.NewLine + "{0}",
                                    assemblyLoader.LoadedAssemblies.ToString(
                                        assembly => "  " + LogFormat.Assembly(assembly),
                                        Environment.NewLine));
                    Logs.Core.Write("Plugin Base Directories:" + Environment.NewLine + "{0}",
                                    assemblyLoader.BaseDirectories.ToString(
                                        path => "  " + path,
                                        Environment.NewLine));
                    Logs.Core.Write("Available Assembly Paths:" + Environment.NewLine + "{0}",
                                    assemblyLoader.AvailableAssemblyPaths.ToString(
                                        path => "  " + path,
                                        Environment.NewLine));
                }

                pluginManager.Init(assemblyLoader);
                pluginManager.PluginsRemoving += pluginManager_PluginsRemoving;
                pluginManager.PluginsRemoved  += pluginManager_PluginsRemoved;
            }

            // Load all plugins. This needs to be done first, so backends and Types can be located.
            pluginManager.LoadPlugins();

            // Initialize the system backend for system info and file system access
            InitBackend(out systemBack);

            // Load application and user data and submit a change event, so all settings are applied
            DualityApp.AppData.Load();
            DualityApp.UserData.Load();

            // Initialize the graphics backend
            InitBackend(out graphicsBack);

            // Initialize the audio backend
            InitBackend(out audioBack);
            sound = new SoundDevice();

            // Initialize all core plugins, this may allocate Resources or establish references between plugins
            pluginManager.InitPlugins();

            initialized = true;

            // Write environment specs as a debug log
            Logs.Core.Write(
                "DualityApp initialized" + Environment.NewLine +
                "Debug Mode: {0}" + Environment.NewLine +
                "Command line arguments: {1}",
                System.Diagnostics.Debugger.IsAttached,
                launcherArgs.ToString());
        }
Beispiel #3
0
        internal string RunTest(
            string testFile,
            List <string> testsToRun,
            string resultLogFile,
            string errorLogFile,
            string failedConfFile,
            int numRetriesOnFailure,
            TestSuiteLoggerParams loggerParams,
            TestRange testRange,
            string[] cliArgs,
            int testTimeout)
        {
            mLoggerParams = loggerParams;

            try
            {
                mGroup = TestConfLoader.LoadFromFile(testFile, cliArgs);

                if ((mGroup == null) || (mGroup.ParallelTests.Count == 0))
                {
                    mLog.WarnFormat("[{0}] no tests to run", testFile);
                    return("No tests to run");
                }

                mTestsList = testsToRun;

                if (testRange == null)
                {
                    testRange = new TestRange(0, mGroup.ParallelTests.Count - 1);
                }

                if (testRange.EndTest >= mGroup.ParallelTests.Count)
                {
                    testRange.EndTest = mGroup.ParallelTests.Count - 1;
                }

                mUserValues = CliArgsReader.GetUserValues(cliArgs);

                mLauncherArgs = new LauncherArgs();

                mLauncherArgs.ResultLogFile    = resultLogFile;
                mLauncherArgs.ErrorLogFile     = errorLogFile;
                mLauncherArgs.FailedConfigFile = failedConfFile;
                mLauncherArgs.RetryOnFailure   = numRetriesOnFailure;
                mLauncherArgs.MaxRetry         = numRetriesOnFailure;
                mLauncherArgs.TestRange        = testRange;
                mLauncherArgs.TestsTimeout     = testTimeout;

                System.Threading.ThreadPool.QueueUserWorkItem(
                    new System.Threading.WaitCallback(Run));

                return(string.Format(
                           "Trying to launch {0} tests",
                           mGroup.ParallelTests.Count));
            }
            catch (Exception e)
            {
                mLog.ErrorFormat("RunTest error {0}", e.Message);
                mLog.Debug(e.StackTrace);
                return(e.Message);
            }
        }