public void RootTranslation() { var rootTranslator = new RootTranslator(); var pathTable = Context.PathTable; // Source is shorter than target var shortCaseSourceTranslatedRootPath = GetFullPath(pathTable, "ShortSource").Expand(pathTable); var shortCaseTargetTranslatedRootPath = GetFullPath(pathTable, "Short___Target").Expand(pathTable); rootTranslator.AddTranslation( shortCaseSourceTranslatedRootPath.ExpandedPath, shortCaseTargetTranslatedRootPath.ExpandedPath); // Source is longer than target var longCaseSourceTranslatedRootPath = GetFullPath(pathTable, "LongSourceSource").Expand(pathTable); var longCaseTargetTranslatedRootPath = GetFullPath(pathTable, "LongTarget").Expand(pathTable); rootTranslator.AddTranslation( longCaseSourceTranslatedRootPath.ExpandedPath, longCaseTargetTranslatedRootPath.ExpandedPath); rootTranslator.Seal(); var cache = new CacheCoreArtifactContentCache(Session, rootTranslator); // SHORTER SOURCE, SAME ROOT: Path should NOT be translated VerifyExpandedPathForCacheEquals(cache, shortCaseSourceTranslatedRootPath, shortCaseSourceTranslatedRootPath); // LONGER SOURCE, SAME ROOT: Path SHOULD be translated VerifyExpandedPathForCacheEquals(cache, longCaseSourceTranslatedRootPath, longCaseTargetTranslatedRootPath); }
/// <summary> /// Returns a cache initializer to a real instance of the cache /// </summary> protected CacheInitializer GetRealCacheInitializerForTests() { var tempDir = OperatingSystemHelper.IsUnixOS ? "/tmp/buildxl-temp" : TemporaryDirectory; string cacheDirectory = Path.Combine(tempDir, "cache"); AbsolutePath cacheConfigPath = WriteTestCacheConfigToDisk(cacheDirectory); var translator = new RootTranslator(); if (TryGetSubstSourceAndTarget(out var substSource, out var substTarget)) { translator.AddTranslation(substTarget, substSource); } translator.Seal(); Configuration.Cache.CacheConfigFile = cacheConfigPath; Configuration.Cache.CacheLogFilePath = AbsolutePath.Create(Context.PathTable, tempDir).Combine(Context.PathTable, "cache.log"); var maybeCacheInitializer = CacheInitializer.GetCacheInitializationTask( LoggingContext, Context.PathTable, cacheDirectory, Configuration.Cache, translator, recoveryStatus: false, cancellationToken: CancellationToken.None).GetAwaiter().GetResult(); if (!maybeCacheInitializer.Succeeded) { throw new BuildXLException("Unable to initialize the real cache: " + maybeCacheInitializer.Failure.DescribeIncludingInnerFailures()); } return(maybeCacheInitializer.Result); }
public void RootTranslationDifferentRoots() { var rootTranslator = new RootTranslator(); var pathTable = Context.PathTable; // Source is shorter than target but has different root var shortCaseChangeRootSourceTranslatedRootPath = ChangeRoot(GetFullPath(pathTable, "ShortChangeRootSrc"), pathTable, newRoot: 'A'); var shortCaseChangeRootTargetTranslatedRootPath = ChangeRoot(GetFullPath(pathTable, "ShortChangeRootTarget"), pathTable, newRoot: 'B'); rootTranslator.AddTranslation( shortCaseChangeRootSourceTranslatedRootPath.ExpandedPath, shortCaseChangeRootTargetTranslatedRootPath.ExpandedPath); rootTranslator.Seal(); var cache = new CacheCoreArtifactContentCache(Session, rootTranslator); // SHORTER SOURCE, DIFFERENT ROOT: Path SHOULD be translated VerifyExpandedPathForCacheEquals(cache, shortCaseChangeRootSourceTranslatedRootPath, shortCaseChangeRootTargetTranslatedRootPath); }
private void AddTranslation(string sourcePath, string targetPath) { m_translator.AddTranslation(sourcePath, targetPath); }