GetStartInfo() public method

public GetStartInfo ( Selections selections ) : ProcessStartInfo
selections Selections
return System.Diagnostics.ProcessStartInfo
示例#1
0
        public void TestGetStartInfoPathlessCommand()
        {
            var selections = SelectionsTest.CreateTestSelections();

            selections.Implementations.Insert(0, new ImplementationSelection {
                InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")
            });                                                                                                                                        // Should be ignored by Executor
            selections.Implementations[1].Commands[0].Path = null;

            var executor  = new Executor(GetMockStore(selections));
            var startInfo = executor.GetStartInfo(selections, "--custom");

            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)));
            startInfo.Arguments.Should().Be(
                new[]
            {
                selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                "--custom"
            }.JoinEscapeArguments());

            VerifyEnvironment(startInfo, selections);
        }
示例#2
0
        public void TestGetStartInfoWrapper()
        {
            if (!WindowsUtils.IsWindows)
            {
                Assert.Ignore("Wrapper command-line parsing relies on a Win32 API and therefore will not work on non-Windows platforms");
            }

            var selections = SelectionsTest.CreateTestSelections();

            selections.Implementations.Insert(0, new ImplementationSelection {
                InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")
            });                                                                                                                                        // Should be ignored by Executor

            var executor = new Executor(GetMockStore(selections))
            {
                Wrapper = "wrapper --wrapper"
            };
            var startInfo = executor.GetStartInfo(selections, "--custom");

            startInfo.FileName.Should().Be("wrapper");
            startInfo.Arguments.Should().Be(
                new[]
            {
                "--wrapper",
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                Path.Combine(Test1Path, FileUtils.UnifySlashes(selections.Implementations[1].Commands[0].Path)),
                selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                "--custom"
            }.JoinEscapeArguments(),
                because: "Should combine wrapper arguments, runner and application");

            VerifyEnvironment(startInfo, selections);
        }
示例#3
0
        public void TestGetStartInfoMainAbsolute()
        {
            var selections = SelectionsTest.CreateTestSelections();

            selections.Implementations.Insert(0, new ImplementationSelection {
                InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")
            });                                                                                                                                        // Should be ignored by Executor

            var executor = new Executor(GetMockStore(selections))
            {
                Main = "/main"
            };
            var startInfo = executor.GetStartInfo(selections, "--custom");

            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                because: "Should combine runner implementation directory with runner command path");
            startInfo.Arguments.Should().Be(
                new[]
            {
                selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                Path.Combine(Test1Path, "main"),
                "--custom"
            }.JoinEscapeArguments(),
                because: "Should combine core and additional runner arguments with application implementation directory and main binary override");

            VerifyEnvironment(startInfo, selections);
        }
示例#4
0
        public void TestGetStartInfoForEachArgs()
        {
            var selections = SelectionsTest.CreateTestSelections();

            selections.Implementations.Insert(0, new ImplementationSelection {
                InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")
            });                                                                                                                                        // Should be ignored by Executor

            selections.Implementations[1].Commands[0].Arguments.Add(new ForEachArgs
            {
                ItemFrom  = "SPLIT_ARG",
                Arguments = { "pre1 $item post1", "pre2 $item post2" }
            });
            selections.Implementations[2].Bindings.Add(new EnvironmentBinding {
                Name = "SPLIT_ARG", Value = "split1" + Path.PathSeparator + "split2"
            });

            var executor  = new Executor(GetMockStore(selections));
            var startInfo = executor.GetStartInfo(selections);

            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                because: "Should combine runner implementation directory with runner command path");
            startInfo.Arguments.Should().Be(
                new[]
            {
                selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                Path.Combine(Test1Path, FileUtils.UnifySlashes(selections.Implementations[1].Commands[0].Path)),
                selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                "pre1 split1 post1", "pre2 split1 post2", "pre1 split2 post1", "pre2 split2 post2"
            }.JoinEscapeArguments(),
                because: "Should combine core and additional runner arguments with application implementation directory and command path");

            VerifyEnvironment(startInfo, selections);
        }
