예제 #1
0
        static void InteractiveMode(string s)
        {
            Console.WriteLine("Interactive testcloud uploader. Type --help for help");
            Console.WriteLine(
                "Usage: >>> -d <deviceset> -c <category> -a <key> -u <user> [-c <category> -c <category> -c <category>]");

            while (true)
            {
                Console.Write(">>> ");
                var command     = Console.ReadLine();
                var commandList = command.Split(' ');

                var platform          = DeviceSet.Platform.None;
                var deviceSet         = "";
                var categories        = new List <string>();
                var excludeCategories = new List <string>();
                var series            = "";
                var account           = "";
                var user = "";

                OptionSet options = null;
                options = new OptionSet
                {
                    { "q|quit", "quit", Exit },
                    { "h|help", "show this message and exit", str => ShowInteractiveHelp(options) },
                    { "c|category=", "add a category to the test run [deprecated, use include]", str => categories.Add(str) },
                    { "d|deviceset=", "specify the device set to upload", str => deviceSet = str },
                    { "lc|listcategories", "Lists categories in uitests", ListCategories },
                    { "ld|listdevicesets", "Lists defined devices sets", ListDeviceSets },
                    { "a|account=", "Test Cloud key", str => account = str },
                    { "u|user="******"Test Cloud user", str => user = str },
                    { "n|include=", "add a category to the test run", str => categories.Add(str) },
                    { "e|exclude=", "exclude a category from the test run", str => excludeCategories.Add(str) }
                };

                List <string> extra;
                try
                {
                    extra = options.Parse(commandList);
                }
                catch (OptionException ex)
                {
                    Console.Write("Uploader:");
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Try --help for more informaiton");
                }

                if (command.Length == 0)
                {
                    ShowHelp(options);
                }

                // by default take the first category as the series name
                if (categories.Count >= 1)
                {
                    series = categories.First();
                }

                if (commandList.Length >= 4)
                {
                    var validQuery = true;

                    if (!IsValidDeviceSet(deviceSet))
                    {
                        Console.WriteLine("Invalid DeviceSet: {0}", deviceSet);
                        validQuery = false;
                    }

                    if (!CategoriesValid(categories))
                    {
                        Console.Write("Invalid Category(s):");
                        foreach (var c in categories)
                        {
                            Console.Write(" {0} ", c);
                        }
                        Console.Write("\n");
                        validQuery = false;
                    }

                    if (validQuery)
                    {
                        var devSet     = StringToDeviceSet(deviceSet);
                        var execString = BuildExecutionString(devSet.DeviceSetPlatform.First(), devSet, categories, series, account, user, excludeCategories: excludeCategories);
                        Console.WriteLine(execString);
                        TestCloudUtils.UploadApp(execString);
                    }
                }
            }
        }
예제 #2
0
        static int Main(string[] args)
        {
            loaderActions = new LoaderActions();

            var       categories        = new List <string>();
            var       excludeCategories = new List <string>();
            string    series            = null;
            var       platform          = DeviceSet.Platform.None;
            DeviceSet deviceSet         = null;
            var       validate          = false;
            string    outputFile        = null;
            var       account           = "";
            var       user = "";

            OptionSet optionSet = null;

            optionSet = new OptionSet
            {
                {
                    "p|platform=", "specify the test platform, iOS or Android",
                    s => platform = (DeviceSet.Platform)Enum.Parse(typeof(DeviceSet.Platform), s)
                },
                { "d|deviceset=", "the device set to use for the test run", s => deviceSet = StringToDeviceSet(s) },
                { "c|category=", "add a category to the test run [deprecated, use include]", str => categories.Add(str) },
                { "s|series=", "specify the series when uploaded to Test Cloud", s => series = s },
                { "l|list", "list categories available in test suite", ListCategories },
                { "sets", "list available device sets", ListDeviceSets },
                { "i|interactive", "start uploader in interactive mode", InteractiveMode },
                { "h|help", "show this message and exit", s => ShowHelp(optionSet) },
                { "v|validate", "validate all tests or a specified category", s => validate = true },
                { "o|output=", "output destination for NUnit XML", s => outputFile = s },
                { "a|account=", "Test Cloud key", s => account = s },
                { "u|user="******"Test Cloud user", s => user = s },
                { "n|include=", "add a category to the test run", str => categories.Add(str) },
                { "e|exclude=", "exclude a category from the test run", str => excludeCategories.Add(str) }
            };

            List <string> extra;

            try
            {
                extra = optionSet.Parse(args);
            }
            catch (OptionException ex)
            {
                Console.Write("Uploader:");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try --help for more informaiton");
            }

            if (args.Length == 0)
            {
                ShowHelp(optionSet);
            }

            if (validate)
            {
                var category = categories.FirstOrDefault();
                return(loaderActions.ValidateCategory(category) ? 0 : 1);
            }

            if (platform == DeviceSet.Platform.None)
            {
                Console.WriteLine("Platform must be specified");
                return(1);
            }

            if (deviceSet != null && !deviceSet.DeviceSetPlatform.Contains(platform))
            {
                Console.WriteLine("DeviceSet platform does not match specified platform");
                return(1);
            }

            if (deviceSet == null)
            {
                if (platform == DeviceSet.Platform.Android)
                {
                    deviceSet = DeviceSets.AndroidFastParallel;
                }
                else
                {
                    deviceSet = DeviceSets.IOsFastParallel;
                }
            }

            var execString = BuildExecutionString(platform, deviceSet, categories, series, account, user, outputFile, excludeCategories);

            Console.WriteLine(execString);

            var processStatus = TestCloudUtils.UploadApp(execString);

            Console.WriteLine("test-cloud.exe status: " + processStatus);
            return(processStatus);
        }