Skip to content

Commit 3b507c8

Browse files
committed
Enabled skipped test (Issue166)
1 parent 8c1cc46 commit 3b507c8

File tree

4 files changed

+25
-80
lines changed

4 files changed

+25
-80
lines changed

src/Dotnet.Script.Core/Dotnet.Script.Core.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<RepositoryUrl>https://github.com/filipw/dotnet-script.git</RepositoryUrl>
1616
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1717
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
18-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
18+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1919
</PropertyGroup>
2020

2121
<ItemGroup>
@@ -39,7 +39,11 @@
3939
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
4040
<PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
4141
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
42+
<!-- The following references are just quick fixes for issue #166 and issue #268
43+
We need to figure out why we can't load these via the dependency context.
44+
-->
4245
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
46+
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
4347
</ItemGroup>
4448

4549
<ItemGroup>

src/Dotnet.Script.Core/ScriptCompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ private Assembly MapUnresolvedAssemblyToRuntimeLibrary(IDictionary<string, Runti
258258
return loadedAssembly;
259259
}
260260
_logger.Trace($"Redirecting {assemblyName} to {runtimeAssembly.Name}");
261+
261262
return Assembly.LoadFrom(runtimeAssembly.Path);
262263
}
263264
}

src/Dotnet.Script.Tests/ScriptExecutionTests.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,13 @@ public void ShouldHandleIssue129()
7777
Assert.Contains("Bad HTTP authentication header", result.output);
7878
}
7979

80-
#if DISABLED
81-
// This unit test does not work with DLLs. I am not certain what it was testing.
8280
[Fact]
8381
public void ShouldHandleIssue166()
8482
{
85-
// System.Data.SqlClient loads native assets
86-
// No story on *nix yet.
87-
if (_scriptEnvironment.IsWindows)
88-
{
89-
var result = ScriptTestRunner.Default.ExecuteFixture("Issue166");
90-
Assert.Contains("Connection successful", result.output);
91-
}
83+
var result = ScriptTestRunner.Default.ExecuteFixture("Issue166", "--nocache");
84+
Assert.Contains("Connection successful", result.output);
85+
9286
}
93-
#endif
9487

9588
[Fact]
9689
public void ShouldPassUnknownArgumentToScript()

src/Dotnet.Script/Program.cs

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
using Dotnet.Script.Core;
22
using Dotnet.Script.Core.Commands;
33
using Dotnet.Script.Core.Versioning;
4-
using Dotnet.Script.DependencyModel.Context;
54
using Dotnet.Script.DependencyModel.Environment;
65
using Dotnet.Script.DependencyModel.Logging;
7-
using Dotnet.Script.DependencyModel.Runtime;
86
using McMaster.Extensions.CommandLineUtils;
97
using Microsoft.CodeAnalysis;
108
using Microsoft.CodeAnalysis.Scripting;
119
using Microsoft.CodeAnalysis.Scripting.Hosting;
12-
using Microsoft.CodeAnalysis.Text;
1310
using System;
14-
using System.Collections.Generic;
1511
using System.IO;
1612
using System.Linq;
1713
using System.Threading.Tasks;
@@ -206,61 +202,34 @@ private static int Wain(string[] args)
206202

