/// <summary>
            /// Get strong fingerprint tree for the entry
            /// </summary>
            public JsonNode GetStrongFingerprintTree()
            {
                var strongEntry           = m_entry.StrongFingerprintEntry;
                var strongFingerprintTree = JsonTree.Deserialize(strongEntry.StrongFingerprintToInputs.Value);
                var pathSetTree           = JsonTree.Deserialize(strongEntry.PathSetHashToInputs.Value);

                return(MergeStrongFingerprintAndPathSetTrees(strongFingerprintTree, pathSetTree));
            }
Exemple #2
0
        public void RepeatNameTest()
        {
            string jsonA = "{\"Object\":[{\"PathSet\":\"VSO0:890000000000000000000000000000000000000000000000000000000000000000\"}," +
                           "{\"ObservedInputs\":[{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"A\":\"\"},{\"P\":\"\"},{\"E\":\"VSO0:4D939FB1E1CE7586909F84F4FEFB0F385B31DD586FF97FC14874BCDB4B2A801400\"}]}]}";

            var    treeA        = JsonTree.Deserialize(jsonA);
            string deserialized = JsonTree.Serialize(treeA);

            XAssert.AreEqual(JsonTree.PrettyPrintJson(jsonA), deserialized);
        }
            private static IReadOnlyList <string> GetDirectoryMembership(FingerprintStore store, string directoryFingerprint)
            {
                if (!store.TryGetContentHashValue(directoryFingerprint, out string storedValue))
                {
                    return(null);
                }

                var directoryMembershipTree = JsonTree.Deserialize(storedValue);

                return(directoryMembershipTree.Children.First.Value.Values);
            }
Exemple #4
0
        public void BasicTest()
        {
            string jsonA = "{\"Object\":[{\"WeakFingerprint\":\"097ED1ED5703816B8F286410076E658260D029BC\"},{\"StrongFingerprint\":\"C926945B5824E1CC7C512D66FB3B8FE869B71936\"}]}";
            string jsonB = "{\"Object\":[{\"WeakFingerprint\":\"097ED1ED5703816B8F286410076E658260D029BC\"},{\"StrongFingerprint\":\"DefinitelyNotTheSameFingerprint\"}]}";

            var treeA = JsonTree.Deserialize(jsonA);
            var treeB = JsonTree.Deserialize(jsonB);

            var changeList = JsonTree.DiffTrees(treeA, treeB);

            AssertUnchanged("WeakFingerprint", changeList);
            AssertChanged("StrongFingerprint", changeList);
        }
Exemple #5
0
        public void NestedNamelessArraysTest()
        {
            var jsonA = "{\"key\":[\"value\", [\"nestedValue\"]]}";

            var treeA   = JsonTree.Deserialize(jsonA);
            var keyNode = JsonTree.FindNodeByName(treeA, "key");

            XAssert.IsTrue(keyNode.Values.Contains("value") && keyNode.Values.Contains("nestedValue"));

            string deserialized = JsonTree.Serialize(treeA);

            XAssert.IsTrue(deserialized.Contains("value") && deserialized.Contains("nestedValue"));

            XAssert.AreNotEqual(JsonTree.PrettyPrintJson(jsonA), deserialized);
        }
Exemple #6
0
        public void RepeatNameTest()
        {
            string jsonA = "{\"Object\":[{\"PathSet\":\"VSO0:890000000000000000000000000000000000000000000000000000000000000000\"}," +
                           "{\"ObservedInputs\":[{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"A\":\"\"},{\"P\":\"\"},{\"E\":\"VSO0:4D939FB1E1CE7586909F84F4FEFB0F385B31DD586FF97FC14874BCDB4B2A801400\"}]}]}";
            string jsonB = "{\"Object\":[{\"PathSet\":\"VSO0:890000000000000000000000000000000000000000000000000000000000000000\"}," +
                           "{\"ObservedInputs\":[{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"CHANGEDVALUE\"},{\"P\":\"\"},{\"P\":\"\"},{\"P\":\"\"},{\"E\":\"VSO0:4D939FB1E1CE7586909F84F4FEFB0F385B31DD586FF97FC14874BCDB4B2A801400\"}]}]}";

            var treeA = JsonTree.Deserialize(jsonA);
            var treeB = JsonTree.Deserialize(jsonB);

            var changeList = JsonTree.DiffTrees(treeA, treeB);

            AssertChanged("P", changeList);
            AssertAdded("P", changeList);
            AssertRemoved("A", changeList);
        }
