diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets index 691e3854..bfb480e9 100644 --- a/.paket/Paket.Restore.targets +++ b/.paket/Paket.Restore.targets @@ -1,21 +1,108 @@ - true + true + $(MSBuildThisFileDirectory) + /Library/Frameworks/Mono.framework/Commands/mono + mono + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + "$(PaketExePath)" + $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" + + + + + + + $(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references + + + + + + + + + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) + + + %(PaketReferencesFileLinesInfo.PackageVersion) + + + + + $(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config + + + + + + + false + + - - - - - - - - - - - + + + $(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).references + true + + + + <_NuspecFiles Include="$(BaseIntermediateOutputPath)*.nuspec"/> + + + + + + + + + + + + \ No newline at end of file diff --git a/.semver b/.semver index 980a4c56..809da96d 100644 --- a/.semver +++ b/.semver @@ -1,6 +1,6 @@ --- -:major: 4 -:minor: 1 -:patch: 1 -:special: '' +:major: 5 +:minor: 0 +:patch: 0 +:special: 'beta' :metadata: '' diff --git a/.travis.yml b/.travis.yml index 0df0a8b5..73996f5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -19,3 +32,4 @@ matrix: allow_failures: - mono: latest - mono: weekly + - os: osx diff --git a/DEVGUIDE.md b/DEVGUIDE.md index b6c0532d..306ccca6 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -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: @@ -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 diff --git a/Expecto.Sample/App.config b/Expecto.Sample/App.config index 12a9d510..3918676e 100644 --- a/Expecto.Sample/App.config +++ b/Expecto.Sample/App.config @@ -4,6 +4,16 @@ + + True + + + + + True + + + True @@ -49,14 +59,4 @@ - - True - - - - - True - - - \ No newline at end of file diff --git a/Expecto.Tests/Expecto.Tests.fsproj b/Expecto.Tests/Expecto.Tests.fsproj index ad5fa466..5426cfff 100644 --- a/Expecto.Tests/Expecto.Tests.fsproj +++ b/Expecto.Tests/Expecto.Tests.fsproj @@ -18,7 +18,7 @@ false false bin\Debug\ - DEBUG;TRACE + DEBUG;TRACE;FSCHECK_TESTS 3 AnyCPU bin\Debug\Expecto.Tests.xml @@ -29,7 +29,7 @@ true true bin\Release\ - TRACE + TRACE;FSCHECK_TESTS 3 AnyCPU bin\Release\Expecto.Tests.xml diff --git a/Expecto.Tests/Tests.fs b/Expecto.Tests/Tests.fs index d0fe30b5..d23b7ddb 100644 --- a/Expecto.Tests/Tests.fs +++ b/Expecto.Tests/Tests.fs @@ -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 @@ -18,10 +19,19 @@ module Dummy = [] 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 "" @@ -88,6 +98,7 @@ let tests = r.Value.duration ==? TimeSpan.FromMilliseconds 27. ] +#if FSCHECK_TESTS testList "TestResultCounts" [ let inline testProp fn = let config = @@ -120,6 +131,7 @@ let tests = true ) ] +#endif testList "Exception handling" [ testCaseAsync "Expecto ignore" <| async { @@ -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 @@ -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 @@ -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) = @@ -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 @@ -734,6 +760,8 @@ let expecto = ] ] +#if FSCHECK_TESTS + let inline popCount (i:uint16) = let mutable v = uint32 i v <- v - ((v >>> 1) &&& 0x55555555u) @@ -752,6 +780,8 @@ let popcountTest = (fun i -> (popCount i |> int) = (popCount16 i |> int)) ] +#endif + [] let asyncTests = testList "async" [ @@ -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 ] [] diff --git a/Expecto.Tests/app.config b/Expecto.Tests/app.config index 657043e6..3a0f2738 100644 --- a/Expecto.Tests/app.config +++ b/Expecto.Tests/app.config @@ -2,6 +2,16 @@ + + True + + + + + True + + + True @@ -47,14 +57,4 @@ - - True - - - - - True - - - \ No newline at end of file diff --git a/Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj b/Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj new file mode 100644 index 00000000..cdd664e6 --- /dev/null +++ b/Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj @@ -0,0 +1,35 @@ + + + + Expecto.netcore.Tests + Expecto.netcore.Tests + Exe + netcoreapp1.1 + false + + RESHAPED_THREAD_CULTURE; + $(DefineConstants) + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Expecto.netcore.Tests/nuget.config b/Expecto.netcore.Tests/nuget.config new file mode 100644 index 00000000..3814f423 --- /dev/null +++ b/Expecto.netcore.Tests/nuget.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Expecto.netcore/Expecto.netcore.fsproj b/Expecto.netcore/Expecto.netcore.fsproj index 5ba2f556..9df2b892 100644 --- a/Expecto.netcore/Expecto.netcore.fsproj +++ b/Expecto.netcore/Expecto.netcore.fsproj @@ -1,54 +1,23 @@ - - + Expecto - 1.1.2 - Library netstandard1.6 pdbonly - - $(DefineConstants);RELEASE - + - - 1.0.0-alpha-20161104-2 - All - - - 4.0.1.7-alpha - - - 3.3.0 - - - 4.3.0 - - - - - 1.6.1 - - - 1.0.0-alpha-000009 - - - 4.3.0 - - - 1.0.0-alpha-20161104-2 - - - - - 1.0.0-preview2-020000 - + + + + + + + - - + \ No newline at end of file diff --git a/Expecto.sln b/Expecto.sln index d3432d64..ca651608 100644 --- a/Expecto.sln +++ b/Expecto.sln @@ -8,11 +8,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{3786E1 paket.dependencies = paket.dependencies EndProjectSection EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto", "Expecto\Expecto.fsproj", "{C0D55728-10A9-4A7A-9DF9-D2F21F663AC2}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto", "Expecto\Expecto.fsproj", "{C0D55728-10A9-4A7A-9DF9-D2F21F663AC2}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto.BenchmarkDotNet", "Expecto.BenchmarkDotNet\Expecto.BenchmarkDotNet.fsproj", "{0ACABEAA-29BD-4F9F-89DB-0D03B5AFC952}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto.BenchmarkDotNet", "Expecto.BenchmarkDotNet\Expecto.BenchmarkDotNet.fsproj", "{0ACABEAA-29BD-4F9F-89DB-0D03B5AFC952}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto.FsCheck", "Expecto.FsCheck\Expecto.FsCheck.fsproj", "{58507646-335A-460E-B283-77A2BAF0D3A8}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto.FsCheck", "Expecto.FsCheck\Expecto.FsCheck.fsproj", "{58507646-335A-460E-B283-77A2BAF0D3A8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{1870B8C4-3943-41D3-AEA3-F8A69AB9E9FE}" ProjectSection(SolutionItems) = preProject @@ -25,21 +25,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{1870 build.sh = build.sh docker-build.sh = docker-build.sh Gemfile = Gemfile - globals.json = globals.json paket.dependencies = paket.dependencies Rakefile = Rakefile README.md = README.md + global.json = global.json EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B9D0E5F-378A-4310-B9F3-4ECF67AA5A23}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{191A316D-EA59-4BA9-9A70-D2AC46ECC6ED}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto.Tests", "Expecto.Tests\Expecto.Tests.fsproj", "{4182E778-F6C2-4BA4-BFC7-19DB54890E18}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto.Tests", "Expecto.Tests\Expecto.Tests.fsproj", "{4182E778-F6C2-4BA4-BFC7-19DB54890E18}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto.Sample", "Expecto.Sample\Expecto.Sample.fsproj", "{9996E3A7-F97F-4A6A-AD5F-C6C70858E220}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto.Sample", "Expecto.Sample\Expecto.Sample.fsproj", "{9996E3A7-F97F-4A6A-AD5F-C6C70858E220}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Expecto.Focused.Tests", "testdata\Expecto.Focused.Tests\Expecto.Focused.Tests.fsproj", "{2967D1F6-742B-4F3A-8688-A743888FF34B}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Expecto.Focused.Tests", "testdata\Expecto.Focused.Tests\Expecto.Focused.Tests.fsproj", "{2967D1F6-742B-4F3A-8688-A743888FF34B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Expecto.Tests.CSharp", "Expecto.Tests.CSharp\Expecto.Tests.CSharp.csproj", "{87E8FA7E-C2C8-488C-9B8F-7B887EDF5E4B}" EndProject diff --git a/Expecto/Expect.fs b/Expecto/Expect.fs index 3573f2ed..06ef01db 100644 --- a/Expecto/Expect.fs +++ b/Expecto/Expect.fs @@ -190,8 +190,8 @@ let hasCountOf (actual : _ seq) (expected : uint32) (selector : _ -> bool) messa let inline equal (actual : 'a) (expected : 'a) message = match box actual, box expected with | (:? string as a), (:? string as e) -> - use ai = a.GetEnumerator() - use ei = e.GetEnumerator() + let ai = a.ToCharArray().GetEnumerator() + let ei = e.ToCharArray().GetEnumerator() let mutable i = 0 let baseMsg errorIndex = let diffString = new String(' ', errorIndex + 1) + "↑" diff --git a/Expecto/Expecto.fs b/Expecto/Expecto.fs index 31dadade..f4870a13 100644 --- a/Expecto/Expecto.fs +++ b/Expecto/Expecto.fs @@ -190,8 +190,8 @@ module internal Helpers = member m.MatchTestsAttributes () = m.GetCustomAttributes true - |> Array.map (fun t -> t.GetType().FullName) - |> Set.ofArray + |> Seq.map (fun t -> t.GetType().FullName) + |> Set.ofSeq |> Set.intersect allTestAttributes |> Set.toList |> List.choose matchFocusAttributes @@ -399,7 +399,6 @@ module Impl = open Expecto.Logging.Message open Helpers open Mono.Cecil - open Mono.Cecil.Rocks let logger = Log.create "Expecto" @@ -641,12 +640,12 @@ module Impl = summary = fun _ summary -> let spirit = if summary.successful then - if Console.OutputEncoding.BodyName = "utf-8" then + if Console.OutputEncoding.WebName = "utf-8" then "ᕙ໒( ˵ ಠ ╭͜ʖ╮ ಠೃ ˵ )७ᕗ" else "Success!" else - if Console.OutputEncoding.BodyName = "utf-8" then + if Console.OutputEncoding.WebName = "utf-8" then "( ರ Ĺ̯ ರೃ )" else "" @@ -1021,7 +1020,8 @@ module Impl = let rand = Random() let randNext tests = - List.length tests |> rand.Next |> List.nth tests + let next = List.length tests |> rand.Next + List.nth tests next let finishTimestamp = lazy @@ -1155,9 +1155,9 @@ module Impl = let asMembers x = Seq.map (fun m -> m :> MemberInfo) x let bindingFlags = BindingFlags.Public ||| BindingFlags.Static fun (t: Type) -> - [ t.GetMethods bindingFlags |> asMembers - t.GetProperties bindingFlags |> asMembers - t.GetFields bindingFlags |> asMembers ] + [ t.GetTypeInfo().GetMethods bindingFlags |> asMembers + t.GetTypeInfo().GetProperties bindingFlags |> asMembers + t.GetTypeInfo().GetFields bindingFlags |> asMembers ] |> Seq.collect id |> Seq.choose testFromMember |> Seq.toList @@ -1171,20 +1171,20 @@ module Impl = let isFsharpFuncType t = let baseType = let rec findBase (t:Type) = - if t.BaseType = null || t.BaseType = typeof then + if t.GetTypeInfo().BaseType = null || t.GetTypeInfo().BaseType = typeof then t else - findBase t.BaseType + findBase (t.GetTypeInfo().BaseType) findBase t - baseType.IsGenericType && baseType.GetGenericTypeDefinition() = typedefof> + baseType.GetTypeInfo().IsGenericType && baseType.GetTypeInfo().GetGenericTypeDefinition() = typedefof> let getFuncTypeToUse (testFunc:unit->unit) (asm:Assembly) = let t = testFunc.GetType() - if t.Assembly.FullName = asm.FullName then + if t.GetTypeInfo().Assembly.FullName = asm.FullName then t else let nestedFunc = - t.GetFields() + t.GetTypeInfo().GetFields() |> Seq.tryFind (fun f -> isFsharpFuncType f.FieldType) match nestedFunc with | Some f -> f.GetValue(testFunc).GetType() @@ -1194,7 +1194,7 @@ module Impl = match testCode with | Sync test -> let t = getFuncTypeToUse test asm - let m = t.GetMethods () |> Seq.find (fun m -> (m.Name = "Invoke") && (m.DeclaringType = t)) + let m = t.GetTypeInfo().GetMethods () |> Seq.find (fun m -> (m.Name = "Invoke") && (m.DeclaringType = t)) (t.FullName, m.Name) | Async _ | AsyncFsCheck _ -> ("Unknown Async", "Unknown Async") @@ -1214,13 +1214,16 @@ module Impl = let getMethods typeName = match types.TryFind (getEcma335TypeName typeName) with - | Some t -> Some (t.GetMethods()) + | Some t -> Some (t.Methods) | _ -> None let getFirstOrDefaultSequencePoint (m:MethodDefinition) = m.Body.Instructions - |> Seq.tryFind (fun i -> (i.SequencePoint <> null && i.SequencePoint.StartLine <> lineNumberIndicatingHiddenLine)) - |> Option.map (fun i -> i.SequencePoint) + |> Seq.tryPick (fun i -> + let sp = m.DebugInformation.GetSequencePoint i + if sp <> null && sp.StartLine <> lineNumberIndicatingHiddenLine then + Some sp else None) + |> Option.map (fun maybeSequencePoint -> maybeSequencePoint) match getMethods className with | None -> SourceLocation.empty @@ -1462,7 +1465,7 @@ module Tests = module ExpectoConfig = let expectoVersion() = - let assembly = Assembly.GetExecutingAssembly() + let assembly = typeof.GetTypeInfo().Assembly let fileInfoVersion = FileVersionInfo.GetVersionInfo assembly.Location fileInfoVersion.ProductVersion diff --git a/Expecto/Expecto.fsproj b/Expecto/Expecto.fsproj index e0f792b2..da1be5aa 100644 --- a/Expecto/Expecto.fsproj +++ b/Expecto/Expecto.fsproj @@ -1,4 +1,4 @@ - + Expecto @@ -86,26 +86,26 @@ - ..\packages\Mono.Cecil\lib\net45\Mono.Cecil.dll + ..\packages\Mono.Cecil\lib\net40\Mono.Cecil.dll True True - ..\packages\Mono.Cecil\lib\net45\Mono.Cecil.Mdb.dll + ..\packages\Mono.Cecil\lib\net40\Mono.Cecil.Mdb.dll True True - ..\packages\Mono.Cecil\lib\net45\Mono.Cecil.Pdb.dll + ..\packages\Mono.Cecil\lib\net40\Mono.Cecil.Pdb.dll True True - ..\packages\Mono.Cecil\lib\net45\Mono.Cecil.Rocks.dll + ..\packages\Mono.Cecil\lib\net40\Mono.Cecil.Rocks.dll True True - + \ No newline at end of file diff --git a/Rakefile b/Rakefile index 337e936f..28c2d8b7 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ require 'bundler/setup' require 'albacore' require 'albacore/tasks/release' require 'albacore/tasks/versionizer' +require 'semver' Configuration = ENV['CONFIGURATION'] || 'Release' @@ -29,9 +30,14 @@ build :quick_compile do |b| b.sln = 'Expecto.Tests/Expecto.Tests.fsproj' end +desc 'Perform fast netcore build (warn: doesn\'t d/l deps)' +task :quick_compile_netcore do + system "dotnet", %W|build -c #{Configuration} Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj| +end + task :paket_bootstrap do system 'tools/paket.bootstrapper.exe', - %|4.0.0-alpha030|, + %|4.1.7|, clr_command: true unless File.exists? 'tools/paket.exe' end @@ -43,44 +49,71 @@ task :restore_quick do system 'tools/paket.exe', 'restore', clr_command: true end +task :restore_dotnetcli do + system "dotnet", %W|restore Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj| +end + desc 'restore all nugets as per the packages.config files' -task :restore => [:paket_bootstrap, :restore_quick, :paket_files] +task :restore => [:paket_bootstrap, :restore_quick, :paket_files, :restore_dotnetcli] desc 'Perform full build' -build :compile => [:versioning, :restore, :assembly_info] do |b| +build :compile => [:versioning, :restore, :assembly_info, :build_dotnetcli] do |b| b.prop 'Configuration', Configuration b.sln = 'Expecto.sln' end +task :build_dotnetcli => [:versioning, :restore_dotnetcli, :assembly_info] do + system "dotnet", %W|build -c #{Configuration} -f netstandard1.6 Expecto.netcore/Expecto.netcore.fsproj| +end + +directory 'build/clipkg' directory 'build/pkg' +task :create_nugets_dotnetcli => ['build/clipkg', :build_dotnetcli] do + system "dotnet", %W|pack -v n --no-build -c #{Configuration} -o ../build/clipkg /p:Version=#{ENV['NUGET_VERSION']} Expecto.netcore/Expecto.netcore.fsproj| +end + +desc 'Merge standard and dotnetcli nupkgs' + task :merge_nupkgs => [ :create_nugets_dotnetcli, :create_nugets ] do + system "dotnet", %W|restore tools/tools.proj -v n| + Dir.chdir "tools" do + [ "Expecto" ].each do |item| + version = SemVer.find.format("%M.%m.%p%s") + sourcenupkg = "../build/pkg/#{item}.#{version}.nupkg" + netcorenupkg = "../build/clipkg/#{item}.#{version}.nupkg" + system "dotnet", %W|mergenupkg --source "#{sourcenupkg}" --other "#{netcorenupkg}" --framework netstandard1.6| + end + end + end + desc 'package nugets - finds all projects and package them' -nugets_pack :create_nugets => ['build/pkg', :versioning, :compile] do |p| - p.configuration = Configuration - p.files = FileList['*/*.{csproj,fsproj,nuspec}']. - exclude(/Tests|Sample|netcore/) - p.out = 'build/pkg' - p.exe = 'packages/NuGet.CommandLine/tools/NuGet.exe' - p.with_metadata do |m| - m.description = 'Expecto is a smooth test framework for F#, cloned from Fuchu with added functionality for making it easier to use.' - m.authors = 'Henrik Feldt, Logibit AB, formerly @mausch' - m.project_url = 'https://github.com/haf/expecto' - m.icon_url = 'https://raw.githubusercontent.com/haf/expecto/master/docs/expecto-logo-small.png' - m.tags = 'testing fsharp assert expect' - m.version = ENV['NUGET_VERSION'] +nugets_pack :create_nugets => ['build/pkg', :versioning, :compile, :create_nugets_dotnetcli] do |p| + p.configuration = Configuration + p.files = FileList['*/*.{csproj,fsproj,nuspec}']. + exclude(/Tests|Sample|netcore/) + p.out = 'build/pkg' + p.exe = 'packages/NuGet.CommandLine/tools/NuGet.exe' + p.with_metadata do |m| + m.description = 'Expecto is a smooth test framework for F#, cloned from Fuchu with added functionality for making it easier to use.' + m.authors = 'Henrik Feldt, Logibit AB, formerly @mausch' + m.project_url = 'https://github.com/haf/expecto' + m.icon_url = 'https://raw.githubusercontent.com/haf/expecto/master/docs/expecto-logo-small.png' + m.tags = 'testing fsharp assert expect' + m.version = ENV['NUGET_VERSION'] end end namespace :tests do task :unit do + system "dotnet", %W|run -c #{Configuration} --project Expecto.netcore.Tests/Expecto.netcore.Tests.fsproj --summary| system "Expecto.Tests/bin/#{Configuration}/Expecto.Tests.exe", '--summary', clr_command: true system "Expecto.Tests.CSharp/bin/#{Configuration}/Expecto.Tests.CSharp.exe", '--summary', clr_command: true end end task :tests => :'tests:unit' - -task :default => [ :compile, :tests, :create_nugets ] +task :'tests:unit' => [ :restore_dotnetcli ] +task :default => [ :compile, :tests, :create_nugets, :merge_nupkgs ] task :ensure_nuget_key do raise 'missing env NUGET_KEY value' unless ENV['NUGET_KEY'] diff --git a/appveyor.yml b/appveyor.yml index 233ea4a2..8ec09537 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,14 +2,14 @@ os: Visual Studio 2015 environment: matrix: - - CLI_VERSION: 1.0.0-preview3-003857 + - CLI_VERSION: 1.0.1 install: - set PATH=C:\Ruby23-x64\bin;%PATH% - bundle install build_script: - - bundle exec rake + - cmd: build.cmd "All" # # .NET Core SDK binaries # - ps: $url = "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-win-x64.latest.zip" diff --git a/build.cmd b/build.cmd index 73e18441..1e32c279 100644 --- a/build.cmd +++ b/build.cmd @@ -1,6 +1,6 @@ @echo off -.paket\paket.bootstrapper.exe 4.0.0-alpha030 --max-file-age=120 +.paket\paket.bootstrapper.exe 4.4.0 if errorlevel 1 ( exit /b %errorlevel% ) diff --git a/build.fsx b/build.fsx index 6c7950d2..20d4520e 100644 --- a/build.fsx +++ b/build.fsx @@ -18,6 +18,45 @@ let run cmd args dir = ) System.TimeSpan.MaxValue = false then failwithf "Error while running '%s' with args: %s" cmd args + +let project = "Expecto" +let summary = "A smooth unit test framework for F#" +let description = summary + +// List of author names (for NuGet package) +let authors = [ "Logibit AB" ] +let copyright = "(c) 2016 by Henrik Feldt, formerly Fuchu by @mausch" +// Tags for your project (for NuGet package) + +let version = { Major = 5; Minor = 0; Patch = 0 } + +open Fake.AssemblyInfoFile + +let genFSAssemblyInfo (projectPath) = + let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath) + let folderName = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(projectPath)) + let basePath = folderName + let fileName = basePath @@ "AssemblyVersionInfo.fs" + CreateFSharpAssemblyInfo fileName [ + Attribute.Title (projectName) + Attribute.Product project + Attribute.Copyright copyright + Attribute.Company (authors |> String.concat ", ") + Attribute.Description summary + Attribute.Version <| string version + // Attribute.Version release.AssemblyVersion + // Attribute.FileVersion release.AssemblyVersion + // Attribute.InformationalVersion release.NugetVersion + ] + + +// Generate assembly info files with the right version & up-to-date information +Target "AssemblyInfo" (fun _ -> + let fsProjs = !! "./**/*.fsproj" |> Seq.filter (fun s -> not <| s.Contains "preview") + fsProjs |> Seq.iter genFSAssemblyInfo +) + + // -------------------------------------------------------------------------------------- // Rename Logary Facades for Expecto // (why this is necessary - https://github.com/logary/logary/#using-logary-in-a-library) @@ -49,10 +88,17 @@ Target "Clean" (fun _ -> // Build library, test project, & sample let solutionFile = "Expecto" +MSBuildDefaults <- { MSBuildDefaults with Verbosity = Some Minimal } Target "Build" (fun _ -> !! (solutionFile + ".sln") - |> MSBuildRelease "" "Rebuild" + |> MSBuildWithDefaults "Rebuild" + |> ignore +) + +Target "BuildFast" (fun _ -> + !! (solutionFile + ".sln") + |> MSBuildWithDefaults "Build" |> ignore ) @@ -66,6 +112,7 @@ Target "RunTests" (fun _ -> // Build netcore expecto library let netcoreDir = "Expecto.netcore" +let netcoreTestsDir = "Expecto.netcore.Tests" let dotnet args dir = run "dotnet" args dir Target "DotnetBuild" (fun _ -> @@ -74,6 +121,12 @@ Target "DotnetBuild" (fun _ -> dotnet "build" netcoreDir ) +Target "DotnetRunTests" (fun _ -> + dotnet "--info" "" + dotnet "restore" netcoreTestsDir + dotnet "run -c Release --parallel --fail-on-focused-tests --summary --version" netcoreTestsDir +) + Target "CreateNuGets" (fun _ -> let result = ExecProcess (fun info -> @@ -88,13 +141,16 @@ Target "CreateNuGets" (fun _ -> Target "All" DoNothing -"ExpectoChangeo" + +"AssemblyInfo" + ==> "ExpectoChangeo" ==> "Clean" ==> "Build" + ==> "DotnetRunTests" ==> "RunTests" <=> "DotnetBuild" "Build" ==> "All" "DotnetBuild" ==> "All" -RunTargetOrDefault "All" +RunTargetOrDefault "DotnetBuild" diff --git a/build.sh b/build.sh index fc4a3436..3e704c84 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ if test "$OS" = "Windows_NT" then # use .Net - .paket/paket.bootstrapper.exe $@ 4.0.0-alpha030 --max-file-age=120 + .paket/paket.bootstrapper.exe $@ 4.4.0 exit_code=$? if [ $exit_code -ne 0 ]; then exit $exit_code @@ -20,7 +20,7 @@ then packages/build/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx else # use mono - mono .paket/paket.bootstrapper.exe + mono .paket/paket.bootstrapper.exe 4.4.0 exit_code=$? if [ $exit_code -ne 0 ]; then certificate_count=$(certmgr -list -c Trust | grep X.509 | wc -l) diff --git a/global.json b/global.json new file mode 100644 index 00000000..0436af42 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "1.0.1" + } +} \ No newline at end of file diff --git a/globals.json b/globals.json deleted file mode 100644 index 1118bfb9..00000000 --- a/globals.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - // "version": "1.0.0-preview4-004130" - "version": "1.0.0-preview4-004079" - - } -} \ No newline at end of file diff --git a/paket.dependencies b/paket.dependencies index 0798e3a5..e82857fc 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -1,17 +1,17 @@ -source https://nuget.org/api/v2 +source https://nuget.org/api/v2 redirects: on framework net461 -github logary/logary src/Logary.Facade/Facade.fs +github logary/logary:0fbb7829b9d4b62f9ffd10d7a4b20d075c6cccc6 src/Logary.Facade/Facade.fs nuget Argu nuget FsCheck -nuget FSharp.Core ~> 3 +nuget FSharp.Core nuget BenchmarkDotNet nuget BenchmarkDotNet.Toolchains.Roslyn nuget BenchmarkDotNet.Core nuget NuGet.CommandLine -nuget Mono.Cecil +nuget Mono.Cecil = 0.10-beta5 group build source https://www.nuget.org/api/v2 diff --git a/paket.lock b/paket.lock index 2205d294..62634a50 100644 --- a/paket.lock +++ b/paket.lock @@ -58,7 +58,7 @@ NUGET System.Xml.XPath.XDocument (>= 4.3) Microsoft.CodeAnalysis.CSharp (2.0) Microsoft.CodeAnalysis.Common (2.0) - Mono.Cecil (0.9.6.4) + Mono.Cecil (0.10-beta5) NuGet.CommandLine (3.5) System.AppContext (4.3) System.Collections (4.3) diff --git a/testdata/Expecto.Focused.Tests/Expecto.Focused.Tests.fsproj b/testdata/Expecto.Focused.Tests/Expecto.Focused.Tests.fsproj index 794091e6..5bc1d4d4 100644 --- a/testdata/Expecto.Focused.Tests/Expecto.Focused.Tests.fsproj +++ b/testdata/Expecto.Focused.Tests/Expecto.Focused.Tests.fsproj @@ -1,4 +1,4 @@ - + Expecto.Focused.Tests @@ -30,22 +30,6 @@ 3 AnyCPU - - - - - - - - Expecto - {c0d55728-10a9-4a7a-9df9-d2f21f663ac2} - True - - - - - - @@ -65,10 +49,24 @@ ..\..\packages\FSharp.Core\lib\net40\FSharp.Core.dll - True True - + + + + + + + + + + + Expecto + {c0d55728-10a9-4a7a-9df9-d2f21f663ac2} + True + + + \ No newline at end of file diff --git a/testdata/Expecto.Focused.Tests/app.config b/testdata/Expecto.Focused.Tests/app.config new file mode 100644 index 00000000..0af883b9 --- /dev/null +++ b/testdata/Expecto.Focused.Tests/app.config @@ -0,0 +1,9 @@ + + + + + True + + + + diff --git a/tools/tools.proj b/tools/tools.proj new file mode 100644 index 00000000..8fcaeb88 --- /dev/null +++ b/tools/tools.proj @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file