|
5 | 5 | using System.Reflection;
|
6 | 6 | using System.Security.Cryptography;
|
7 | 7 | using Dotnet.Script.Core;
|
| 8 | +using Dotnet.Script.DependencyModel.Context; |
8 | 9 | using Dotnet.Script.DependencyModel.Environment;
|
9 | 10 | using Dotnet.Script.DependencyModel.Runtime;
|
10 | 11 | using Microsoft.CodeAnalysis;
|
@@ -211,15 +212,20 @@ public TestClass()
|
211 | 212 | IMapper mapper = Mapper.CreateNew();
|
212 | 213 | }
|
213 | 214 | }";
|
214 |
| - var wd = Path.GetDirectoryName(typeof(ScriptExecutionTests).Assembly.Location); |
215 |
| - var compiler = new ScriptCompiler(new ScriptLogger(Console.Error, true), new RuntimeDependencyResolver(type => ((level, message) => {}))); |
216 |
| - var res = compiler.CreateCompilationContext<object, InteractiveScriptGlobals>(new ScriptContext(SourceText.From(code), wd, Enumerable.Empty<string>())); |
217 |
| - using(var ms = File.OpenWrite(Path.Combine(wd, "Issue235.dll"))) |
| 215 | + var logger = new ScriptLogger(Console.Error, true); |
| 216 | + var runtimeDependencyResolver = new RuntimeDependencyResolver(type => ((level, message) => {})); |
| 217 | + var compiler = new ScriptCompiler(logger, runtimeDependencyResolver); |
| 218 | + //Copied from Execute(string fixture, params string[] arguments) |
| 219 | + //Probably there should be a better place for this |
| 220 | + var workingDirectory = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "TestFixtures", "Issue235"); |
| 221 | + var scriptContext = new ScriptContext(SourceText.From(code), workingDirectory, Enumerable.Empty<string>(), scriptMode: ScriptMode.REPL); |
| 222 | + var compilationResult = compiler.CreateCompilationContext<object, InteractiveScriptGlobals>(scriptContext); |
| 223 | + using(var ms = File.OpenWrite(Path.Combine(workingDirectory, "Issue235.dll"))) |
218 | 224 | {
|
219 |
| - res.Script.GetCompilation().Emit(ms); |
| 225 | + compilationResult.Script.GetCompilation().Emit(ms); |
220 | 226 | }
|
221 |
| - // var result = Execute(Path.Combine("Issue235", "Issue235.csx")); |
222 |
| - // Assert.Contains("Hello World!", result.output); |
| 227 | + var result = Execute(Path.Combine("Issue235", "Issue235.csx")); |
| 228 | + Assert.Contains("Hello World!", result.output); |
223 | 229 | }
|
224 | 230 |
|
225 | 231 | private static (string output, int exitCode) Execute(string fixture, params string[] arguments)
|
|
0 commit comments