Exemple #7
0
        public void BasicTest()
        {
            string jsonA = "{\"Dependencies\":[{\"a\":\"valueA\"},{\"b\":\"valueB\"}]}";

            var    treeA        = JsonTree.Deserialize(jsonA);
            string deserialized = JsonTree.Serialize(treeA);

            XAssert.AreEqual(JsonTree.PrettyPrintJson(jsonA), deserialized);

            string jsonB = "{\"Object\":[{\"WeakFingerprint\":\"097ED1ED5703816B8F286410076E658260D029BC\"},{\"StrongFingerprint\":\"C926945B5824E1CC7C512D66FB3B8FE869B71936\"}]}";

            var    treeB         = JsonTree.Deserialize(jsonB);
            string deserializedB = JsonTree.Serialize(treeB);

            XAssert.AreEqual(JsonTree.PrettyPrintJson(jsonB), deserializedB);
        }
Exemple #8
0
        public void MoveObjectsInList()
        {
            string jsonA = "{\"Dependencies\":[{\"a\":\"valueA\"},{\"b\":\"valueB\"}]}";
            string jsonB = "{\"Dependencies\":[{\"b\":\"valueB\"},{\"a\":\"valueA\"}]}";

            var treeA = JsonTree.Deserialize(jsonA);
            var treeB = JsonTree.Deserialize(jsonB);

            var changeList = JsonTree.DiffTrees(treeA, treeB);

            // The change list must detect either "a" or "b" as having moved positions
            // the current algorithm detects happens to detect "a"
            AssertRemoved("a", changeList);
            AssertAdded("a", changeList);
            var printDiff = JsonTree.PrintTreeChangeList(changeList);

            XAssert.IsTrue(printDiff.Contains("a") && printDiff.Contains("valueA"));
            XAssert.IsFalse(printDiff.Contains("b") || printDiff.Contains("valueB"));
        }