207203
if (scriptFile.HasValue)
208204
{
205+
if (interactive.HasValue())
206+
{
207+
return await RunInteractiveWithSeed(file.Value, logFactory, app.RemainingArguments.Concat(argsAfterDoubleHyphen).ToArray(), packageSources.Values?.ToArray());
208+
}
209209

210-
// if (File.Exists(file.Value))
211-
// {
212-
if (interactive.HasValue())
213-
{
214-
return await RunInteractiveWithSeed(file.Value, logFactory, app.RemainingArguments.Concat(argsAfterDoubleHyphen).ToArray(), packageSources.Values?.ToArray());
215-
}
216-
217-
var fileCommandOptions = new ExecuteScriptCommandOptions
218-
(
219-
new ScriptFile(file.Value),
220-
app.RemainingArguments.Concat(argsAfterDoubleHyphen).ToArray(),
221-
optimizationLevel,
222-
packageSources.Values?.ToArray(),
223-
interactive.HasValue(),
224-
nocache.HasValue()
225-
);
226-
227-
var fileCommand = new ExecuteScriptCommand(ScriptConsole.Default, logFactory);
228-
return await fileCommand.Run<int, CommandLineScriptGlobals>(fileCommandOptions);
210+
var fileCommandOptions = new ExecuteScriptCommandOptions
211+
(
212+
new ScriptFile(file.Value),
213+
app.RemainingArguments.Concat(argsAfterDoubleHyphen).ToArray(),
214+
optimizationLevel,
215+
packageSources.Values?.ToArray(),
216+
interactive.HasValue(),
217+
nocache.HasValue()
218+
);
229219

230-
// }
231-
// else
232-
// {
233-
// if (IsHttpUri(file.Value))
234-
// {
235-
// var downloader = new ScriptDownloader();
236-
// var code = await downloader.Download(file.Value);
237-
// return await RunCode(code, !nocache.HasValue(), logFactory, optimizationLevel, args, Directory.GetCurrentDirectory(), packageSources.Values?.ToArray());
238-
// }
239-
// else
240-
// {
241-
// throw new Exception($"Couldn't find file '{file}'");
242-
// }
243-
// }
244-
}
220+
var fileCommand = new ExecuteScriptCommand(ScriptConsole.Default, logFactory);
221+
return await fileCommand.Run<int, CommandLineScriptGlobals>(fileCommandOptions);
222+
}
245223
else
246224
{
247225
await RunInteractive(!nocache.HasValue(), logFactory, packageSources.Values?.ToArray());
248226
}
249227
return exitCode;
250228
});
251229

252-
253230
return app.Execute(argsBeforeDoubleHyphen);
254231
}
255232

256-
257-
258-
private static bool IsHttpUri(string fileName)
259-
{
260-
return Uri.TryCreate(fileName, UriKind.Absolute, out Uri uriResult)
261-
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
262-
}
263-
264233
private static async Task<int> RunInteractive(bool useRestoreCache, LogFactory logFactory, string[] packageSources)
265234
{
266235
var options = new ExecuteInteractiveCommandOptions(null, Array.Empty<string>(), packageSources);
@@ -274,27 +243,5 @@ private async static Task<int> RunInteractiveWithSeed(string file, LogFactory lo
274243
await new ExecuteInteractiveCommand(ScriptConsole.Default, logFactory).Execute(options);
275244
return 0;
276245
}
277-
278-
279-
private static Task<int> RunCode(string code, bool useRestoreCache, LogFactory logFactory, OptimizationLevel optimizationLevel, IEnumerable<string> args, string currentWorkingDirectory, string[] packageSources)
280-
{
281-
var sourceText = SourceText.From(code);
282-
var context = new ScriptContext(sourceText, currentWorkingDirectory ?? Directory.GetCurrentDirectory(), args, null, optimizationLevel, ScriptMode.Eval, packageSources: packageSources);
283-
return Run(useRestoreCache, logFactory, context);
284-
}
285-
286-
private static Task<int> Run(bool useRestoreCache,LogFactory logFactory, ScriptContext context)
287-
{
288-
var compiler = GetScriptCompiler(useRestoreCache, logFactory);
289-
var runner = new ScriptRunner(compiler, logFactory, ScriptConsole.Default);
290-
return runner.Execute<int>(context);
291-
}
292-
293-
private static ScriptCompiler GetScriptCompiler(bool useRestoreCache, LogFactory logFactory)
294-
{
295-
var runtimeDependencyResolver = new RuntimeDependencyResolver(logFactory, useRestoreCache);
296-
var compiler = new ScriptCompiler(logFactory, runtimeDependencyResolver);
297-
return compiler;
298-
}
299246
}
300247
}

0 commit comments

Comments
 (0)