Example #1
0
        public void TestValidDirectoryId(int pathId, uint partialSealId, bool isSharedOpaque)
        {
            // skip invalid input
            if (partialSealId == 0 && isSharedOpaque)
            {
                return;
            }

            var dir  = new DirectoryArtifact(new AbsolutePath(pathId), partialSealId, isSharedOpaque);
            var dir2 = DirectoryId.Parse(DirectoryId.ToString(dir));

            XAssert.AreEqual(dir, dir2);
        }
Example #2
0
        /// <summary>
        /// This is used only for testing, particulary <code>Client.GetSealedDirectoryContent</code>
        /// </summary>
        internal async Task <IIpcResult> AddDirectoryAsync(string directoryPath, string directoryId, string dropDirectoryPath, bool enableChunkDedup, Client apiClient)
        {
            Contract.Requires(!string.IsNullOrEmpty(directoryPath));
            Contract.Requires(!string.IsNullOrEmpty(directoryId));
            Contract.Requires(dropDirectoryPath != null);

            if (apiClient == null)
            {
                return(new IpcResult(
                           IpcResultStatus.ExecutionError,
                           "ApiClient is not initialized"));
            }

            DirectoryArtifact directoryArtifact = DirectoryId.Parse(directoryId);

            var maybeResult = await apiClient.GetSealedDirectoryContent(directoryArtifact, directoryPath);

            if (!maybeResult.Succeeded)
            {
                return(new IpcResult(
                           IpcResultStatus.GenericError,
                           "could not get the directory content from BuildXL server:" + maybeResult.Failure.Describe()));
            }

            List <SealedDirectoryFile> directoryContent = maybeResult.Result;

            var addFileTasks = directoryContent.Select(
                file =>
            {
                var remoteFileName = Inv(
                    "{0}/{1}",
                    dropDirectoryPath,
                    // we need to convert '\' into '/' because this path would be a part of a drop url
                    GetRelativePath(directoryPath, file.FileName).Replace('\\', '/'));

                var dropItem = new DropItemForBuildXLFile(
                    apiClient,
                    file.FileName,
                    FileId.ToString(file.Artifact),
                    enableChunkDedup,
                    file.ContentInfo,
                    remoteFileName);
                return(AddFileAsync(dropItem));
            }).ToArray();

            var ipcResults = await BuildXL.Utilities.Tasks.TaskUtilities.SafeWhenAll(addFileTasks);

            return(IpcResult.Merge(ipcResults));
        }
Example #3
0
 [InlineData("1:1:not-an-int")] // third field not an int
 public void TestInvalidDirectoryId(string dirIdStr)
 {
     XAssert.IsFalse(DirectoryId.TryParse(dirIdStr, out _));
     Assert.Throws <ArgumentException>(() => DirectoryId.Parse(dirIdStr));
 }