Ejemplo n.º 1
0
        private static void AppendText(string macro, string path)
        {
            string text  = File.ReadAllText(path);
            string text2 = new StringReader(text).ReadLine();

            if (text2.Contains("#define"))
            {
                text = text.Substring(text2.Length, text.Length - text2.Length);
            }
            else
            {
                macro += "\r\n";
            }
            text = text.Insert(0, macro);
            File.WriteAllText(path, text);
        }
Ejemplo n.º 2
0
        private static void AppendMacro(string macro)
        {
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(true);
            System.Diagnostics.StackFrame sf = st.GetFrame(0);
            string path = sf.GetFileName();

            string text  = File.ReadAllText(path);
            string text2 = new StringReader(text).ReadLine();

            if (text2.Contains("#define"))
            {
                text = text.Substring(text2.Length, text.Length - text2.Length);
            }
            else
            {
                macro += "\r\n";
            }
            text = text.Insert(0, macro);
            File.WriteAllText(path, text);
            InjectMethods.Recompile();
        }
Ejemplo n.º 3
0
        public void RepetitiveEvaluationFailureGetsPrintedToConsole()
        {
            // Build evaluation actor that allows 1 failure per evaluation, but uses a risky operation that
            // produces 2 failures in a row.
            var actorRef = this.CreateEvaluationActorWithRiskyOperation(
                config: new AlgorithmTunerConfiguration.AlgorithmTunerConfigurationBuilder()
                .SetMaximumNumberConsecutiveFailuresPerEvaluation(1)
                .Build(maximumNumberParallelEvaluations: 1),
                failuresInARow: 2);

            // Then take a look at console output:
            TestUtils.CheckOutput(
                action: () =>
            {
                // Start genome evaluation and therefore provoke failing evaluations.
                ((ICanTell)actorRef).Tell(new Poll(), this._generationEvaluationActorRef);
                ((ICanTell)actorRef).Tell(
                    new GenomeInstancePairEvaluation <TestInstance>(
                        new GenomeInstancePair <TestInstance>(this._genome, this._testInstance),
                        0,
                        0,
                        false),
                    this._generationEvaluationActorRef);

                // Wait a while to really let them fail.
                this.ExpectNoMsg(milliseconds: 1500);
            },
                check: consoleOutput =>
            {
                // Check that information about it is written to console.
                string output = new StringReader(consoleOutput.ToString()).ReadToEnd();
                Assert.True(
                    output.Contains($"Genome {this._genome} does not work with instance 1"),
                    $"Console output {output} does not contain information about problematic evaluation.");
            });
        }