Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for netcore / netstandard1.6 #140

Merged
merged 9 commits into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 102 additions & 15 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
@@ -1,21 +1,108 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Mark that this target file has been loaded. -->
<IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
<IsPaketRestoreTargetsFileLoaded>true</IsPaketRestoreTargetsFileLoaded>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
<!-- Paket command -->
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
</PropertyGroup>

<Target Name="PaketRestore" BeforeTargets="_GenerateProjectRestoreGraphPerFramework;_GenerateRestoreGraphWalkPerFramework;CollectPackageReferences" >

<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)" ' />

<PropertyGroup>
<PaketReferencesFilePath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references</PaketReferencesFilePath>
</PropertyGroup>

<ReadLinesFromFile File="$(PaketReferencesFilePath)" >
<Output TaskParameter="Lines" ItemName="PaketReferencesFileLines"/>
</ReadLinesFromFile>

<ItemGroup Condition=" '@(PaketReferencesFileLines)' != '' " >
<PaketReferencesFileLinesInfo Include="@(PaketReferencesFileLines)" >
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
</PaketReferencesFileLinesInfo>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
</PropertyGroup>

</Target>

<Target Name="PaketDisableDirectPack" AfterTargets="_IntermediatePack" BeforeTargets="GenerateNuspec" >
<PropertyGroup>
<ContinuePackingAfterGeneratingNuspec>false</ContinuePackingAfterGeneratingNuspec>
</PropertyGroup>
</Target>

<UsingTask TaskName="Paket.Build.Tasks.PaketRestoreTask" AssemblyFile="PaketRestoreTask.dll" />

<Target Name="PaketRestore" BeforeTargets="_GenerateRestoreGraphWalkPerFramework" >
<Exec Command="$(MSBuildThisFileDirectory)\paket.exe restore --project $(MSBuildProjectFullPath)" />

<!-- Write out package references for NETCore -->
<PaketRestoreTask
ProjectUniqueName="$(MSBuildProjectFullPath)"
PackageReferences="@(PackageReference)"
TargetFrameworks="$(TargetFramework)">
<Output TaskParameter="NewPackageReferences" ItemName="PackageReference" />
<Output TaskParameter="AlternativeConfigFile" ItemName="RestoreConfigFile" />
</PaketRestoreTask>
</Target>
<Target Name="PaketOverrideNuspec" AfterTargets="GenerateNuspec" >
<PropertyGroup>
<PaketReferencesFilePath>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references</PaketReferencesFilePath>
<ContinuePackingAfterGeneratingNuspec>true</ContinuePackingAfterGeneratingNuspec>
</PropertyGroup>

<ItemGroup>
<_NuspecFiles Include="$(BaseIntermediateOutputPath)*.nuspec"/>
</ItemGroup>

<Exec Command='$(PaketCommand) fix-nuspec file "@(_NuspecFiles)" references-file "$(PaketReferencesFilePath)" ' />

<ConvertToAbsolutePath Condition="@(_NuspecFiles) != ''" Paths="@(_NuspecFiles)">
<Output TaskParameter="AbsolutePaths" PropertyName="NuspecFileAbsolutePath" />
</ConvertToAbsolutePath>

<!-- Call Pack -->
<PackTask PackItem="$(PackProjectInputFile)"
PackageFiles="@(_PackageFiles)"
PackageFilesToExclude="@(_PackageFilesToExclude)"
PackageVersion="$(PackageVersion)"
PackageId="$(PackageId)"
Title="$(Title)"
Authors="$(Authors)"
Description="$(Description)"
Copyright="$(Copyright)"
RequireLicenseAcceptance="$(PackageRequireLicenseAcceptance)"
LicenseUrl="$(PackageLicenseUrl)"
ProjectUrl="$(PackageProjectUrl)"
IconUrl="$(PackageIconUrl)"
ReleaseNotes="$(PackageReleaseNotes)"
Tags="$(PackageTags)"
TargetPathsToAssemblies="@(_TargetPathsToAssemblies->'%(FinalOutputPath)')"
TargetPathsToSymbols="@(_TargetPathsToSymbols)"
TargetFrameworks="@(_TargetFrameworks)"
AssemblyName="$(AssemblyName)"
PackageOutputPath="$(PackageOutputAbsolutePath)"
IncludeSymbols="$(IncludeSymbols)"
IncludeSource="$(IncludeSource)"
PackageTypes="$(PackageType)"
IsTool="$(IsTool)"
RepositoryUrl="$(RepositoryUrl)"
RepositoryType="$(RepositoryType)"
SourceFiles="@(_SourceFiles->Distinct())"
NoPackageAnalysis="$(NoPackageAnalysis)"
MinClientVersion="$(MinClientVersion)"
Serviceable="$(Serviceable)"
AssemblyReferences="@(_References)"
ContinuePackingAfterGeneratingNuspec="$(ContinuePackingAfterGeneratingNuspec)"
NuspecOutputPath="$(BaseIntermediateOutputPath)"
IncludeBuildOutput="$(IncludeBuildOutput)"
BuildOutputFolder="$(BuildOutputTargetFolder)"
ContentTargetFolders="$(ContentTargetFolders)"
RestoreOutputPath="$(RestoreOutputAbsolutePath)"
NuspecFile="$(NuspecFileAbsolutePath)"
NuspecBasePath="$(NuspecBasePath)"
NuspecProperties="$(NuspecProperties)"/>
</Target>

