Ejemplo n.º 1
0
        private BuildXLEngine CreateEngine(bool rememberAllChangedTrackedInputs)
        {
            IFrontEndController Create(PathTable pathTable, SymbolTable symbolTable)
            {
                var frontEndStatistics = new FrontEndStatistics();
                var moduleRegistry     = new ModuleRegistry(symbolTable);

                var frontEndFactory = FrontEndFactory.CreateInstanceForTesting(
                    () => new ConfigurationProcessor(new FrontEndStatistics(), ParseAndEvaluateLogger),
                    new DScriptFrontEnd(frontEndStatistics, ParseAndEvaluateLogger));

                var evaluationScheduler = new EvaluationScheduler(degreeOfParallelism: 1);

                return(new FrontEndHostController(
                           frontEndFactory,
                           evaluationScheduler,
                           moduleRegistry,
                           new FrontEndStatistics(),
                           logger: InitializationLogger,
                           collector: null,
                           collectMemoryAsSoonAsPossible: false));
            }

            BuildXLEngine.PopulateLoggingAndLayoutConfiguration(Configuration, Context.PathTable, bxlExeLocation: null, inTestMode: true);
            var successfulValidation = BuildXLEngine.PopulateAndValidateConfiguration(Configuration, Configuration, Context.PathTable, LoggingContext);

            Assert.True(successfulValidation);

            var engine = BuildXLEngine.Create(LoggingContext, Context, Configuration, new LambdaBasedFrontEndControllerFactory(Create), new BuildViewModel(), rememberAllChangedTrackedInputs: rememberAllChangedTrackedInputs);

            engine.TestHooks = TestHooks;

            return(engine);
        }
Ejemplo n.º 2
0
        public void ValueCacheIsNotStatic()
        {
            var es1     = new EvaluationScheduler(degreeOfParallelism: 1);
            var es2     = new EvaluationScheduler(degreeOfParallelism: 1);
            var key     = "key";
            var counter = 0;
            var res1    = es1.ValueCacheGetOrAdd(key, () => Interlocked.Increment(ref counter));
            var res2    = es2.ValueCacheGetOrAdd(key, () => Interlocked.Increment(ref counter));

            XAssert.AreEqual(2, counter);
            XAssert.AreEqual(1, res1);
            XAssert.AreEqual(2, res2);
        }
Ejemplo n.º 3
0
        public void ValueCacheGetOrAddInvokesFactoryOnlyOnce(int count)
        {
            var evalScheduler = new EvaluationScheduler(degreeOfParallelism: 1);
            var counter       = 0;
            var result        = Enumerable
                                .Range(1, count)
                                .ToArray()
                                .AsParallel()
                                .Select(i => evalScheduler.ValueCacheGetOrAdd("some-key", () => Interlocked.Increment(ref counter)))
                                .ToArray();

            XAssert.AreEqual(1, counter);
            var expectedResult = Enumerable.Range(1, count).Select(i => counter).ToArray();

            XAssert.ArrayEqual(expectedResult, result);
        }