Prexonite, a .NET hosted scripting language with a focus on meta-programming and embedded DSLs
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix bug in ast.test.pxs that caused the suite to delete its \init function. Add tracing to build system to verify that no module is built more often than necessary. Re-enable CIL static and CIL isolated test-profiles, still skipping stored test profiles

Christian Klauser (Feb 10, 2013, 6:10 PM +0100) 271796fa f302961c

+319 -94
+4
Prexonite/Application.cs
··· 30 30 using System.Diagnostics; 31 31 using System.IO; 32 32 using System.Linq; 33 + using JetBrains.Annotations; 33 34 using Prexonite.Compiler; 34 35 using Prexonite.Internal; 35 36 using Prexonite.Modular; ··· 139 140 "Instantiating module {0} did not result in an instantiated initialization function.", 140 141 _module.Name)); 141 142 _initializationFunction = _functionTable[InitializationId]; 143 + Debug.Assert(_InitializationFunction != null); 142 144 } 143 145 144 146 #endregion ··· 226 228 227 229 #region Initialization 228 230 231 + [NotNull] 229 232 private readonly PFunction _initializationFunction; 230 233 private int _initializationOffset; 231 234 ··· 248 251 /// <summary> 249 252 /// Provides access to the initialization function. 250 253 /// </summary> 254 + [NotNull] 251 255 internal PFunction _InitializationFunction 252 256 { 253 257 get { return _initializationFunction; }
+5 -1
Prexonite/Compiler/Build/ITargetDescription.cs
··· 27 27 using System.Collections.Generic; 28 28 using System.Threading; 29 29 using System.Threading.Tasks; 30 + using JetBrains.Annotations; 30 31 using Prexonite.Modular; 31 32 32 33 namespace Prexonite.Compiler.Modular ··· 37 38 { 38 39 public interface ITargetDescription 39 40 { 41 + [NotNull] 40 42 ISet<ModuleName> Dependencies { get; } 41 43 44 + [NotNull] 42 45 ModuleName Name 43 46 { 44 47 get; 45 48 } 46 49 47 - Task<ITarget> BuildAsync(IBuildEnvironment build, IDictionary<ModuleName, Task<ITarget>> dependencies, CancellationToken token); 50 + [NotNull] 51 + Task<ITarget> BuildAsync([NotNull] IBuildEnvironment build, [NotNull] IDictionary<ModuleName, Task<ITarget>> dependencies, CancellationToken token); 48 52 } 49 53 }
+61 -36
Prexonite/Compiler/Build/ManualPlan.cs
··· 25 25 // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 26 27 27 using System; 28 - using System.Collections.Concurrent; 29 28 using System.Collections.Generic; 30 29 using System.Diagnostics; 31 30 using System.IO; ··· 71 70 { 72 71 if (HasUnresolvedDependencies(description)) 73 72 { 74 - var missing = description.Dependencies.Where(d => !TargetDescriptions.Contains(d)); 73 + var missing = description.Dependencies.Where(d => !TargetDescriptions.Contains(d)).ToEnumerationString(); 74 + Plan.Trace.TraceEvent(TraceEventType.Error, 0, 75 + "Failed to resolve the following dependencies of target {0}: {1}", description, missing); 75 76 throw new BuildException( 76 77 string.Format("Not all dependencies of target named {0} have been resolved. The following modules are missing: {1}", 77 - description.Name, missing.ToEnumerationString()), description); 78 + description.Name, missing), description); 78 79 } 79 80 } 80 81 ··· 90 91 return BuildWithMapAsync(description, taskMap, token); 91 92 } 92 93 93 - public IDictionary<ModuleName,Task<ITarget>> BuildAsync(IEnumerable<ModuleName> names, CancellationToken token) 94 + public IDictionary<ModuleName, Task<ITarget>> BuildAsync(IEnumerable<ModuleName> names, CancellationToken token) 94 95 { 95 96 if (names == null) 96 97 throw new ArgumentNullException("names"); 97 98 var taskMap = CreateTaskMap(); 98 99 return 99 100 names 100 - .ToDictionary(name => name , name => BuildWithMapAsync(_prepareBuild(name), taskMap, token)); 101 + .ToDictionary(name => name, name => BuildWithMapAsync(_prepareBuild(name), taskMap, token)); 101 102 } 102 103 103 104 private ITargetDescription _prepareBuild(ModuleName name) ··· 112 113 return new TaskMap<ModuleName, ITarget>(5, TargetDescriptions.Count); 113 114 } 114 115 115 - public Task<Tuple<Application,ITarget>> LoadAsync(ModuleName name, CancellationToken token) 116 + public Task<Tuple<Application, ITarget>> LoadAsync(ModuleName name, CancellationToken token) 116 117 { 117 118 var taskMap = CreateTaskMap(); 118 119 var description = _prepareBuild(name); ··· 121 122 var target = buildTask.Result; 122 123 var app = new Application(target.Module); 123 124 _linkDependencies(taskMap, app, description, token); 124 - return Tuple.Create(app,target); 125 - },token); 125 + return Tuple.Create(app, target); 126 + }, token); 126 127 } 127 128 128 129 private void _linkDependencies(TaskMap<ModuleName, ITarget> taskMap, Application instance, ITargetDescription instanceDescription, CancellationToken token) ··· 145 146 } 146 147 } 147 148 148 - protected Task<IBuildEnvironment> GetBuildEnvironmentAsync(TaskMap<ModuleName,ITarget> taskMap, ITargetDescription description, CancellationToken token) 149 + protected Task<IBuildEnvironment> GetBuildEnvironmentAsync(TaskMap<ModuleName, ITarget> taskMap, ITargetDescription description, CancellationToken token) 149 150 { 150 151 if (description.Dependencies.Count == 0) 151 152 { ··· 161 162 _ => GetBuildEnvironment(taskMap, description, token)); 162 163 } 163 164 164 - protected virtual IBuildEnvironment GetBuildEnvironment(TaskMap<ModuleName,ITarget> taskMap, ITargetDescription description, CancellationToken token) 165 + protected virtual IBuildEnvironment GetBuildEnvironment(TaskMap<ModuleName, ITarget> taskMap, ITargetDescription description, CancellationToken token) 165 166 { 167 + Plan.Trace.TraceEvent(TraceEventType.Verbose, 0, "Get build environment for {0}.", description); 166 168 var buildEnvironment = new DefaultBuildEnvironment(this, description, taskMap, token); 167 169 return buildEnvironment; 168 170 } 169 171 170 - protected Task<ITarget> BuildWithMapAsync(ITargetDescription targetDescription, TaskMap<ModuleName,ITarget> taskMap, CancellationToken token) 172 + protected Task<ITarget> BuildWithMapAsync(ITargetDescription targetDescription, TaskMap<ModuleName, ITarget> taskMap, CancellationToken token) 173 + { 174 + return taskMap.GetOrAdd(targetDescription.Name, 175 + name => 176 + { 177 + Plan.Trace.TraceEvent(TraceEventType.Verbose, 0, "Request build of {0} and its dependencies.", 178 + targetDescription); 179 + return 180 + Task.Factory.StartNew(() => _buildTaskImpl(targetDescription, taskMap, token, name), token) 181 + .Unwrap(); 182 + }); 183 + } 184 + 185 + private Task<ITarget> _buildTaskImpl(ITargetDescription targetDescription, TaskMap<ModuleName, ITarget> taskMap, CancellationToken token, 186 + ModuleName name) 171 187 { 172 - return taskMap.GetOrAdd(targetDescription.Name, name => 173 - Task.Factory.StartNew( () => 174 - { 175 - var desc = TargetDescriptions[name]; 176 - var deps = 177 - desc.Dependencies.Select( 178 - depName => new KeyValuePair<ModuleName, Task<ITarget>>( 179 - depName, 180 - BuildWithMapAsync( 181 - TargetDescriptions[depName], 182 - taskMap, token))); 188 + var desc = TargetDescriptions[name]; 189 + var deps = 190 + desc.Dependencies.Select( 191 + depName => 192 + new KeyValuePair<ModuleName, Task<ITarget>>( 193 + depName, 194 + BuildWithMapAsync( 195 + TargetDescriptions[depName], 196 + taskMap, token))); 183 197 184 - var depMap = new Dictionary<ModuleName, Task<ITarget>>(); 185 - depMap.AddRange(deps); 198 + var depMap = new Dictionary<ModuleName, Task<ITarget>>(); 199 + depMap.AddRange(deps); 186 200 187 - token.ThrowIfCancellationRequested(); 201 + token.ThrowIfCancellationRequested(); 188 202 189 - var buildTask = GetBuildEnvironmentAsync(taskMap, desc, token) 190 - .ContinueWith(bet => 191 - { 192 - var instance = new Application(bet.Result.Module); 193 - _linkDependencies(taskMap,instance, targetDescription, token); 194 - token.ThrowIfCancellationRequested(); 195 - return BuildTargetAsync(bet, desc, depMap, token); 196 - }, token); 197 - return buildTask.Unwrap(); 198 - },token).Unwrap()); 203 + var buildTask = GetBuildEnvironmentAsync(taskMap, desc, 204 + token) 205 + .ContinueWith(bet => 206 + { 207 + var instance = 208 + new Application( 209 + bet.Result.Module); 210 + Plan.Trace.TraceEvent( 211 + TraceEventType.Verbose, 0, 212 + "Linking compile-time dependencies for module {0}.", 213 + bet.Result.Module.Name); 214 + _linkDependencies(taskMap, 215 + instance, targetDescription, 216 + token); 217 + token 218 + .ThrowIfCancellationRequested 219 + (); 220 + return BuildTargetAsync(bet, desc, 221 + depMap, token); 222 + }, token); 223 + return buildTask.Unwrap(); 199 224 } 200 225 201 226 protected virtual Task<ITarget> BuildTargetAsync(Task<IBuildEnvironment> buildEnvironment, ITargetDescription description, Dictionary<ModuleName, Task<ITarget>> dependencies, CancellationToken token) 202 227 { 203 228 var buildTask = description.BuildAsync(buildEnvironment.Result, dependencies, token); 204 - Debug.Assert(buildTask != null, "Task for building target is null.",string.Format("{0}.BuildAsync returned null instead of a Task.", description.GetType().Name)); 229 + Debug.Assert(buildTask != null, "Task for building target is null.", string.Format("{0}.BuildAsync returned null instead of a Task.", description.GetType().Name)); 205 230 return buildTask; 206 231 } 207 232 }
+22 -4
Prexonite/Compiler/Build/ManualTargetDescription.cs
··· 5 5 using System.Linq; 6 6 using System.Threading; 7 7 using System.Threading.Tasks; 8 + using JetBrains.Annotations; 8 9 using Prexonite.Compiler.Build.Internal; 9 10 using Prexonite.Modular; 10 11 ··· 13 14 [DebuggerDisplay("ManualTargetDescription({Name} from {_fileName})")] 14 15 internal class ManualTargetDescription : ITargetDescription 15 16 { 17 + [NotNull] 16 18 private readonly ModuleName _moduleName; 19 + [NotNull] 17 20 private readonly ISource _source; 18 21 /// <summary> 19 22 /// The file name for symbols derived from the supplied reader. Can be null. 20 23 /// </summary> 24 + [CanBeNull] 21 25 private readonly string _fileName; 26 + [NotNull] 22 27 private readonly DependencySet _dependencies; 23 28 24 - internal ManualTargetDescription(ModuleName moduleName, ISource source, string fileName, IEnumerable<ModuleName> dependencies) 29 + internal ManualTargetDescription([NotNull] ModuleName moduleName, [NotNull] ISource source, [CanBeNull] string fileName, [NotNull] IEnumerable<ModuleName> dependencies) 25 30 { 26 - if ((object) moduleName == null) 31 + if (moduleName == null) 27 32 throw new ArgumentNullException("moduleName"); 28 - if ((object) source == null) 33 + if (source == null) 29 34 throw new ArgumentNullException("source"); 30 35 if (dependencies == null) 31 36 throw new ArgumentNullException("dependencies"); ··· 68 73 Enumerable.Empty<Message>()); 69 74 using (reader) 70 75 { 71 - Trace.WriteLine("Building module " + Name); 72 76 token.ThrowIfCancellationRequested(); 77 + Plan.Trace.TraceEvent(TraceEventType.Information, 0, "Building {0}.", this); 78 + Trace.CorrelationManager.StartLogicalOperation("Build"); 73 79 ldr.LoadFromReader(reader, _fileName); 80 + Trace.CorrelationManager.StopLogicalOperation(); 81 + Plan.Trace.TraceEvent(TraceEventType.Verbose, 0, "Done with building {0}, wrapping result in target.", this); 74 82 } 75 83 84 + // ReSharper disable PossibleMultipleEnumeration 76 85 return _createTargetFromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 86 + 77 87 } 78 88 catch (Exception e) 79 89 { 80 90 return DefaultModuleTarget._FromLoader(ldr, 81 91 _createAggregateException(aggregateExceptions.Append(e).ToArray()), 82 92 aggregateMessages); 93 + // ReSharper restore PossibleMultipleEnumeration 83 94 } 84 95 } 85 96 else 86 97 { 98 + Plan.Trace.TraceEvent(TraceEventType.Error, 0, "Not all dependencies of {0} were built successfully. Waiting for other dependencies to finish and then return a failed target.",this); 87 99 Task.WaitAll(dependencies.Values.ToArray<Task>()); 88 100 return _createTargetFromLoader(ldr, aggregateExceptions.ToArray(), aggregateMessages); 89 101 } ··· 98 110 aggregateMessages); 99 111 } 100 112 113 + [CanBeNull] 101 114 private static Exception _createAggregateException(Exception[] aggregateExceptions) 102 115 { 103 116 Exception aggregateException; ··· 108 121 else 109 122 aggregateException = null; 110 123 return aggregateException; 124 + } 125 + 126 + public override string ToString() 127 + { 128 + return string.Format("{{{0} located in {1}}}", _moduleName, _fileName); 111 129 } 112 130 } 113 131 }
+7 -4
Prexonite/Compiler/Build/Plan.cs
··· 24 24 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 25 25 // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 26 27 + using System.Diagnostics; 27 28 using Prexonite.Compiler.Build.Internal; 28 29 29 30 namespace Prexonite.Compiler.Build 30 31 { 31 32 public static class Plan 32 33 { 33 - public static IPlan CreateDefault() 34 - { 35 - return new ManualPlan(); 36 - } 34 + public static readonly TraceSource Trace = new TraceSource("Prexonite.Compiler.Build"); 35 + 36 + public static IPlan CreateDefault() 37 + { 38 + return new ManualPlan(); 39 + } 37 40 } 38 41 }
+6
Prexonite/Compiler/Build/ProvidedTarget.cs
··· 104 104 { 105 105 var tcs = new TaskCompletionSource<ITarget>(); 106 106 tcs.SetResult(this); 107 + Plan.Trace.TraceEvent(TraceEventType.Information, 0, "Used provided target {0}.",this); 107 108 return tcs.Task; 108 109 } 109 110 ··· 127 128 } 128 129 129 130 #endregion 131 + 132 + public override string ToString() 133 + { 134 + return _debuggerDisplay; 135 + } 130 136 131 137 #endregion 132 138 }
+1 -5
Prexonite/Compiler/Loader.cs
··· 33 33 using System.Diagnostics; 34 34 using System.Diagnostics.CodeAnalysis; 35 35 using System.IO; 36 - using System.Linq; 37 36 using System.Reflection; 38 37 using System.Security.AccessControl; 39 38 using System.Text; ··· 47 46 using Prexonite.Compiler.Macro.Commands; 48 47 using Prexonite.Compiler.Symbolic; 49 48 using Prexonite.Modular; 50 - using Prexonite.Properties; 51 49 using Prexonite.Types; 52 50 using Debug = System.Diagnostics.Debug; 53 51 ··· 69 67 { 70 68 } 71 69 72 - [DebuggerStepThrough] 73 70 public Loader(LoaderOptions options) 74 71 { 75 72 if (options == null) ··· 79 76 _functionTargets = new SymbolTable<CompilerTarget>(); 80 77 _functionTargetsIterator = new FunctionTargetsIterator(this); 81 78 82 - CreateFunctionTarget( 83 - ParentApplication._InitializationFunction); 79 + CreateFunctionTarget(ParentApplication._InitializationFunction); 84 80 85 81 if (options.RegisterCommands) 86 82 RegisterExistingCommands();
+4 -2
Prexonite/Modular/Module.cs
··· 13 13 /// <summary> 14 14 /// A Prexonite module is a named container for Prexonite functions and variable declarations. 15 15 /// </summary> 16 - [DebuggerDisplay("module {ModuleName}")] 16 + [DebuggerDisplay("module {Name}")] 17 17 public abstract class Module : IHasMetaTable, IMetaFilter 18 18 { 19 19 public abstract ModuleName Name { get; } ··· 64 64 65 65 public static Module Create(ModuleName moduleName) 66 66 { 67 - return new ModuleImpl(moduleName); 67 + var moduleImpl = new ModuleImpl(moduleName); 68 + Debug.Assert(moduleImpl.Functions.Contains(Application.InitializationId)); 69 + return moduleImpl; 68 70 } 69 71 70 72 public FunctionDeclaration CreateFunction(string id)
+1 -1
Prexonite/Prexonite.csproj
··· 55 55 <DebugType>pdbonly</DebugType> 56 56 <Optimize>true</Optimize> 57 57 <OutputPath>bin\</OutputPath> 58 - <DefineConstants>allowIndex</DefineConstants> 58 + <DefineConstants>allowIndex,TRACE</DefineConstants> 59 59 <ErrorReport>prompt</ErrorReport> 60 60 <WarningLevel>4</WarningLevel> 61 61 <PlatformTarget>AnyCPU</PlatformTarget>
+68 -14
PrexoniteTests/Tests/Configurations/ModuleCache.cs
··· 6 6 using System.Text; 7 7 using System.Threading; 8 8 using System.Threading.Tasks; 9 + using JetBrains.Annotations; 9 10 using Prexonite; 10 11 using Prexonite.Compiler; 11 12 using Prexonite.Compiler.Build; ··· 25 26 26 27 [ThreadStatic] private static ITargetDescription _sysDescription; 27 28 29 + [NotNull] private static readonly TraceSource _trace = 30 + new TraceSource("PrexoniteTests.Tests.Configurations.ModuleCache"); 31 + 28 32 // ReSharper disable InconsistentNaming 29 33 private static ManualPlan Cache 30 34 // ReSharper restore InconsistentNaming ··· 32 36 get 33 37 { 34 38 _lastAccess = DateTime.Now; 35 - return _plan ?? (_plan = new IncrementalPlan()); 39 + if (_plan != null) return _plan; 40 + else 41 + { 42 + _trace.TraceEvent(TraceEventType.Information, 0, "Creating empty build plan for thread {0}.", Thread.CurrentThread.ManagedThreadId); 43 + return _plan = new IncrementalPlan(); 44 + } 36 45 } 37 46 } 38 47 ··· 45 54 46 55 private static ITargetDescription _loadSys() 47 56 { 48 - var sysName = new ModuleName("sys", new Version(0, 0)); 49 - var desc = Cache.CreateDescription(sysName, 50 - Source.FromString(Resources.sys), 51 - "sys.pxs", 52 - Enumerable.Empty<ModuleName>()); 53 - Cache.TargetDescriptions.Add(desc); 54 - Cache.Build(sysName); 55 - // Important: lookup the target description in order to get the cached description 56 - return Cache.TargetDescriptions[sysName]; 57 + Trace.CorrelationManager.StartLogicalOperation("Load runtime system (_loadSys)"); 58 + ITargetDescription sysTarget; 59 + try 60 + { 61 + var sysName = new ModuleName("sys", new Version(0, 0)); 62 + var desc = Cache.CreateDescription(sysName, 63 + Source.FromString(Resources.sys), 64 + "sys.pxs", 65 + Enumerable.Empty<ModuleName>()); 66 + Cache.TargetDescriptions.Add(desc); 67 + Cache.Build(sysName); 68 + // Important: lookup the target description in order to get the cached description 69 + sysTarget = Cache.TargetDescriptions[sysName]; 70 + } 71 + finally 72 + { 73 + Trace.CorrelationManager.StopLogicalOperation(); 74 + } 75 + return sysTarget; 57 76 } 58 77 59 78 public static DateTime LastAccess ··· 85 104 { 86 105 if (IsStale) 87 106 { 107 + _trace.TraceEvent(TraceEventType.Information, 0, "Delete cached build plan for thread {0}.", 108 + Thread.CurrentThread.ManagedThreadId); 88 109 _plan = null; 89 110 } 90 111 } ··· 105 126 var moduleName = new ModuleName(Path.GetFileNameWithoutExtension(path), new Version(0, 0)); 106 127 107 128 if (Cache.TargetDescriptions.Contains(moduleName)) 129 + { 130 + _trace.TraceEvent(TraceEventType.Verbose, 0, 131 + "ModuleCache already contains a description of {0} on thread {1}, no action necessary.", moduleName, 132 + Thread.CurrentThread.ManagedThreadId); 108 133 return; 109 - 134 + } 135 + 110 136 var dependencyNames = 111 137 dependencies.Select(dep => 112 138 new ModuleName(Path.GetFileNameWithoutExtension(dep), new Version(0, 0))).ToArray(); 113 139 114 140 var desc = Cache.CreateDescription(moduleName, Source.FromFile(file,Encoding.UTF8), path, dependencyNames.Append(SysDescription.Name)); 141 + _trace.TraceEvent(TraceEventType.Information, 0, 142 + "Adding new target description for cache on thread {0}: {1}.", Thread.CurrentThread.ManagedThreadId, 143 + desc); 115 144 Cache.TargetDescriptions.Add(desc); 116 - 117 145 } 118 146 119 147 private static IEnumerable<SymbolInfo> _addOriginInfo(ProvidedTarget p) ··· 132 160 { 133 161 EnsureFresh(); 134 162 135 - return Cache.Load(_toModuleName(path)); 163 + var targetModuleName = _toModuleName(path); 164 + Trace.CorrelationManager.StartLogicalOperation("ModuleCache.Load(" + targetModuleName + ")"); 165 + Tuple<Application, ITarget> result; 166 + try 167 + { 168 + result = Cache.Load(targetModuleName); 169 + } 170 + finally 171 + { 172 + Trace.CorrelationManager.StopLogicalOperation(); 173 + _trace.Flush(); 174 + } 175 + 176 + return result; 136 177 } 137 178 138 179 private static ModuleName _toModuleName(string path) ··· 143 184 public static ITarget Build(string path) 144 185 { 145 186 EnsureFresh(); 146 - return Cache.Build(_toModuleName(path)); 187 + var targetModuleName = _toModuleName(path); 188 + Trace.CorrelationManager.StartLogicalOperation("ModuleCache.Build(" + targetModuleName + ")"); 189 + ITarget result; 190 + try 191 + { 192 + result = Cache.Build(targetModuleName); 193 + } 194 + finally 195 + { 196 + Trace.CorrelationManager.StopLogicalOperation(); 197 + } 198 + 199 + return result; 147 200 } 148 201 149 202 public static Task<ITarget> BuildAsync(ModuleName name) 150 203 { 204 + _trace.TraceEvent(TraceEventType.Information, 0, "Requested asynchronous build of module {0}.", name); 151 205 return Cache.BuildAsync(name, CancellationToken.None); 152 206 } 153 207 }
+5 -1
PrexoniteTests/Tests/Configurations/ScriptedUnitTestContainer.cs
··· 53 53 public const string ListTestsId = @"test\list_test"; 54 54 public const string RunTestId = @"test\run_test"; 55 55 public const string PrexoniteUnitTestFramework = @"psr\test.pxs"; 56 + public const string DumpRequestFlag = "request_dump"; 56 57 57 58 protected abstract UnitTestConfiguration Runner { get; } 58 59 ··· 124 125 } 125 126 } 126 127 128 + /// <summary> 129 + /// Prints a stored representation of each application in the compound that has its "request_dump" flag set. 130 + /// </summary> 127 131 public void PrintCompound() 128 132 { 129 133 var tasks = 130 - Application.Compound.Select( 134 + Application.Compound.Where(app => app.Meta[DumpRequestFlag].Switch).Select( 131 135 app => 132 136 new KeyValuePair<ModuleName, Task<ITarget>>(app.Module.Name, ModuleCache.BuildAsync(app.Module.Name))) 133 137 .ToDictionary(k => k.Key, k => k.Value);
+62 -18
PrexoniteTests/Tests/Configurations/VMTestConfigurations.cs
··· 1 1  2 2 // ReSharper disable RedundantUsingDirective 3 + // ReSharper disable RedundantNameQualifier 3 4 using System; 5 + using System.CodeDom.Compiler; 4 6 using System.Reflection; 5 7 using System.Collections.Generic; 6 8 using Prexonite.Types; ··· 15 17 { 16 18 17 19 [TestFixture] 20 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 18 21 internal class ast_Interpreted : Unit_ast 19 22 { 20 23 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 27 30 } 28 31 } 29 32 30 - [TestFixture,Explicit] 33 + [TestFixture] 34 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 31 35 internal class ast_CilStatic : Unit_ast 32 36 { 33 37 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 40 44 } 41 45 } 42 46 43 - [TestFixture,Explicit] 47 + [TestFixture] 48 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 44 49 internal class ast_CilIsolated : Unit_ast 45 50 { 46 51 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 57 62 } 58 63 59 64 [TestFixture, Explicit] 65 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 60 66 internal class ast_StoredInterpreted : Unit_ast 61 67 { 62 68 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 70 76 } 71 77 72 78 [TestFixture, Explicit] 79 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 73 80 internal class ast_StoredCilStatic : Unit_ast 74 81 { 75 82 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 84 91 85 92 86 93 [TestFixture, Explicit] 94 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 87 95 internal class ast_StoredCilIsolated : Unit_ast 88 96 { 89 97 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 100 108 } 101 109 102 110 [TestFixture] 111 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 103 112 internal class lang_ext_Interpreted : Unit_lang_ext 104 113 { 105 114 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 112 121 } 113 122 } 114 123 115 - [TestFixture,Explicit] 124 + [TestFixture] 125 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 116 126 internal class lang_ext_CilStatic : Unit_lang_ext 117 127 { 118 128 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 125 135 } 126 136 } 127 137 128 - [TestFixture,Explicit] 138 + [TestFixture] 139 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 129 140 internal class lang_ext_CilIsolated : Unit_lang_ext 130 141 { 131 142 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 142 153 } 143 154 144 155 [TestFixture, Explicit] 156 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 145 157 internal class lang_ext_StoredInterpreted : Unit_lang_ext 146 158 { 147 159 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 155 167 } 156 168 157 169 [TestFixture, Explicit] 170 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 158 171 internal class lang_ext_StoredCilStatic : Unit_lang_ext 159 172 { 160 173 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 169 182 170 183 171 184 [TestFixture, Explicit] 185 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 172 186 internal class lang_ext_StoredCilIsolated : Unit_lang_ext 173 187 { 174 188 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 185 199 } 186 200 187 201 [TestFixture] 202 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 188 203 internal class macro_Interpreted : Unit_macro 189 204 { 190 205 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 197 212 } 198 213 } 199 214 200 - [TestFixture,Explicit] 215 + [TestFixture] 216 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 201 217 internal class macro_CilStatic : Unit_macro 202 218 { 203 219 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 210 226 } 211 227 } 212 228 213 - [TestFixture,Explicit] 229 + [TestFixture] 230 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 214 231 internal class macro_CilIsolated : Unit_macro 215 232 { 216 233 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 227 244 } 228 245 229 246 [TestFixture, Explicit] 247 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 230 248 internal class macro_StoredInterpreted : Unit_macro 231 249 { 232 250 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 240 258 } 241 259 242 260 [TestFixture, Explicit] 261 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 243 262 internal class macro_StoredCilStatic : Unit_macro 244 263 { 245 264 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 254 273 255 274 256 275 [TestFixture, Explicit] 276 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 257 277 internal class macro_StoredCilIsolated : Unit_macro 258 278 { 259 279 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 270 290 } 271 291 272 292 [TestFixture] 293 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 273 294 internal class misc_Interpreted : Unit_misc 274 295 { 275 296 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 282 303 } 283 304 } 284 305 285 - [TestFixture,Explicit] 306 + [TestFixture] 307 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 286 308 internal class misc_CilStatic : Unit_misc 287 309 { 288 310 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 295 317 } 296 318 } 297 319 298 - [TestFixture,Explicit] 320 + [TestFixture] 321 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 299 322 internal class misc_CilIsolated : Unit_misc 300 323 { 301 324 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 312 335 } 313 336 314 337 [TestFixture, Explicit] 338 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 315 339 internal class misc_StoredInterpreted : Unit_misc 316 340 { 317 341 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 325 349 } 326 350 327 351 [TestFixture, Explicit] 352 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 328 353 internal class misc_StoredCilStatic : Unit_misc 329 354 { 330 355 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 339 364 340 365 341 366 [TestFixture, Explicit] 367 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 342 368 internal class misc_StoredCilIsolated : Unit_misc 343 369 { 344 370 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 355 381 } 356 382 357 383 [TestFixture] 384 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 358 385 internal class struct_Interpreted : Unit_struct 359 386 { 360 387 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 367 394 } 368 395 } 369 396 370 - [TestFixture,Explicit] 397 + [TestFixture] 398 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 371 399 internal class struct_CilStatic : Unit_struct 372 400 { 373 401 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 380 408 } 381 409 } 382 410 383 - [TestFixture,Explicit] 411 + [TestFixture] 412 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 384 413 internal class struct_CilIsolated : Unit_struct 385 414 { 386 415 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 397 426 } 398 427 399 428 [TestFixture, Explicit] 429 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 400 430 internal class struct_StoredInterpreted : Unit_struct 401 431 { 402 432 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 410 440 } 411 441 412 442 [TestFixture, Explicit] 443 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 413 444 internal class struct_StoredCilStatic : Unit_struct 414 445 { 415 446 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 424 455 425 456 426 457 [TestFixture, Explicit] 458 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 427 459 internal class struct_StoredCilIsolated : Unit_struct 428 460 { 429 461 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 441 473 442 474 443 475 [TestFixture] 476 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 444 477 internal class VMTests_Interpreted : Prx.Tests.VMTests 445 478 { 446 479 public VMTests_Interpreted() ··· 449 482 } 450 483 } 451 484 452 - [TestFixture,Explicit] 485 + [TestFixture] 486 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 453 487 internal class VMTests_CilStatic : Prx.Tests.VMTests 454 488 { 455 489 public VMTests_CilStatic() ··· 459 493 } 460 494 } 461 495 462 - [TestFixture,Explicit] 496 + [TestFixture] 497 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 463 498 internal class VMTests_CilIsolated : Prx.Tests.VMTests 464 499 { 465 500 public VMTests_CilIsolated() ··· 471 506 472 507 473 508 [TestFixture] 509 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 474 510 internal class PartialApplication_Interpreted : PrexoniteTests.Tests.PartialApplication 475 511 { 476 512 public PartialApplication_Interpreted() ··· 479 515 } 480 516 } 481 517 482 - [TestFixture,Explicit] 518 + [TestFixture] 519 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 483 520 internal class PartialApplication_CilStatic : PrexoniteTests.Tests.PartialApplication 484 521 { 485 522 public PartialApplication_CilStatic() ··· 489 526 } 490 527 } 491 528 492 - [TestFixture,Explicit] 529 + [TestFixture] 530 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 493 531 internal class PartialApplication_CilIsolated : PrexoniteTests.Tests.PartialApplication 494 532 { 495 533 public PartialApplication_CilIsolated() ··· 501 539 502 540 503 541 [TestFixture] 542 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 504 543 internal class Lazy_Interpreted : PrexoniteTests.Tests.Lazy 505 544 { 506 545 public Lazy_Interpreted() ··· 509 548 } 510 549 } 511 550 512 - [TestFixture,Explicit] 551 + [TestFixture] 552 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 513 553 internal class Lazy_CilStatic : PrexoniteTests.Tests.Lazy 514 554 { 515 555 public Lazy_CilStatic() ··· 519 559 } 520 560 } 521 561 522 - [TestFixture,Explicit] 562 + [TestFixture] 563 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 523 564 internal class Lazy_CilIsolated : PrexoniteTests.Tests.Lazy 524 565 { 525 566 public Lazy_CilIsolated() ··· 531 572 532 573 533 574 [TestFixture] 575 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 534 576 internal class Translation_Interpreted : PrexoniteTests.Tests.Translation 535 577 { 536 578 public Translation_Interpreted() ··· 539 581 } 540 582 } 541 583 542 - [TestFixture,Explicit] 584 + [TestFixture] 585 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 543 586 internal class Translation_CilStatic : PrexoniteTests.Tests.Translation 544 587 { 545 588 public Translation_CilStatic() ··· 549 592 } 550 593 } 551 594 552 - [TestFixture,Explicit] 595 + [TestFixture] 596 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 553 597 internal class Translation_CilIsolated : PrexoniteTests.Tests.Translation 554 598 { 555 599 public Translation_CilIsolated()
+15 -4
PrexoniteTests/Tests/Configurations/VMTestConfigurations.tt
··· 7 7 <#@ import namespace="System.Linq" #> 8 8 <#@ import namespace="System.Collections.Generic" #> 9 9 // ReSharper disable RedundantUsingDirective 10 + // ReSharper disable RedundantNameQualifier 10 11 using System; 12 + using System.CodeDom.Compiler; 11 13 using System.Reflection; 12 14 using System.Collections.Generic; 13 15 using Prexonite.Types; ··· 25 27 var baseName = _toIdentifier(testFile.TestFileName); #> 26 28 27 29 [TestFixture] 30 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 28 31 internal class <#=baseName#>_Interpreted : <#=className#> 29 32 { 30 33 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory(); ··· 37 40 } 38 41 } 39 42 40 - [TestFixture,Explicit] 43 + [TestFixture] 44 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 41 45 internal class <#=baseName#>_CilStatic : <#=className#> 42 46 { 43 47 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{CompileToCil=true}; ··· 50 54 } 51 55 } 52 56 53 - [TestFixture,Explicit] 57 + [TestFixture] 58 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 54 59 internal class <#=baseName#>_CilIsolated : <#=className#> 55 60 { 56 61 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.InMemory{ ··· 67 72 } 68 73 69 74 [TestFixture, Explicit] 75 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 70 76 internal class <#=baseName#>_StoredInterpreted : <#=className#> 71 77 { 72 78 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored(); ··· 80 86 } 81 87 82 88 [TestFixture, Explicit] 89 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 83 90 internal class <#=baseName#>_StoredCilStatic : <#=className#> 84 91 { 85 92 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{CompileToCil=true}; ··· 94 101 95 102 96 103 [TestFixture, Explicit] 104 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 97 105 internal class <#=baseName#>_StoredCilIsolated : <#=className#> 98 106 { 99 107 private readonly UnitTestConfiguration _runner = new UnitTestConfiguration.FromStored{ ··· 114 122 var baseName = vmClass.Substring(vmClass.LastIndexOf('.')+1); #> 115 123 116 124 [TestFixture] 125 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 117 126 internal class <#=baseName#>_Interpreted : <#=vmClass#> 118 127 { 119 128 public <#=baseName#>_Interpreted() ··· 122 131 } 123 132 } 124 133 125 - [TestFixture,Explicit] 134 + [TestFixture] 135 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 126 136 internal class <#=baseName#>_CilStatic : <#=vmClass#> 127 137 { 128 138 public <#=baseName#>_CilStatic() ··· 132 142 } 133 143 } 134 144 135 - [TestFixture,Explicit] 145 + [TestFixture] 146 + [GeneratedCode("VMTestConfiguration.tt","0.0")] 136 147 internal class <#=baseName#>_CilIsolated : <#=vmClass#> 137 148 { 138 149 public <#=baseName#>_CilIsolated()
+37 -1
PrexoniteTests/app.config
··· 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 - <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> 3 + <startup> 4 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> 5 + </startup> 6 + <system.diagnostics> 7 + <sources> 8 + <source name="PrexoniteTests.Tests.Configurations.ModuleCache" 9 + switchName="PrexoniteTests" 10 + switchType="System.Diagnostics.SourceSwitch"> 11 + <!-- use default listeners. use <clear /> to remove those --> 12 + <listeners> 13 + <remove name="Default" /> 14 + <add name="build.log" /> 15 + </listeners> 16 + </source> 17 + <source name="Prexonite.Compiler.Build" 18 + switchName="PrexoniteTests" 19 + switchType="System.Diagnostics.SourceSwitch"> 20 + <listeners> 21 + <remove name="Default" /> 22 + <add name="build.log" /> 23 + </listeners> 24 + 25 + </source> 26 + </sources> 27 + <switches> 28 + <add name="PrexoniteTests" value="Verbose" /> 29 + </switches> 30 + <sharedListeners> 31 + <add name="build.log" 32 + type="System.Diagnostics.TextWriterTraceListener" 33 + initializeData="build.log" 34 + traceOutputOptions="DateTime, ThreadId" 35 + > 36 + </add> 37 + </sharedListeners> 38 + </system.diagnostics> 39 + </configuration>
+1 -2
PrexoniteTests/psr-tests/macro.test.pxs
··· 174 174 175 175 function test_reports[test] 176 176 { 177 - var ldr = new Prexonite::Compiler::Loader(asm(ldr.eng),asm(ldr.app)); 178 - test\execute_single_macro(ldr,asm(ldr.app).Functions["test_reports\\macro"]); 177 + var ldr = run_single_macro_inspect(asm(ldr.app).Functions[entityref_to(test_reports\macro).Id]); 179 178 assert_eq(ldr.Errors.Count,1,"Exactly one error expected."); 180 179 assert_eq(ldr.Warnings.Count,1,"Exactly one warning expected."); 181 180 assert_eq(ldr.Infos.Count,1,"Exactly one info expected.");
+20 -1
Prx/psr/test/meta_macro.pxs
··· 75 75 } 76 76 } 77 77 78 - function test\run_single_macro as run_single_macro(testMacro) 78 + // Runs the specified macro in its own module (linked to the current application compound) 79 + // Will then unlink the temporary module, but return the loader used to execute the macro for inspection. 80 + function test\run_single_macro_inspect as run_single_macro_inspect(testMacro) 79 81 [ 80 82 Add Prexonite to Imports; 81 83 Add Prexonite::Types to Imports; ··· 97 99 var testApp = asm(ldr.app); 98 100 99 101 var ldr; 102 + var oldCompCount = testApp.Compound.Count; 100 103 try { 101 104 ::Application.Link(testApp,app); 102 105 ldr = new ::Loader(eng, app); ··· 105 108 if(app.IsLinkedTo(testApp)) 106 109 app.Unlink(); 107 110 } 111 + 112 + if(testApp.Compound.Count != oldCompCount) 113 + throw "meta_macro did not successfully restore the original application compound."; 114 + 115 + return ldr; 116 + } 117 + 118 + function test\run_single_macro as run_single_macro(testMacro) 119 + [ 120 + Add Prexonite to Imports; 121 + Add Prexonite::Types to Imports; 122 + Add Prexonite::Compiler to Imports; 123 + Add Prexonite::Compiler::Ast to Imports; 124 + ] 125 + { 126 + var ldr = run_single_macro_inspect(testMacro); 108 127 109 128 ldr.Warnings >> each(println(?)); 110 129 if(ldr.Errors.Count > 0)