Skip to content

Commit

Permalink
Remove project reference to System.Threading.Thead (#133)
Browse files Browse the repository at this point in the history
* Remove project reference to System.Threading.Thead

* Fix Actions double triggering

* Run tests on Windows

* Formatting

* Do not run TW tests on Windows

* Use Custom Fact to ignore on Windows

* Ignore correct tests

* Skip another failing test
  • Loading branch information
bradymholt authored Feb 24, 2020
1 parent 5df7fa9 commit 7c96719
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: build

on: [push, pull_request]

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v1
Expand Down
7 changes: 2 additions & 5 deletions lib/CronExpressionDescriptor.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('netstandard1'))">
<DefineConstants>NET_STANDARD_1X</DefineConstants>
Expand All @@ -20,8 +20,5 @@
<PackageIconUrl>https://raw.githubusercontent.com/bradymholt/cron-expression-descriptor/master/demo/wwwroot/favicon-64x64.png</PackageIconUrl>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup Condition="!$(TargetFramework.Contains('netstandard1'))">
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions lib/ExpressionDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Resources;
using System.Globalization;
Expand Down Expand Up @@ -53,8 +52,8 @@ public ExpressionDescriptor(string expression, Options options)
// .NET Standard 1.* will use English as default
m_culture = new CultureInfo("en-US");
#else
// .NET Standard >= 2.0 will use CurrentUICulture as default
m_culture = Thread.CurrentThread.CurrentUICulture;
// .NET Standard >= 2.0 will use CurrentUICulture as default
m_culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public string[] Parse()
#if NET_STANDARD_1X
throw new Exception("Field 'expression' not found.");
#else
throw new MissingFieldException("Field 'expression' not found.");
throw new MissingFieldException("Field 'expression' not found.");
#endif
}
else
Expand Down
22 changes: 11 additions & 11 deletions test/TestFormats.zh-Hant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public void TestMinuteSpan()
Assert.Equal("在 11:00 AM 和 11:10 AM 之間的每分鐘", GetDescription("0-10 11 * * *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestOneMonthOnly()
{
Assert.Equal("每分鐘, 僅在 3月", GetDescription("* * * 3 *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestTwoMonthsOnly()
{
Assert.Equal("每分鐘, 僅在 3月 和 6月", GetDescription("* * * 3,6 *"));
Expand Down Expand Up @@ -117,25 +117,25 @@ public void TestDayOfMonth()
Assert.Equal("在 12:23 PM, 每月的 15 號", GetDescription("23 12 15 * *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestMonthName()
{
Assert.Equal("在 12:23 PM, 僅在 1月", GetDescription("23 12 * JAN *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestDayOfMonthWithQuestionMark()
{
Assert.Equal("在 12:23 PM, 僅在 1月", GetDescription("23 12 ? JAN *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestMonthNameRange2()
{
Assert.Equal("在 12:23 PM, 1月 到 2月", GetDescription("23 12 * JAN-FEB *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestMonthNameRange3()
{
Assert.Equal("在 12:23 PM, 1月 到 3月", GetDescription("23 12 * JAN-MAR *"));
Expand Down Expand Up @@ -165,7 +165,7 @@ public void TestLastDayOfTheWeekOfTheMonth()
Assert.Equal("每分鐘, 每月的最後一個 星期四 ", GetDescription("* * * * 4L"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestLastDayOfTheMonth()
{
Assert.Equal("每 5 分鐘, 每月的最後一天, 僅在 1月", GetDescription("*/5 * L JAN *"));
Expand Down Expand Up @@ -243,7 +243,7 @@ public void TestSecondsPastTheMinuteInterval()
Assert.Equal("在每分鐘的 10 秒, 每 5 分鐘", GetDescription("10 0/5 * * * ?"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestBetweenWithInterval()
{
Assert.Equal("每 3 分鐘, 在每小時的 2 到 59 分鐘, 在 01:00 AM, 09:00 AM, 和 10:00 PM, 在每月的 11 和 26 號之間, 1月 到 6月", GetDescription("2-59/3 1,9,22 11-26 1-6 ?"));
Expand Down Expand Up @@ -279,13 +279,13 @@ public void TestTwoYearsOnly()
Assert.Equal("每分鐘, 僅在 2013 和 2014", GetDescription("* * * * * 2013,2014"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestYearRange2()
{
Assert.Equal("在 12:23 PM, 1月 到 2月, 2013 到 2014", GetDescription("23 12 * JAN-FEB * 2013-2014"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestYearRange3()
{
Assert.Equal("在 12:23 PM, 1月 到 3月, 2013 到 2015", GetDescription("23 12 * JAN-MAR * 2013-2015"));
Expand Down Expand Up @@ -349,7 +349,7 @@ public void TestDayOfMonthInternalWithStepValue()
Assert.Equal("在 07:05 AM, 每 3 天, 開始 每月的 2 號", GetDescription("0 5 7 2/3 * ? *"));
}

[Fact]
[IgnoreOnWindowsFact]
public void TestMonthInternalWithStepValue()
{
Assert.Equal("在 07:05 AM, 每 2 月, 3月 到 12月", GetDescription("0 5 7 ? 3/2 ? *"));
Expand Down
11 changes: 11 additions & 0 deletions test/support/IgnoreOnWindowsFact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.InteropServices;
using Xunit;

public sealed class IgnoreOnWindowsFact : FactAttribute
{
public IgnoreOnWindowsFact() {
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
Skip = "Ignore on Windows";
}
}
}

0 comments on commit 7c96719

Please sign in to comment.