示例#5
0
        public void TestGetStartInfoForEachArgs()
        {
            var selections = SelectionsTest.CreateTestSelections();
            selections.Implementations.Insert(0, new ImplementationSelection {InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")}); // Should be ignored by Executor

            selections.Implementations[1].Commands[0].Arguments.Add(new ForEachArgs
            {
                ItemFrom = "SPLIT_ARG",
                Arguments = {"pre1 $item post1", "pre2 $item post2"}
            });
            selections.Implementations[2].Bindings.Add(new EnvironmentBinding {Name = "SPLIT_ARG", Value = "split1" + Path.PathSeparator + "split2"});

            var executor = new Executor(GetMockStore(selections));
            var startInfo = executor.GetStartInfo(selections);
            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                because: "Should combine runner implementation directory with runner command path");
            startInfo.Arguments.Should().Be(
                new[]
                {
                    selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                    selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                    Path.Combine(Test1Path, FileUtils.UnifySlashes(selections.Implementations[1].Commands[0].Path)),
                    selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                    "pre1 split1 post1", "pre2 split1 post2", "pre1 split2 post1", "pre2 split2 post2"
                }.JoinEscapeArguments(),
                because: "Should combine core and additional runner arguments with application implementation directory and command path");

            VerifyEnvironment(startInfo, selections);
        }
示例#6
0
        public void TestGetStartInfoPathlessCommand()
        {
            var selections = SelectionsTest.CreateTestSelections();
            selections.Implementations.Insert(0, new ImplementationSelection {InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")}); // Should be ignored by Executor
            selections.Implementations[1].Commands[0].Path = null;

            var executor = new Executor(GetMockStore(selections));
            var startInfo = executor.GetStartInfo(selections, "--custom");
            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)));
            startInfo.Arguments.Should().Be(
                new[]
                {
                    selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                    selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                    selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                    "--custom"
                }.JoinEscapeArguments());

            VerifyEnvironment(startInfo, selections);
        }
示例#7
0
        public void TestGetStartInfoMainAbsolute()
        {
            var selections = SelectionsTest.CreateTestSelections();
            selections.Implementations.Insert(0, new ImplementationSelection {InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")}); // Should be ignored by Executor

            var executor = new Executor(GetMockStore(selections)) {Main = "/main"};
            var startInfo = executor.GetStartInfo(selections, "--custom");
            startInfo.FileName.Should().Be(
                Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                because: "Should combine runner implementation directory with runner command path");
            startInfo.Arguments.Should().Be(
                new[]
                {
                    selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                    selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                    Path.Combine(Test1Path, "main"),
                    "--custom"
                }.JoinEscapeArguments(),
                because: "Should combine core and additional runner arguments with application implementation directory and main binary override");

            VerifyEnvironment(startInfo, selections);
        }
示例#8
0
        public void TestGetStartInfoWrapper()
        {
            if (!WindowsUtils.IsWindows) Assert.Ignore("Wrapper command-line parsing relies on a Win32 API and therefore will not work on non-Windows platforms");

            var selections = SelectionsTest.CreateTestSelections();
            selections.Implementations.Insert(0, new ImplementationSelection {InterfaceUri = new FeedUri("http://0install.de/feeds/test/dummy.xml")}); // Should be ignored by Executor

            var executor = new Executor(GetMockStore(selections)) {Wrapper = "wrapper --wrapper"};
            var startInfo = executor.GetStartInfo(selections, "--custom");
            startInfo.FileName.Should().Be("wrapper");
            startInfo.Arguments.Should().Be(
                new[]
                {
                    "--wrapper",
                    Path.Combine(Test2Path, FileUtils.UnifySlashes(selections.Implementations[2].Commands[0].Path)),
                    selections.Implementations[2].Commands[0].Arguments[0].ToString(),
                    selections.Implementations[1].Commands[0].Runner.Arguments[0].ToString(),
                    Path.Combine(Test1Path, FileUtils.UnifySlashes(selections.Implementations[1].Commands[0].Path)),
                    selections.Implementations[1].Commands[0].Arguments[0].ToString(),
                    "--custom"
                }.JoinEscapeArguments(),
                because: "Should combine wrapper arguments, runner and application");

            VerifyEnvironment(startInfo, selections);
        }
示例#9
0
 private static void ExpectCommandException(Selections selections)
 {
     var storeMock = new Mock<IStore>(MockBehavior.Loose);
     storeMock.Setup(x => x.GetPath(It.IsAny<ManifestDigest>())).Returns("test path");
     var executor = new Executor(storeMock.Object);
     Assert.Throws<ExecutorException>(() => executor.GetStartInfo(selections), "Invalid Selections should be rejected");
 }