From 256536b67be8d441db193c765a003218c19a5d96 Mon Sep 17 00:00:00 2001 From: Sergey Komisarchik Date: Sun, 27 Nov 2016 12:15:01 +0300 Subject: [PATCH] enable travis ci --- .editorconfig | 13 ++++- .travis.yml | 49 +++++++++++++++++++ build.sh | 12 +++++ serilog-sinks-file.sln | 3 ++ .../FileLoggerConfigurationExtensionsTests.cs | 6 +-- .../Support/TempFolder.cs | 8 ++- 6 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 .travis.yml create mode 100644 build.sh diff --git a/.editorconfig b/.editorconfig index f76c08a..f16002a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,16 @@ -root=true +root = true [*] +trim_trailing_whitespace = true +insert_final_newline = true indent_style = space indent_size = 4 + +[*.{csproj,json,config,yml}] +indent_size = 2 + +[*.sh] +end_of_line = lf + +[*.{cmd, bat}] +end_of_line = crlf diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e9daee9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +language: csharp + +#dotnet cli require Ubuntu 14.04 +sudo: required +dist: trusty + +#dotnet cli require OSX 10.10 +osx_image: xcode7.1 + +addons: + apt: + packages: + - gettext + - libcurl4-openssl-dev + - libicu-dev + - libssl-dev + - libunwind8 + - zlib1g + +os: + - linux + +env: + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - TMP: /tmp + + matrix: + - CLI_VERSION=1.0.0-preview2-003121 + - CLI_VERSION=Latest + +matrix: + allow_failures: + - env: CLI_VERSION=Latest + +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; brew link --force openssl; fi + # Download script to install dotnet cli + - if test "$CLI_OBTAIN_URL" == ""; then export CLI_OBTAIN_URL="https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.sh"; fi + - curl -L --create-dirs $CLI_OBTAIN_URL -o ./scripts/obtain/install.sh + - find ./scripts -name "*.sh" -exec chmod +x {} \; + - export DOTNET_INSTALL_DIR="$PWD/.dotnetcli" + # use bash to workaround bug https://github.com/dotnet/cli/issues/1725 + - sudo bash ./scripts/obtain/install.sh --channel "preview" --version "$CLI_VERSION" --install-dir "$DOTNET_INSTALL_DIR" --no-path + # add dotnet to PATH + - export PATH="$DOTNET_INSTALL_DIR:$PATH" + +script: + - ./build.sh \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..39408c4 --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +dotnet restore --no-cache +for path in src/*/project.json; do + dirname="$(dirname "${path}")" + dotnet build ${dirname} -f netstandard1.3 -c Release +done + +for path in test/*.Tests/project.json; do + dirname="$(dirname "${path}")" + dotnet build ${dirname} -f netcoreapp1.0 -c Release + dotnet test ${dirname} -f netcoreapp1.0 -c Release +done diff --git a/serilog-sinks-file.sln b/serilog-sinks-file.sln index bf1cf9a..536f0ab 100644 --- a/serilog-sinks-file.sln +++ b/serilog-sinks-file.sln @@ -7,8 +7,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .travis.yml = .travis.yml appveyor.yml = appveyor.yml Build.ps1 = Build.ps1 + build.sh = build.sh global.json = global.json NuGet.Config = NuGet.Config README.md = README.md diff --git a/test/Serilog.Sinks.File.Tests/FileLoggerConfigurationExtensionsTests.cs b/test/Serilog.Sinks.File.Tests/FileLoggerConfigurationExtensionsTests.cs index 78c35b3..e39cccb 100644 --- a/test/Serilog.Sinks.File.Tests/FileLoggerConfigurationExtensionsTests.cs +++ b/test/Serilog.Sinks.File.Tests/FileLoggerConfigurationExtensionsTests.cs @@ -1,15 +1,15 @@ using System; using System.Threading; -using Serilog; using Serilog.Sinks.File.Tests.Support; using Serilog.Tests.Support; using Xunit; +using System.IO; namespace Serilog.Tests { public class FileLoggerConfigurationExtensionsTests { - const string InvalidPath = "/\\"; + static readonly string InvalidPath = new string(Path.GetInvalidPathChars()); [Fact] public void WhenWritingCreationExceptionsAreSuppressed() @@ -66,7 +66,6 @@ public void WhenFlushingToDiskReportedFileSinkCanBeCreatedAndDisposed() } } -#if ATOMIC_APPEND [Fact] public void WhenFlushingToDiskReportedSharedFileSinkCanBeCreatedAndDisposed() { @@ -79,6 +78,5 @@ public void WhenFlushingToDiskReportedSharedFileSinkCanBeCreatedAndDisposed() Thread.Sleep(TimeSpan.FromSeconds(1)); } } -#endif } } diff --git a/test/Serilog.Sinks.File.Tests/Support/TempFolder.cs b/test/Serilog.Sinks.File.Tests/Support/TempFolder.cs index a57d71f..f809c05 100644 --- a/test/Serilog.Sinks.File.Tests/Support/TempFolder.cs +++ b/test/Serilog.Sinks.File.Tests/Support/TempFolder.cs @@ -37,10 +37,14 @@ public void Dispose() } } - public static TempFolder ForCaller([CallerMemberName] string caller = null) + public static TempFolder ForCaller([CallerMemberName] string caller = null, [CallerFilePath] string sourceFileName = "") { if (caller == null) throw new ArgumentNullException(nameof(caller)); - return new TempFolder(caller); + if (sourceFileName == null) throw new ArgumentNullException(nameof(sourceFileName)); + + var folderName = System.IO.Path.GetFileNameWithoutExtension(sourceFileName) + "_" + caller; + + return new TempFolder(folderName); } public string AllocateFilename(string ext = null)