Exemple #1
0
        /// <summary>
        /// Creates an instance of <see cref="ArgumentsBuilder"/>.
        /// </summary>
        public ArgumentsBuilder(ProcessBuilder processBuilder)
        {
            Contract.Requires(processBuilder != null);

            m_processBuilder = processBuilder;
            m_dataBuilder    = new ArgumentsDataBuilder(processBuilder.ArgumentsBuilder);
            m_finished       = false;
        }
Exemple #2
0
        public void TestAddingAndUnifyingIpcPip()
        {
            var fragment = CreatePipGraphFragmentTest(nameof(TestAddingAndUnifyingIpcPip));

            (IIpcMoniker moniker, PipId servicePipId) = TestPipGraphFragmentUtils.CreateService(fragment);

            var          processBuilder          = fragment.GetProcessBuilder();
            var          argumentsBuilder        = new ArgumentsBuilder(processBuilder);
            FileArtifact outputFileToVerify      = fragment.CreateOutputFile("g");
            AbsolutePath outputDirectoryToVerify = fragment.CreateOutputDirectory("d").Path;

            argumentsBuilder
            .AddInputFileOption("/input:", fragment.CreateSourceFile("f"))
            .AddOutputFileOption("/output:", outputFileToVerify.Path)
            .AddOutputDirectoryOption("/outputDir:", outputDirectoryToVerify)
            .Finish();
            (Process process, ProcessOutputs processOutputs) = fragment.ScheduleProcessBuilder(processBuilder);

            XAssert.IsTrue(processOutputs.TryGetOutputDirectory(outputDirectoryToVerify, out var outputDirectory));

            var addFileProcessBuilder = fragment.GetIpcProcessBuilder();

            new ArgumentsBuilder(addFileProcessBuilder)
            .AddStringOption("--command ", "addFile")
            .AddIpcMonikerOption("--ipcMoniker ", moniker)
            .AddInputFileOption("--file ", outputFileToVerify)
            .AddInputDirectoryOption("--directory ", outputDirectory.Root)
            .AddFileIdOption("--fileId ", outputFileToVerify)
            .AddDirectoryIdOption("--directoryId ", outputDirectory.Root)
            .AddVsoHashOption("--vsoHash ", outputFileToVerify)
            .Finish();

            FileArtifact ipcOutputFileToVerify;

            IpcPip ipcPip = fragment.ScheduleIpcPip(
                moniker,
                servicePipId,
                addFileProcessBuilder,
                ipcOutputFileToVerify = fragment.CreateOutputFile("add"),
                false);

            var graph = SerializeAndDeserializeIndependentFragments(fragment, fragment);

            VerifyGraphSuccessfullyConstructed(graph);
            VerifyProducerExists(graph, fragment, outputFileToVerify.Path);
            VerifyProducerExists(graph, fragment, outputDirectoryToVerify);
            VerifyProducerExists(graph, fragment, ipcOutputFileToVerify);

            var remappedOutputFile      = FileArtifact.CreateOutputFile(RemapFragmentPath(fragment, outputFileToVerify.Path));
            var remappedOutputDirectory = DirectoryArtifact.CreateWithZeroPartialSealId(RemapFragmentPath(fragment, outputDirectory.Root));

            PipData expectedArguments = new ArgumentsDataBuilder(Context.StringTable)
                                        .AddStringOption("--command ", "addFile")
                                        .AddIpcMonikerOption("--ipcMoniker ", moniker)
                                        .AddPathOption("--file ", remappedOutputFile.Path)
                                        .AddPathOption("--directory ", remappedOutputDirectory.Path)
                                        .AddFileIdOption("--fileId ", remappedOutputFile)
                                        .AddDirectoryIdOption("--directoryId ", remappedOutputDirectory)
                                        .AddVsoHashOption("--vsoHash ", remappedOutputFile)
                                        .Finish();

            VerifyResultingArguments(graph, fragment, ipcOutputFileToVerify, expectedArguments);
        }