Skip to content

Commit cd93a37

Browse files
committed
separate fsi tooltask for tests
1 parent 4c5a0dd commit cd93a37

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

FSharpTests.Directory.Build.targets

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<Project>
22

3-
<UsingTask TaskName="Fsi" AssemblyFile="$(FSharpBuildAssemblyFile)" />
3+
<UsingTask TaskName="FsiTestTask" AssemblyFile="$(FSharpBuildAssemblyFile)" />
44

55
<Target
66
Name="RunFSharpScript"
77
Returns=""
88
DependsOnTargets="$(CoreCompileDependsOn)"
99
>
10-
<Fsi Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
10+
<FsiTestTask
11+
Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
1112
CodePage="$(CodePage)"
1213
DefineConstants="$(DefineConstants)"
1314
DisabledWarnings="$(NoWarn)"
@@ -34,7 +35,7 @@
3435
WarningsAsErrors="$(WarningsAsErrors)">
3536
<Output TaskParameter="CommandLineArgs" ItemName="FsiCommandLineArgs" />
3637
<Output TaskParameter="TextOutput" ItemName="FsiTextOutput" />
37-
</Fsi>
38+
</FsiTestTask>
3839

3940
<ItemGroup>
4041
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)" />

src/FSharp.Build/FSharp.Build.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<Compile Include="FSharpCommandLineBuilder.fs" />
3939
<Compile Include="Fsc.fs" />
4040
<Compile Include="Fsi.fs" />
41+
<Compile Include="FsiTestTask.fs" />
4142
<Compile Include="FSharpEmbedResourceText.fs" />
4243
<Compile Include="FSharpEmbedResXSource.fs" />
4344
<Compile Include="WriteCodeFragment.fs" />

src/FSharp.Build/Fsi.fs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,6 @@ type public Fsi() as this =
161161

162162
builder
163163

164-
let outputWriter = new StringWriter()
165-
166-
override _.LogEventsFromTextOutput(line, msgImportance) =
167-
outputWriter.WriteLine(line)
168-
base.LogEventsFromTextOutput(line, msgImportance)
169-
170164
// --codepage <int>: Specify the codepage to use when opening source files
171165
member _.CodePage
172166
with get () = codePage
@@ -289,9 +283,6 @@ type public Fsi() as this =
289283
with get () = List.toArray commandLineArgs
290284
and set value = commandLineArgs <- List.ofArray value
291285

292-
[<Output>]
293-
member _.TextOutput = outputWriter.ToString()
294-
295286
// ToolTask methods
296287
override _.ToolName = "fsi.exe"
297288

src/FSharp.Build/FsiTestTask.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace FSharp.Build.Tests
4+
5+
open System.IO
6+
open Microsoft.Build.Framework
7+
8+
/// MsBuild tool task for capturing stdout from test scripts.
9+
type FsiTestTask() =
10+
inherit FSharp.Build.Fsi()
11+
12+
// Just to keep a reasonable amount of test scipt output.
13+
let outputWriter = new StringWriter()
14+
15+
override _.LogEventsFromTextOutput(line, msgImportance) =
16+
outputWriter.WriteLine(line)
17+
base.LogEventsFromTextOutput(line, msgImportance)
18+
19+
[<Output>]
20+
member _.TextOutput = outputWriter.ToString()

0 commit comments

Comments
 (0)