</Project>
8 changes: 4 additions & 4 deletions .semver
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
:major: 4
:minor: 1
:patch: 1
:special: ''
:major: 5
:minor: 0
:patch: 0
:special: 'beta'
:metadata: ''
18 changes: 16 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@ language: csharp

mono:
- 4.6.1
- 4.8.0
- 4.8.1
- latest # => "stable release"
- weekly # => "latest commits"

os:
- osx
- linux

dist: trusty
sudo: required

dotnet: 1.0.1

install:
# See details at https://github.com/NuGet/Home/issues/2163
# this may be required because of an underlying bug in mono. It may
# also be induced by us because we have an extra nuget.config source.
- ulimit -n 2048

- rvm install 2.2.3
- gem install bundler
- sudo apt-get update -y

script:
- bundle && bundle exec rake
Expand All @@ -19,3 +32,4 @@ matrix:
allow_failures:
- mono: latest
- mono: weekly
- os: osx
4 changes: 2 additions & 2 deletions DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
conventions and the ones used by this project.
* Visual Studio - [EditorConfig VS Extension][ec-vs]
* vscode - [EditorConfig VScode Extension][ec-vsc]
1. Install the latest version of the [**netcore SDK**][netcore-sdk]
1. Install the `1.0.1` version of the [**netcore SDK**][netcore-sdk]
1. You need [albacore][ac] installed to build like I do – it needs to build
with the `Rakefile` or I won't accept the PR.
1. New features:
Expand Down Expand Up @@ -62,5 +62,5 @@

[ec-vs]: https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig
[ec-vsc]: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
[netcore-sdk]: https://github.com/dotnet/cli#installers-and-binaries
[netcore-sdk]: https://github.com/dotnet/core/blob/master/release-notes/download-archives/1.0.4-download.md
[ac]: https://github.com/albacore/albacore
20 changes: 10 additions & 10 deletions Expecto.Sample/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
Expand Down Expand Up @@ -49,14 +59,4 @@
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding></runtime></configuration>
4 changes: 2 additions & 2 deletions Expecto.Tests/Expecto.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE;FSCHECK_TESTS</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\Expecto.Tests.xml</DocumentationFile>
Expand All @@ -29,7 +29,7 @@
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;FSCHECK_TESTS</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\Expecto.Tests.xml</DocumentationFile>
Expand Down
54 changes: 43 additions & 11 deletions Expecto.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open System
open System.Text.RegularExpressions
open System.Threading
open System.IO
open System.Reflection
open Expecto
open Expecto.Impl
open System.Globalization
Expand All @@ -18,10 +19,19 @@ module Dummy =
[<Tests>]
let testB() = TestLabel ("test B", TestList ([], Normal), Normal)

let thisModuleType = lazy Type.GetType "Expecto.Tests+Dummy, Expecto.Tests"
let thisAssemblyName =
#if NETCOREAPP1_1
"Expecto.netcore.Tests"
#else
"Expecto.Tests"
#endif

let thisModuleNameQualified = sprintf "Expecto.Tests+Dummy, %s" thisAssemblyName
let thisModuleType = lazy Type.GetType(thisModuleNameQualified, throwOnError=true)

module EmptyModule =
let thisModuleType = lazy Type.GetType "Expecto.Tests+EmptyModule, Expecto.Tests"
let thisModuleNameQualified = sprintf "Expecto.Tests+EmptyModule, %s" Dummy.thisAssemblyName
let thisModuleType = lazy Type.GetType(thisModuleNameQualified, throwOnError=true)

