Skip to content

Commit

Permalink
Merge branch 'fsharp4' of http://github.com/Microsoft/visualfsharp in…
Browse files Browse the repository at this point in the history
…to fix-123
  • Loading branch information
dsyme committed Jan 29, 2015
2 parents d91cb38 + d17d429 commit 99a552c
Show file tree
Hide file tree
Showing 44 changed files with 630 additions and 131 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ tests/fsharpqa/Source/CodeGen/EmittedIL/QueryExpressionStepping/Utils.dll
tests/fsharpqa/Source/CodeGen/EmittedIL/ComputationExpressions/ComputationExprLibrary.dll

*.csproj.user

*.ide
*.log
*.jrs
*.chk
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
136 changes: 136 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
95 changes: 95 additions & 0 deletions appveyor-build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
@echo on

set APPVEYOR_CI=1

:: Check prerequisites
set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. Please see http://www.microsoft.com/en-us/download/details.aspx?id=40760. && goto :eof

set _gacutilexe="%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe"
if not exist %_gacutilexe% echo Error: Could not find gacutil.exe. && goto :eof

.\.nuget\NuGet.exe restore packages.config -PackagesDirectory packages
@if ERRORLEVEL 1 echo Error: Nuget restore failed && goto :eof

::Build
%_gacutilexe% /i lkg\FSharp-2.0.50726.900\bin\FSharp.Core.dll
@if ERRORLEVEL 1 echo Error: gacutil failed && goto :eof

%_msbuildexe% src\fsharp-proto-build.proj
@if ERRORLEVEL 1 echo Error: compiler proto build failed && goto :eof

ngen install lib\proto\fsc-proto.exe

%_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true
@if ERRORLEVEL 1 echo Error: library debug build failed && goto :eof

%_msbuildexe% src/fsharp-compiler-build.proj /p:UseNugetPackages=true
@if ERRORLEVEL 1 echo Error: compile debug build failed && goto :eof

REM We don't build new net20 FSharp.Core anymore
REM %_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true /p:TargetFramework=net20
REM @if ERRORLEVEL 1 echo Error: library net20 debug build failed && goto :eof

%_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable47
@if ERRORLEVEL 1 echo Error: library portable47 debug build failed && goto :eof

REM Dropped for faster build
REM %_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable7
REM @if ERRORLEVEL 1 echo Error: library portable7 debug build failed && goto :eof


%_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable78
@if ERRORLEVEL 1 echo Error: library portable78 debug build failed && goto :eof

REM Dropped for faster build
REM %_msbuildexe% src/fsharp-library-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable259
REM @if ERRORLEVEL 1 echo Error: library portable259 debug build failed && goto :eof

%_msbuildexe% src/fsharp-library-unittests-build.proj /p:UseNugetPackages=true
@if ERRORLEVEL 1 echo Error: library unittests debug build failed && goto :eof


REM Dropped for faster build
REM %_msbuildexe% src/fsharp-library-unittests-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable47
@REM if ERRORLEVEL 1 echo Error: library unittests debug build failed portable47 && goto :eof

REM Dropped for faster build
REM %_msbuildexe% src/fsharp-library-unittests-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable7
REM @if ERRORLEVEL 1 echo Error: library unittests debug build failed portable7 && goto :eof

REM Dropped for faster build
REM %_msbuildexe% src/fsharp-library-unittests-build.proj /p:UseNugetPackages=true /p:TargetFramework=portable78
REM @if ERRORLEVEL 1 echo Error: library unittests debug build failed portable78 && goto :eof


@echo on
call src\update.cmd debug -ngen

@echo on
call tests\BuildTestTools.cmd debug
REM @if ERRORLEVEL 1 echo Error: 'tests\BuildTestTools.cmd debug' failed && goto :eof

@echo on

pushd tests

REM Disabled while working out perl problem, see https://github.com/Microsoft/visualfsharp/pull/169
REM call RunTests.cmd debug fsharp Smoke
REM @if ERRORLEVEL 1 echo Error: 'RunTests.cmd debug fsharpqa Smoke' failed && goto :eof

REM Disabled while working out perl problem, see https://github.com/Microsoft/visualfsharp/pull/169
REM call RunTests.cmd debug fsharpqa Smoke
REM @if ERRORLEVEL 1 echo Error: 'RunTests.cmd debug fsharpqa Smoke' failed && goto :eof

set PATH=%PATH%;%~dp0%packages\NUnit.Runners.2.6.3\tools\
call RunTests.cmd debug coreunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd debug coreunit' failed && goto :eof

popd



