Esempio n. 1
0
        private FileArtifactWithAttributes Convert(FileArtifactWithAttributes file)
        {
            if (AreGraphsSame)
            {
                return(file);
            }

            return(FileArtifactWithAttributes.FromFileArtifact(Convert(file.ToFileArtifact()), file.FileExistence));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a process pip without inferring any accesses from processOperations. This allows the consumer to specify
        /// all file acceses
        /// </summary>
        protected Process CreateProcessWithoutInferringAccesses(
            IEnumerable <FileArtifact> dependencies,
            IEnumerable <FileArtifact> outputs,
            IEnumerable <Operation> processOperations,
            IEnumerable <string> tags = null,
            IEnumerable <EnvironmentVariable> environmentVariables = null,
            IEnumerable <DirectoryArtifact> directoryDependencies  = null,
            IEnumerable <DirectoryArtifact> directoryOutputs       = null,
            IEnumerable <PipId> orderDependencies      = null,
            IEnumerable <AbsolutePath> untrackedPaths  = null,
            IEnumerable <AbsolutePath> untrackedScopes = null,
            FileArtifact?stdOut      = null,
            FileArtifact?stdError    = null,
            PipProvenance provenance = null,
            IEnumerable <AbsolutePath> additionalTempDirectories = null,
            AbsolutePath?tempDirectory           = null,
            IEnumerable <FileArtifact> tempFiles = null /* converted to FileArtifactWithAttributes with FileExistence.Temporary, then concatenated to outputs */)
        {
            Contract.Requires(dependencies != null);
            Contract.Requires(outputs != null);

            FileArtifact executable = TestProcessExecutable;

            untrackedScopes = untrackedScopes ?? new AbsolutePath[0];
            if (tempDirectory != null)

            // Make temp directories untracked scopes to mimic pips built through PipBuilder
            {
                untrackedScopes = untrackedScopes.Concat(new AbsolutePath[] { (AbsolutePath)tempDirectory });
            }
            untrackedScopes = untrackedScopes.Concat(additionalTempDirectories ?? new AbsolutePath[0]);

            // Add C://Windows dependency for test executable
            untrackedScopes = untrackedScopes.Concat(TestProcessDependencies);

            IEnumerable <FileArtifactWithAttributes> outputsWithAttributes = outputs.Select(o => o.WithAttributes());

            if (tempFiles != null)
            {
                outputsWithAttributes = outputsWithAttributes.Concat(tempFiles.Select(tf => FileArtifactWithAttributes.FromFileArtifact(tf, FileExistence.Temporary)));
            }

            var process =
                new Process(
                    executable: executable,
                    workingDirectory: GetWorkingDirectory(),
                    arguments: CreateArguments(processOperations, Context.StringTable),
                    responseFile: FileArtifact.Invalid,
                    responseFileData: PipData.Invalid,
                    environmentVariables: environmentVariables != null
                        ? ReadOnlyArray <EnvironmentVariable> .From(environmentVariables)
                        : ReadOnlyArray <EnvironmentVariable> .Empty,
                    standardInput: FileArtifact.Invalid,
                    standardOutput: stdOut ?? FileArtifact.Invalid,
                    standardError: stdError ?? FileArtifact.Invalid,
                    standardDirectory: GetStandardDirectory(),
                    warningTimeout: null,
                    timeout: null,
                    dependencies: ReadOnlyArray <FileArtifact> .From((new[] { executable }).Concat(dependencies ?? CollectionUtilities.EmptyArray <FileArtifact>())),
                    outputs: ReadOnlyArray <FileArtifactWithAttributes> .From(outputsWithAttributes),
                    directoryDependencies: ReadOnlyArray <DirectoryArtifact> .From(directoryDependencies ?? new DirectoryArtifact[0]),
                    directoryOutputs: ReadOnlyArray <DirectoryArtifact> .From(directoryOutputs ?? new DirectoryArtifact[0]),
                    orderDependencies: orderDependencies != null ? ReadOnlyArray <PipId> .From(orderDependencies) : ReadOnlyArray <PipId> .Empty,
                    untrackedPaths: ReadOnlyArray <AbsolutePath> .From(untrackedPaths ?? ReadOnlyArray <AbsolutePath> .Empty),
                    untrackedScopes: ReadOnlyArray <AbsolutePath> .From(untrackedScopes),
                    tags: ConvertToStringIdArray(tags),
                    successExitCodes: ReadOnlyArray <int> .Empty,
                    semaphores: ReadOnlyArray <ProcessSemaphoreInfo> .Empty,
                    provenance: provenance ?? CreateProvenance(),
                    toolDescription: StringId.Invalid,
                    additionalTempDirectories: ReadOnlyArray <AbsolutePath> .From(additionalTempDirectories ?? ReadOnlyArray <AbsolutePath> .Empty),
                    tempDirectory: tempDirectory ?? default(AbsolutePath)
                    );

            return(process);
        }