Test arguments parses the command line arguments given to the testrunner
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            TestArguments arguments = new TestArguments(args);
            if (arguments.HaveAdditionalPath)
            {
                ProcessStartInfo info = new ProcessStartInfo(
                                    new FileInfo(Assembly.GetEntryAssembly().Location).FullName,
                                    arguments.StrippedArgs()
                                    );
                info.UseShellExecute = false;
                info.EnvironmentVariables["PATH"] = arguments.AdditionalPath + ";" + info.EnvironmentVariables["PATH"];
                info.EnvironmentVariables["LD_LIBRARY_PATH"] = arguments.AdditionalPath + ":" + info.EnvironmentVariables["LD_LIBRARY_PATH"];
                info.EnvironmentVariables["DYLD_LIBRARY_PATH"] = arguments.AdditionalPath + ":" + info.EnvironmentVariables["DYLD_LIBRARY_PATH"];
                Process.Start(info);
                return;
            }

            //
            // Ensure that the native library was successfully loaded
            //
            try
            {
                Console.Out.WriteLine("Testing LibSBML: " + libsbml.getLibSBMLDottedVersion());
            }
            catch
            {
                Console.Out.WriteLine(string.Format(
                    "Error:  The native libsbml library could not be loaded. {0}" +
                    "\tPlease ensure that libsbmlcs.so|dll|dylib and its dependencies {0}"+
                    "\tare in the LD_LIBRARY_PATH|PATH|DYLD_LIBRARY_PATH.{0}",
                    Environment.NewLine));
                Environment.Exit(1);
            }

            //
            // Checks arguments
            //
            if (args.Length < 1)
            {
                Console.Out.WriteLine("Need one or more argument: fileName or directoryname [...]");
                Environment.Exit(1);
            }

            //
            // Run tests
            //
            Console.Out.WriteLine();
            for (int i = 0; i < args.Length; i++)
            {
                if (Directory.Exists(args[i]))
                {
                    string[] files = System.IO.Directory.GetFiles(args[i]);
                    for (int j = 0; j < files.Length; j++)
                    {
                        if (files[j].EndsWith(".xml"))
                        {
                          testReadAndWriteSBML(files[j]);
                        }
                    }
                }
                else
                {
                    testReadAndWriteSBML(args[i]);
                }
            }

            testCreateSBML();
            testCovariantReturnTypes();

            //
            // Prints result
            //
            if ( numErrors > 0 )
            {
              if (numErrors > 1)
              {
                Console.Out.WriteLine("\n" + numErrors + " tests failed.\n");
              }
              else
              {
                Console.Out.WriteLine("\n" + numErrors + " test failed.\n");
              }
              Environment.Exit(1);
            }

            Console.Out.WriteLine("\nAll tests passed.\n");

            Environment.Exit(0);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TestArguments arguments = new TestArguments(args);

            if (arguments.HaveAdditionalPath)
            {
                ProcessStartInfo info = new ProcessStartInfo(
                    new FileInfo(Assembly.GetEntryAssembly().Location).FullName,
                    arguments.StrippedArgs()
                    );
                info.UseShellExecute = false;
                info.EnvironmentVariables["PATH"]              = arguments.AdditionalPath + ";" + info.EnvironmentVariables["PATH"];
                info.EnvironmentVariables["LD_LIBRARY_PATH"]   = arguments.AdditionalPath + ":" + info.EnvironmentVariables["LD_LIBRARY_PATH"];
                info.EnvironmentVariables["DYLD_LIBRARY_PATH"] = arguments.AdditionalPath + ":" + info.EnvironmentVariables["DYLD_LIBRARY_PATH"];
                Process.Start(info);
                return;
            }

            //
            // Ensure that the native library was successfully loaded
            //
            try
            {
                Console.Out.WriteLine("Testing LibSBML: " + libsbml.getLibSBMLDottedVersion());
            }
            catch
            {
                Console.Out.WriteLine(string.Format(
                                          "Error:  The native libsbml library could not be loaded. {0}" +
                                          "\tPlease ensure that libsbmlcs.so|dll|dylib and its dependencies {0}" +
                                          "\tare in the LD_LIBRARY_PATH|PATH|DYLD_LIBRARY_PATH.{0}",
                                          Environment.NewLine));
                Environment.Exit(1);
            }

            //
            // Checks arguments
            //
            if (args.Length < 1)
            {
                Console.Out.WriteLine("Need one or more argument: fileName or directoryname [...]");
                Environment.Exit(1);
            }


            //
            // Run tests
            //
            Console.Out.WriteLine();
            for (int i = 0; i < args.Length; i++)
            {
                if (Directory.Exists(args[i]))
                {
                    string[] files = System.IO.Directory.GetFiles(args[i]);
                    for (int j = 0; j < files.Length; j++)
                    {
                        if (files[j].EndsWith(".xml"))
                        {
                            testReadAndWriteSBML(files[j]);
                        }
                    }
                }
                else
                {
                    testReadAndWriteSBML(args[i]);
                }
            }

            testCreateSBML();
            testCovariantReturnTypes();

            //
            // Prints result
            //
            if (numErrors > 0)
            {
                if (numErrors > 1)
                {
                    Console.Out.WriteLine("\n" + numErrors + " tests failed.\n");
                }
                else
                {
                    Console.Out.WriteLine("\n" + numErrors + " test failed.\n");
                }
                Environment.Exit(1);
            }

            Console.Out.WriteLine("\nAll tests passed.\n");

            Environment.Exit(0);
        }