public void SpecFilterRecursiveSubdirectories() { var path = X("/c/users/John Doe/src"); RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Create(m_context.PathTable, path), null, MatchMode.WithinDirectoryAndSubdirectories)); RootFilter actual = RunPositiveFilterParserTest($"spec=\'{path}{Path.DirectorySeparatorChar}*'", expected); XAssert.AreEqual(1, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); XAssert.AreEqual(path, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve[0].ToString(m_context.PathTable)); }
public void DefaultFilterCannotShortCircuitValues() { string filterWithValue = "value='myValue'"; RootFilter filterFromCommandLine = ParseFilter(values: null, commandLineFilter: filterWithValue, defaultFilter: null, out var symbolTable, out var pathTable); XAssert.AreEqual(1, filterFromCommandLine.GetEvaluationFilter(symbolTable, pathTable).ValueNamesToResolve.Count); RootFilter filterFromDefault = ParseFilter(values: null, commandLineFilter: null, defaultFilter: filterWithValue, out symbolTable, out pathTable); XAssert.AreEqual(0, filterFromDefault.GetEvaluationFilter(symbolTable, pathTable).ValueNamesToResolve.Count); XAssert.AreEqual(0, filterFromDefault.GetEvaluationFilter(symbolTable, pathTable).ValueDefinitionRootsToResolve.Count); }
public void SpecFilterFilenamePrefixAndSuffixWildcardWithoutAnyNonWildcardCharacters() { RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Invalid, Path.DirectorySeparatorChar.ToString(), MatchMode.PathPrefixAndSuffixWildcard)); RootFilter actual = RunPositiveFilterParserTest("spec='**'", expected); XAssert.AreEqual(0, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); }
public void SpecFilterFilenamePrefixAndSuffixWildcard() { RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Invalid, $"src{Path.DirectorySeparatorChar}BuildXL.", MatchMode.PathPrefixAndSuffixWildcard)); RootFilter actual = RunPositiveFilterParserTest($"spec='*src{Path.DirectorySeparatorChar}BuildXL.*'", expected); XAssert.AreEqual(0, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); }
public void SpecFilterFilenameSuffixWildcard() { var path = X("/c/src/BuildXL."); RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Invalid, path, MatchMode.PathSuffixWildcard)); RootFilter actual = RunPositiveFilterParserTest($"spec='{path}*'", expected); XAssert.AreEqual(0, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); }
public void SpecFilterFilenamePrefixWildcard() { RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Invalid, ".ds", MatchMode.PathPrefixWildcard)); RootFilter actual = RunPositiveFilterParserTest("spec=\'*.ds'", expected); XAssert.AreEqual(0, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); }
public void SpecFilterFilename() { var path = $"{Path.DirectorySeparatorChar}filename.ds"; RootFilter expected = new RootFilter( CreateSpecFilter(AbsolutePath.Invalid, matchMode: MatchMode.PathPrefixWildcard, pathWildcard: path)); RootFilter actual = RunPositiveFilterParserTest($"spec=\'*{path}'", expected); XAssert.AreEqual(0, actual.GetEvaluationFilter(SymbolTable, PathTable).ValueDefinitionRootsToResolve.Count); }
public void ValueShortCircuit() { RootFilter filter = Deserialize("tag='foo'"); XAssert.AreEqual(0, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); filter = Deserialize("value='foo'"); XAssert.AreEqual(1, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // We may short circuit on value when there is an and filter = Deserialize("(value='foo' and tag='bar')"); XAssert.AreEqual(1, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // We may not short circuit on value when there is an "or" without both sides returning a set of values to filter by filter = Deserialize("(value='foo' or tag='bar')"); XAssert.AreEqual(0, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // We can short circuit an "or" when both return a value filter = Deserialize("(value='foo' or (value='bar' or value='bar2'))"); XAssert.AreEqual(3, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // When both sides of an "and" return values to evaluate we only need to evaluate one side filter = Deserialize("(value='foo' and (value='bar' or value='bar2'))"); XAssert.AreEqual(1, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // A negated value filter must cause all values to evaluate filter = Deserialize("~(value='bar')"); XAssert.AreEqual(0, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); filter = Deserialize("(value='bar' or ~(value='bar2'))"); XAssert.AreEqual(0, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); filter = Deserialize("~(value='bar' and value='bar2')"); XAssert.AreEqual(0, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); // The left value filter may still cause short circuiting with a negated value filter on the right because the operator is "and" filter = Deserialize("(value='bar' and ~(value='bar2'))"); XAssert.AreEqual(1, filter.GetEvaluationFilter(SymbolTable, PathTable).ValueNamesToResolve.Count); }