let (==?) actual expected = Expect.equal expected actual ""

Expand Down Expand Up @@ -88,6 +98,7 @@ let tests =
r.Value.duration ==? TimeSpan.FromMilliseconds 27.
]

#if FSCHECK_TESTS
testList "TestResultCounts" [
let inline testProp fn =
let config =
Expand Down Expand Up @@ -120,6 +131,7 @@ let tests =
true
)
]
#endif

testList "Exception handling" [
testCaseAsync "Expecto ignore" <| async {
Expand Down Expand Up @@ -201,10 +213,10 @@ let expecto =
let t = Test.filter ((=) "a") tests |> Test.toTestCodeList |> Seq.toList
t.Length ==? 1
yield testCase "with nested testcase" <| fun _ ->
let t = Test.filter (String.contains "d") tests |> Test.toTestCodeList |> Seq.toList
let t = Test.filter (fun (s: string) -> s.Contains "d") tests |> Test.toTestCodeList |> Seq.toList
t.Length ==? 1
yield testCase "with one testlist" <| fun _ ->
let t = Test.filter (String.contains "c") tests |> Test.toTestCodeList |> Seq.toList
let t = Test.filter (fun (s: string) -> s.Contains "c") tests |> Test.toTestCodeList |> Seq.toList
t.Length ==? 2
yield testCase "with no results" <| fun _ ->
let t = Test.filter ((=) "z") tests |> Test.toTestCodeList |> Seq.toList
Expand Down Expand Up @@ -236,7 +248,7 @@ let expecto =

testList "Reflection" [
let getMember name =
Dummy.thisModuleType.Value.GetMember name
Dummy.thisModuleType.Value.GetTypeInfo().GetMember name
|> Array.tryFind (fun _ -> true)
let getTest =
getMember
Expand Down Expand Up @@ -366,21 +378,35 @@ let expecto =

testList "transformations" [
testCaseAsync "multiple cultures" <| async {
let getCurrentCulture () : CultureInfo =
#if RESHAPED_THREAD_CULTURE
System.Globalization.CultureInfo.CurrentCulture
#else
System.Threading.Thread.CurrentThread.CurrentCulture
#endif

let setCurrentCulture (culture : CultureInfo) =
#if RESHAPED_THREAD_CULTURE
System.Globalization.CultureInfo.CurrentCulture <- culture
#else
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
#endif

let withCulture culture test =
async {
let c = Thread.CurrentThread.CurrentCulture
let c = getCurrentCulture()
try
Thread.CurrentThread.CurrentCulture <- culture
setCurrentCulture culture
match test with
| Sync test ->
test()
| Async test ->
do! test
| AsyncFsCheck (config, _, test) ->
do! Option.orDefault FsCheckConfig.defaultConfig config
|> test
let configOrDefault = match config with | Some c -> c | _ -> FsCheckConfig.defaultConfig
do! configOrDefault |> test
finally
Thread.CurrentThread.CurrentCulture <- c
setCurrentCulture c
}

let testWithCultures (cultures: #seq<CultureInfo>) =
Expand All @@ -396,7 +422,7 @@ let expecto =

let cultures =
["en-US"; "es-AR"; "fr-FR"]
|> List.map CultureInfo.GetCultureInfo
|> List.map CultureInfo

let culturizedTests = testWithCultures cultures atest

Expand Down Expand Up @@ -734,6 +760,8 @@ let expecto =
]
]

#if FSCHECK_TESTS

let inline popCount (i:uint16) =
let mutable v = uint32 i
v <- v - ((v >>> 1) &&& 0x55555555u)
Expand All @@ -752,6 +780,8 @@ let popcountTest =
(fun i -> (popCount i |> int) = (popCount16 i |> int))
]

#endif

[<Tests>]
let asyncTests =
testList "async" [
Expand Down Expand Up @@ -827,11 +857,13 @@ let performance =
(fun measurer -> reset(); measurer mulIJK ())
"ikj faster than ijk"

#if FSCHECK_TESTS
testCase "popcount" (fun _ ->
Expect.isFasterThan (fun () -> repeat10000 (popCount16 >> int) 987us)
(fun () -> repeat10000 (popCount >> int) 987us)
"popcount 16 faster than 32 fails"
) |> assertTestFailsWithMsgContaining "slower"
#endif
]

[<Tests>]
Expand Down
Loading