8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
init:
build_script:
- cmd: appveyor-build.cmd
test: off
version: 0.0.1.{build}
artifacts:
- path: Debug
name: Debug
5 changes: 5 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="NUnit.Runners" version="2.6.3" />
</packages>
4 changes: 2 additions & 2 deletions src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,8 @@ lexfltSeparatorTokensOfPatternMatchMisaligned,"The '|' tokens separating rules o
1130,nrInvalidFieldLabel,"Invalid field label"
1132,nrInvalidExpression,"Invalid expression '%s'"
1133,nrNoConstructorsAvailableForType,"No constructors are available for the type '%s'"
1134,nrUnionTypeNeedsQualifiedAccess,"The union type for union case '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the union type ('%s') in the name you are using.""
1134,nrUnionTypeNeedsQualifiedAccess,"The union type for union case '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the union type ('%s') in the name you are using."
1135,nrRecordTypeNeedsQualifiedAccess,"The record type for the record field '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the record type ('%s') in the name you are using."
# -----------------------------------------------------------------------------
# ilwrite.fs errors
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1309,7 +1310,6 @@ nicePrintOtherOverloads1,"+ 1 overload"
nicePrintOtherOverloadsN,"+ %d overloads"
erasedTo,"Erased to"
3156,parsUnfinishedExpression,"Unexpected token '%s' or incomplete expression"
3157,crefQuotationsCantContainByrefTypes,"Quotations cannot contain byref types"
3158,parsAttributeOnIncompleteCode,"Cannot find code target for this attribute, possibly because the code after the attribute is incomplete."
3159,parsTypeNameCannotBeEmpty,"Type name cannot be empty."
3160,buildProblemReadingAssembly,"Problem reading assembly '%s': %s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{TargetFrameworkDirectory};
{Registry:Software\Microsoft\.NETFramework,v4.5,AssemblyFoldersEx};
</AssemblySearchPaths>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition=" '$(TargetFramework)' == 'sl5' ">$(DefineConstants);SILVERLIGHT</DefineConstants>
<DefineConstants>$(DefineConstants);EXTENSIONTYPING</DefineConstants>
Expand Down Expand Up @@ -108,4 +108,10 @@
<Compile Include="SurfaceArea.4.0.fs" Condition="'$(TargetFramework)' == 'net40'"/>
</ItemGroup>
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
<Target Name="BeforeResolveReferences" Condition="'$(UseNugetPackages)'=='true'">
<CreateProperty Value="$(ProjectDir)..\..\..\packages\NUnit.2.6.3\lib\;$(AssemblySearchPaths)">
<Output TaskParameter="Value"
PropertyName="AssemblySearchPaths" />
</CreateProperty>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ open System
open FSharp.Core.Unittests.LibraryTestFx
open NUnit.Framework

module LeakUtils =
// when testing for liveness, the things that we want to observe must always be created in
// a nested function call to avoid the GC (possibly) treating them as roots past the last use in the block.
// We also need something non trivial to disuade the compiler from inlining in Release builds.
type ToRun<'a>(f : unit -> 'a) =
member this.Invoke() = f()

let run (toRun : ToRun<'a>) = toRun.Invoke()

// ---------------------------------------------------

Expand Down Expand Up @@ -103,7 +111,7 @@ type AsyncModule() =

let endMs = DateTime.Now.Millisecond
let delta = endMs - startMs
Assert.IsTrue(abs ((abs delta) - 500) < 50, sprintf "Delta is too big %d" delta)
Assert.IsTrue(abs ((abs delta) - 500) < 400, sprintf "Delta is too big %d" delta)

[<Test>]
member this.``AwaitWaitHandle.TimeoutWithCancellation``() =
Expand Down Expand Up @@ -191,6 +199,41 @@ type AsyncModule() =

for _i = 1 to 50 do test()


[<Test>]
member this.``Async.AwaitWaitHandle does not leak memory`` () =
// This test checks that AwaitWaitHandle does not leak continuations (described in #131),
// We only test the worst case - when the AwaitWaitHandle is already set.
use manualResetEvent = new System.Threading.ManualResetEvent(true)

let tryToLeak() =
let resource =
LeakUtils.ToRun (fun () ->
let resource = obj()
let work =
async {
let! _ = Async.AwaitWaitHandle manualResetEvent
GC.KeepAlive(resource)
return ()
}

work |> Async.RunSynchronously |> ignore
WeakReference(resource))
|> LeakUtils.run

Assert.IsTrue(resource.IsAlive)

GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()

Assert.IsFalse(resource.IsAlive)

// The leak hangs on a race condition which is really hard to trigger in F# 3.0, hence the 100000 runs...
for _ in 1..100 do tryToLeak()

[<Test>]
member this.``AwaitWaitHandle.DisposedWaitHandle2``() =
let wh = new System.Threading.ManualResetEvent(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ type AsyncType() =
return false
with e -> return true
}
Async.RunSynchronously(a, 1000) |> Assert.IsTrue
Async.RunSynchronously(a, 3000) |> Assert.IsTrue

[<Test>]
member this.NonGenericTaskAsyncValueCancellation () =
Expand Down
Loading

0 comments on commit 99a552c

Please sign in to comment.