Ejemplo n.º 1
0
        public static string Test(TestElement testElement)
        {
            Console.Write("\n  loaded {0}", testElement.testDriver);
            var installPath = GetJavaInstallationPath();
            var javaPath    = Path.Combine(installPath, @"bin\Java.exe");
            var driver      =
                testElement.testDriver.Remove(testElement.testDriver.LastIndexOf(@".", StringComparison.Ordinal));

            if (testElement.testDriver.Length > testElement.testDriver.LastIndexOf(".", StringComparison.Ordinal))
            {
                try
                {
                    using (var process = new Process())
                    {
                        LoadJar(javaPath, driver, process);
                        LogOutput(testElement, process);
                    }
                }
                catch (Exception e)
                {
                    Console.Write(e.Message);
                }
            }
            return("true");
        }
Ejemplo n.º 2
0
        private static void LoadJar(TestElement test)
        {
            var result = JavaLoaderExec.Test(test);

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
        }
Ejemplo n.º 3
0
        private static void TestDriverBuilder(string installPath, TestElement testElement, List <string> testNames)
        {
            var jarPath    = Path.Combine(installPath, "bin\\Jar.exe");
            var tests      = testNames;
            var classNames = new List <string>();

            foreach (var test in tests)
            {
                var kclass   = test.Remove(test.LastIndexOf(".", StringComparison.Ordinal));
                var fileName = kclass + ".class";
                classNames.Add(fileName);
            }
            try
            {
                var driver = testElement.testDriver.Remove(testElement.testDriver.LastIndexOf(".", StringComparison.Ordinal));
                using (var process = new Process())
                {
                    CreateJar(jarPath, classNames, driver, process);
                    LogOutput(testElement, process);
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
Ejemplo n.º 4
0
        private static void LogOutput(TestElement testElement, Process process)
        {
            var output = process.StandardOutput.ReadToEnd();

            Console.WriteLine("Building Java Library for : " + testElement.testName);
            Console.WriteLine(output);
            using (StreamWriter w = File.AppendText(@"build.log"))
            {
                w.WriteLine(output);
            }
        }
Ejemplo n.º 5
0
        private static void LogCompilationOutput(TestElement testElement, Process process)
        {
            var output = process.StandardOutput.ReadToEnd();

            Console.WriteLine("Compiling Java classes for: " + testElement.testName);
            Console.WriteLine("Result:" + output);
            using (StreamWriter w = File.AppendText(@"build.log"))
            {
                w.WriteLine(output);
            }
        }
        private static void BuildTestDriverDll(TestElement testElement, List <string> testNames, Process process)
        {
            var frameworkPath = RuntimeEnvironment.GetRuntimeDirectory();

            process.StartInfo.FileName  = frameworkPath + "/csc.exe";
            process.StartInfo.Arguments = "/target:library /out:..\\..\\..\\TestHarness\\TestStorage\\" +
                                          testElement.testName + ".dll " + string.Join(" ", testNames);
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.Start();
        }
Ejemplo n.º 7
0
 public static void Build(string buildStorage, TestElement testElement)
 {
     if (testElement.toolchain == "csharp")
     {
         var builder = new CSharpLibraryBuilder(buildStorage, testElement);
         builder.Build();
     }
     else if (testElement.toolchain == "java")
     {
         var builder = new JavaLibraryBuilder(buildStorage, testElement);
         builder.Build();
     }
 }
Ejemplo n.º 8
0
        private void LoadDll(TestElement test)
        {
            var loader = new DllLoaderExec(test);

            DllLoaderExec.testersLocation = TestStorage;
            // convert testers relative path to absolute path
            DllLoaderExec.testersLocation = Path.GetFullPath(DllLoaderExec.testersLocation);
            Console.Write("\n  Loading Test Modules from:\n    {0}\n", DllLoaderExec.testersLocation);
            // run load and tests
            var result = loader.loadAndExerciseTesters();

            Console.Write("\n\n  {0}", result);
            Console.Write("\n\n");
        }
        private static void BuildSourceCodeDll(TestElement testElement, List <string> testNames, Process process)
        {
            var frameworkPath = RuntimeEnvironment.GetRuntimeDirectory();
            var driver        = testElement.testDriver.Remove(testElement.testDriver.LastIndexOf(".", StringComparison.Ordinal));

            process.StartInfo.FileName  = frameworkPath + "/csc.exe";
            process.StartInfo.Arguments = "/target:library /out:..\\..\\..\\TestHarness\\TestStorage\\" +
                                          driver + ".dll " + string.Join(" ", testNames);
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.Start();
        }
        private static void LogOutput(TestElement testElement, Process process)
        {
            var output = process.StandardOutput.ReadToEnd();

            Console.WriteLine("Building: " + testElement.testName);
            Console.WriteLine("Result:" + output);
            if (output.Contains("error"))
            {
            }
            using (StreamWriter w = File.AppendText(@"build.log"))
            {
                w.WriteLine(output);
            }
        }
 private static void TestDriverBuilder(TestElement testElement, List <string> testNames)
 {
     try
     {
         using (var process = new Process())
         {
             BuildTestDriverDll(testElement, testNames, process);
             LogOutput(testElement, process);
         }
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
     }
 }
Ejemplo n.º 12
0
        private void CreateBuildRequest()
        {
            ///////////////////////////////////////////////////////////////
            // Serialize Build Request data structure

            "Creating Build Request".Title();
            Console.WriteLine();

            // CSharp Build pass and Tests pass
            var te1 = new TestElement("test1", "csharp");

            te1.addDriver("TestDriver.cs");
            te1.addCode("Tested1.cs");
            te1.addCode("Tested2.cs");

            // Java Build pass and Tests pass
            var te2 = new TestElement("test2", "java");

            te2.addDriver("TestDriver.java");
            te2.addCode("Tested1.java");
            te2.addCode("Tested2.java");

            // CSharp Build pass and Tests Fail
            var te3 = new TestElement("test3", "csharp");

            te3.addDriver("TestDriver1.cs");
            te3.addCode("Tested3.cs");

            // CSharp Build Fail
            var te4 = new TestElement("test4", "csharp");

            te4.addDriver("TestDriverBuildFail.cs");
            te4.addCode("Tested1.cs");
            te4.addCode("Tested2.cs");

            var tr = new BuildRequest("Jim Fawcett");

            tr.tests.Add(te1);
            tr.tests.Add(te2);
            tr.tests.Add(te3);
            tr.tests.Add(te4);
            var trXml = tr.ToXml();

            Console.Write("\n  Serialized TestRequest data structure:\n\n  {0}\n", trXml);
            File.WriteAllText(RepoStorage + "/BuildRequest.xml", trXml);
        }
Ejemplo n.º 13
0
        private static void SourceCodeBuilder(string installPath, TestElement testElement, List <string> testNames)
        {
            var javacPath = Path.Combine(installPath, "bin\\Javac.exe");

            try
            {
                //puts the .class files in the build storage
                using (var process = new Process())
                {
                    CompileJavaClasses(testNames, javacPath, process);
                    LogCompilationOutput(testElement, process);
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
Ejemplo n.º 14
0
        private static void LogOutput(TestElement testElement, Process process)
        {
            var output       = process.StandardOutput.ReadToEnd();
            var filestream   = new FileStream("test.log", FileMode.Append, FileAccess.Write);
            var streamwriter = new StreamWriter(filestream)
            {
                AutoFlush = true
            };
            var currentOut = Console.Out;

            Console.SetOut(streamwriter);
            Console.WriteLine("\n{0}  {1}\n", testElement.testName, output);
            streamwriter.Flush();
            Console.SetOut(currentOut);
            streamwriter.Close();
            filestream.Close();
            Console.WriteLine();
            Console.WriteLine("Done");
        }
Ejemplo n.º 15
0
        //Builds the Testrequest instance from the build request.
        private static TestRequest BuildTestRequest(BuildRequest buildRequest)
        {
            var tr = new TestRequest("Jim Fawcett");

            foreach (var test in buildRequest.tests)
            {
                var te = new TestElement(test.testName, test.toolchain);
                if (test.toolchain == "csharp")
                {
                    te.addDriver(test.testDriver.Remove(test.testDriver.LastIndexOf(".", StringComparison.Ordinal)) + ".dll");
                    te.addCode(test.testName + ".dll");
                }
                else if (test.toolchain == "java")
                {
                    te.addDriver(test.testDriver.Remove(test.testDriver.LastIndexOf(".", StringComparison.Ordinal)) + ".java");
                }
                tr.tests.Add(te);
            }
            return(tr);
        }
 public CSharpLibraryBuilder(string buildStorage, TestElement testElement)
 {
     BuildStorage     = buildStorage;
     this.testElement = testElement;
 }
Ejemplo n.º 17
0
        public DllLoaderExec(TestElement test)
        {
            Test = test;

            testersLocation = ".";
        }
Ejemplo n.º 18
0
 public JavaLibraryBuilder(string buildStorage, TestElement testElement)
 {
     BuildStorage = buildStorage;
     TestElement  = testElement;
 }