Exemple #9
0
        public void LargeNestedObjectTest()
        {
            string jsonA = "{\"Object\":[\"10?B:\\\\out\\\\objects\\\\d\\\\z\\\\bqkrr8zzp30wta21jx01qhl915zwxn\\\\xunit-out\\\\FingerprintS1F4BDE58\\\\2\\\\obj\\\\readonly\\\\obj_0???None?\"," +
                           "\"5?B:\\\\out\\\\objects\\\\d\\\\z\\\\bqkrr8zzp30wta21jx01qhl915zwxn\\\\xunit-out\\\\FingerprintS1F4BDE58\\\\2\\\\obj\\\\obj_1???None?\",{\"ExecutionAndFingerprintOptionsHash\":\"224F5F8E17D4590F2CD7AFAB82AA672D2E0C86E8\"}," +
                           "{\"ContentHashAlgorithmName\":\"Vso0\"},{\"PipType\":\"80\"}," +
                           "{\"Executable\":{\"B:/out/objects/d/z/bqkrr8zzp30wta21jx01qhl915zwxn/Test.BuildXL.FingerprintStore-test-deployment/TestProcess/Test.BuildXL.Executables.TestProcess.exe\":\"VSO0:17426AF3467E448CD8E1146EEE9CFC27107690D39B8091E2882AB164B57ED90400\"}}," +
                           "{\"WorkingDirectory\":\"B:/out/objects/d/z/bqkrr8zzp30wta21jx01qhl915zwxn/xunit-out/FingerprintS1F4BDE58/2/obj/z/7/69c8nz08y0ehxg5vn8ex8g7g59at90/Test.BuildXL.Executables.TestProcess\"}," +
                           "{\"StandardError\":\"{Invalid}\"},{\"StandardOutput\":\"{Invalid}\"}," +
                           "{\"Dependencies\":{\"B:/out/objects/d/z/bqkrr8zzp30wta21jx01qhl915zwxn/Test.BuildXL.FingerprintStore-test-deployment/TestProcess/Test.BuildXL.Executables.TestProcess.exe\":\"VSO0:17426AF3467E448CD8E1146EEE9CFC27107690D39B8091E2882AB164B57ED90400\"}}," +
                           "{\"DirectoryDependencies\":[]},{\"Outputs\":[{\"Path\":\"B:/out/objects/d/z/bqkrr8zzp30wta21jx01qhl915zwxn/xunit-out/ FingerprintS1F4BDE58 / 2 / obj / obj_1\"},{\"Attributes\":\"0\"}]},{\"DirectoryOutputs\":[]}," +
                           "{\"UntrackedPaths\":[]},{\"UntrackedScopes\":[\"C:/WINDOWS\",\"C:/Users/userName/AppData/Local/Microsoft/Windows/INetCache\",\"C:/Users/userName/AppData/Local/Microsoft/Windows/History\"]}," +
                           "{\"HasUntrackedChildProcesses\":\"0\"},{\"PipData\":\"Arguments\"},{\"Escaping\":\"2\"},{\"Separator\":\" \"},{\"Fragments\":\"1\"},{\"PipData\":\"NestedFragment\"},{\"Escaping\":\"2\"},{\"Separator\":\" \"},{\"Fragments\":\"2\"}," +
                           "{\"Environment\":[]},{\"WarningTimeout\":\"-1\"},{\"WarningRegex.Pattern\":\"^\\\\s*((((((\\\\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)|())(()|([^:]*? ))warning( \\\\s*([^: ]*))?\\\\s*:.*$\"},{\"WarningRegex.Options\":\"1\"}," +
                           "{\"ErrorRegex.Pattern\":\".*\"},{\"ErrorRegex.Options\":\"1\"},{\"SuccessExitCodes\":[]}]}";

            var    treeA        = JsonTree.Deserialize(jsonA);
            string deserialized = JsonTree.Serialize(treeA);

            XAssert.AreEqual(JsonTree.PrettyPrintJson(jsonA), deserialized);
        }
            /// <summary>
            /// Adds a directory membership tree as a sub-tree to a given path set tree.
            /// </summary>
            /// <param name="directoryFingerprint">
            /// The directory fingerprint to look up membership.
            /// </param>
            /// <param name="pathSetNode">
            /// The path set node that represents the directory and the parent node.
            /// </param>
            private void AddDirectoryMembershipBranch(string directoryFingerprint, JsonNode pathSetNode)
            {
                if (m_store.TryGetContentHashValue(directoryFingerprint, out string inputs))
                {
                    WriteToPipFile(PrettyFormatJsonField(new KeyValuePair <string, string>(directoryFingerprint, inputs)).ToString());

                    var directoryMembershipTree = JsonTree.Deserialize(inputs);
                    for (var it = directoryMembershipTree.Children.First; it != null; it = it.Next)
                    {
                        JsonTree.ReparentBranch(it.Value, pathSetNode);
                    }
                }
                else
                {
                    // Include a node for the directory membership, but use an error message as the value
                    var placeholder = new JsonNode
                    {
                        Name = directoryFingerprint
                    };
                    placeholder.Values.Add(CacheMissAnalysisUtilities.RepeatedStrings.MissingDirectoryMembershipFingerprint);

                    JsonTree.ReparentBranch(placeholder, pathSetNode);
                }
            }
 /// <summary>
 /// Get weak fingerprint tree for the entry
 /// </summary>
 public JsonNode GetWeakFingerprintTree()
 {
     return(JsonTree.Deserialize(m_entry.WeakFingerprintToInputs.Value));
 }
 private JsonNode GetStrongFingerpintInputTree() => JsonTree.Deserialize(m_entry.StrongFingerprintEntry.StrongFingerprintToInputs.Value);
 /// <summary>
 /// Get pathset tree.
 /// </summary>
 public JsonNode GetPathSetTree() => JsonTree.Deserialize(m_entry.StrongFingerprintEntry.PathSetHashToInputs.Value);