Skip to content

Commit

Permalink
Netcore2 (adamhathcock#302)
Browse files Browse the repository at this point in the history
* Add netstandard 2.0 target and netcoreapp2.0 tests

* Update xunit

* set tests explicitly to netcore2

* update travis

* Don't say build as netcoreapp1.0

* try adding dotnet 1 too

* Remove .NET Core 1 support

* switch to circle

* update cake

* fix circle build

* try fix file ending test again

* Fix casing on files

* Another casing fix

* Add back netstandard1.0

* Finish adding netstandard 1.0 back

* Add netstandard1.3 back
  • Loading branch information
adamhathcock authored Dec 8, 2017
1 parent a4ebd5f commit a8b6def
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 115 deletions.
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
jobs:
build:
docker:
- image: adamhathcock/cake-build:latest
steps:
- checkout
- run:
name: Build
command: ./build.sh

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* text=auto

# need original files to be windows
test/TestArchives/Original/*.txt eol=crlf
*.txt text eol=crlf
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions SharpCompress.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
31 changes: 18 additions & 13 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,37 @@ Task("Build")

DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings);

settings.Framework = "netcoreapp1.1";
DotNetCoreBuild("./tests/SharpCompress.Test/SharpCompress.Test.csproj", settings);
settings.Framework = "netstandard1.3";
DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings);

settings.Framework = "netstandard2.0";
DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings);
}
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
if (!bool.Parse(EnvironmentVariable("APPVEYOR") ?? "false")
&& !bool.Parse(EnvironmentVariable("TRAVIS") ?? "false"))
var files = GetFiles("tests/**/*.csproj");
foreach(var file in files)
{
var files = GetFiles("tests/**/*.csproj");
foreach(var file in files)
var settings = new DotNetCoreTestSettings
{
var settings = new DotNetCoreTestSettings
Configuration = "Release",
Framework = "netcoreapp2.0"
};

DotNetCoreTest(file.ToString(), settings);


settings = new DotNetCoreTestSettings
{
Configuration = "Release"
Configuration = "Release",
Framework = "netcoreapp2.0"
};

DotNetCoreTest(file.ToString(), settings);
}
}
else
{
Information("Skipping tests as this is AppVeyor or Travis CI");
}
});

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
CAKE_VERSION=0.19.1
CAKE_VERSION=0.23.0
CAKE_DLL=$TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION/Cake.dll

# Make sure the tools folder exist.
Expand Down
3 changes: 1 addition & 2 deletions src/SharpCompress/SharpCompress.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<AssemblyVersion>0.18.2.0</AssemblyVersion>
<FileVersion>0.18.2.0</FileVersion>
<Authors>Adam Hathcock</Authors>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net35;netstandard1.0;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net35;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>SharpCompress</AssemblyName>
Expand Down
34 changes: 17 additions & 17 deletions tests/SharpCompress.Test/Rar/RarArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ private void ReadRarPassword(string testArchive, string password)
ResetScratch();
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, testArchive)))
using (var archive = RarArchive.Open(stream, new ReaderOptions()
{
Password = password,
LeaveStreamOpen = true
}))
{
Password = password,
LeaveStreamOpen = true
}))
{
foreach (var entry in archive.Entries)
{
Expand Down Expand Up @@ -66,10 +66,10 @@ protected void ArchiveFileReadPassword(string archiveName, string password)
{
ResetScratch();
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, archiveName), new ReaderOptions()
{
Password = password,
LeaveStreamOpen = true
}))
{
Password = password,
LeaveStreamOpen = true
}))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
Expand Down Expand Up @@ -120,12 +120,12 @@ public void Rar_test_invalid_exttime_ArchiveStreamRead()
public void Rar_Jpg_ArchiveStreamRead()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "RarJpeg.jpg")))
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rarjpeg.jpg")))
{
using (var archive = RarArchive.Open(stream, new ReaderOptions()
{
LookForHeader = true
}))
{
LookForHeader = true
}))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public void Rar_ArchiveFileRead_HasDirectories()
using (var archive = RarArchive.Open(stream))
{
Assert.False(archive.IsSolid);
Assert.True(archive.Entries.Any(entry => entry.IsDirectory));
Assert.Contains(true, archive.Entries.Select(entry => entry.IsDirectory));
}
}
}
Expand All @@ -233,10 +233,10 @@ public void Rar_ArchiveFileRead_HasDirectories()
public void Rar_Jpg_ArchiveFileRead()
{
ResetScratch();
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, "RarJpeg.jpg"), new ReaderOptions()
{
LookForHeader = true
}))
using (var archive = RarArchive.Open(Path.Combine(TEST_ARCHIVES_PATH, "Rarjpeg.jpg"), new ReaderOptions()
{
LookForHeader = true
}))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
Expand Down
10 changes: 5 additions & 5 deletions tests/SharpCompress.Test/Rar/RarHeaderFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ namespace SharpCompress.Test.Rar
public class RarHeaderFactoryTest : TestBase
{
private readonly RarHeaderFactory rarHeaderFactory;

public RarHeaderFactoryTest()
{
ResetScratch();
rarHeaderFactory = new RarHeaderFactory(StreamingMode.Seekable, new ReaderOptions()
{
LeaveStreamOpen = true
});
{
LeaveStreamOpen = true
});
}


[Fact]
public void ReadHeaders_RecognizeEncryptedFlag()
{

ReadEncryptedFlag("Rar.Encrypted_filesAndHeader.rar", true);
ReadEncryptedFlag("Rar.encrypted_filesAndHeader.rar", true);



Expand Down
32 changes: 16 additions & 16 deletions tests/SharpCompress.Test/Rar/RarReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ private void ReadRar(string testArchive, string password)
ResetScratch();
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, testArchive)))
using (var reader = RarReader.Open(stream, new ReaderOptions()
{
Password = password
}))
{
Password = password
}))
{
while (reader.MoveToNextEntry())
{
Expand Down Expand Up @@ -209,9 +209,9 @@ public void Rar_Reader_Audio_program()
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Audio_program.rar")))
using (var reader = RarReader.Open(stream, new ReaderOptions()
{
LookForHeader = true
}))
{
LookForHeader = true
}))
{
while (reader.MoveToNextEntry())
{
Expand All @@ -231,11 +231,11 @@ public void Rar_Reader_Audio_program()
public void Rar_Jpg_Reader()
{
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "RarJpeg.jpg")))
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rarjpeg.jpg")))
using (var reader = RarReader.Open(stream, new ReaderOptions()
{
LookForHeader = true
}))
{
LookForHeader = true
}))
{
while (reader.MoveToNextEntry())
{
Expand All @@ -262,9 +262,9 @@ public void Rar_Solid_Skip_Reader()
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.solid.rar")))
using (var reader = RarReader.Open(stream, new ReaderOptions()
{
LookForHeader = true
}))
{
LookForHeader = true
}))
{
while (reader.MoveToNextEntry())
{
Expand All @@ -287,9 +287,9 @@ public void Rar_Reader_Skip()
ResetScratch();
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Rar.rar")))
using (var reader = RarReader.Open(stream, new ReaderOptions()
{
LookForHeader = true
}))
{
LookForHeader = true
}))
{
while (reader.MoveToNextEntry())
{
Expand Down
19 changes: 8 additions & 11 deletions tests/SharpCompress.Test/SharpCompress.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<AssemblyName>SharpCompress.Test</AssemblyName>
<AssemblyOriginatorKeyFile>../../SharpCompress.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>SharpCompress.Test</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion>1.1.2</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\SharpCompress\SharpCompress.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="xunit" Version="2.3.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Xz\" />
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
</Project>
28 changes: 14 additions & 14 deletions tests/SharpCompress.Test/Tar/TarArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public void Tar_NonUstarArchiveWithLongNameDoesNotSkipEntriesAfterTheLongOne()
using (var archive = TarArchive.Open(unmodified))
{
Assert.Equal(5, archive.Entries.Count);
Assert.True(archive.Entries.Any(entry => entry.Key == "very long filename/"));
Assert.True(archive.Entries.Any(entry => entry.Key == "very long filename/very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename.jpg"));
Assert.True(archive.Entries.Any(entry => entry.Key == "z_file 1.txt"));
Assert.True(archive.Entries.Any(entry => entry.Key == "z_file 2.txt"));
Assert.True(archive.Entries.Any(entry => entry.Key == "z_file 3.txt"));
Assert.Contains("very long filename/", archive.Entries.Select(entry => entry.Key));
Assert.Contains("very long filename/very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename very long filename.jpg", archive.Entries.Select(entry => entry.Key));
Assert.Contains("z_file 1.txt", archive.Entries.Select(entry => entry.Key));
Assert.Contains("z_file 2.txt", archive.Entries.Select(entry => entry.Key));
Assert.Contains("z_file 3.txt", archive.Entries.Select(entry => entry.Key));
}
}

Expand Down Expand Up @@ -74,7 +74,7 @@ public void Tar_VeryLongFilepathReadback()
using (var archive2 = TarArchive.Open(unmodified))
{
Assert.Equal(1, archive2.Entries.Count);
Assert.True(archive2.Entries.Any(entry => entry.Key == longFilename));
Assert.Contains(longFilename, archive2.Entries.Select(entry => entry.Key));

foreach (var entry in archive2.Entries)
Assert.Equal("dummy filecontent", new StreamReader(entry.OpenEntryStream()).ReadLine());
Expand All @@ -85,15 +85,15 @@ public void Tar_VeryLongFilepathReadback()
public void Tar_UstarArchivePathReadLongName()
{
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "ustar with long names.tar");
using(var archive = TarArchive.Open(unmodified))
using (var archive = TarArchive.Open(unmodified))
{
Assert.Equal(6, archive.Entries.Count);
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/"));
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/Some file with veeeeeeeeeery loooooooooong name"));
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/Directory with veeeeeeeeeery loooooooooong name/"));
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/Directory with veeeeeeeeeery loooooooooong name/Some file with veeeeeeeeeery loooooooooong name"));
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/Directory with veeeeeeeeeery loooooooooong name/Directory with veeeeeeeeeery loooooooooong name/"));
Assert.True(archive.Entries.Any(entry => entry.Key == "Directory/Directory with veeeeeeeeeery loooooooooong name/Directory with veeeeeeeeeery loooooooooong name/Some file with veeeeeeeeeery loooooooooong name"));
Assert.Contains("Directory/", archive.Entries.Select(entry => entry.Key));
Assert.Contains("Directory/Some file with veeeeeeeeeery loooooooooong name", archive.Entries.Select(entry => entry.Key));
Assert.Contains("Directory/Directory with veeeeeeeeeery loooooooooong name/", archive.Entries.Select(entry => entry.Key));
Assert.Contains("Directory/Directory with veeeeeeeeeery loooooooooong name/Some file with veeeeeeeeeery loooooooooong name", archive.Entries.Select(entry => entry.Key));
Assert.Contains("Directory/Directory with veeeeeeeeeery loooooooooong name/Directory with veeeeeeeeeery loooooooooong name/", archive.Entries.Select(entry => entry.Key));
Assert.Contains("Directory/Directory with veeeeeeeeeery loooooooooong name/Directory with veeeeeeeeeery loooooooooong name/Some file with veeeeeeeeeery loooooooooong name", archive.Entries.Select(entry => entry.Key));
}
}

Expand All @@ -114,7 +114,7 @@ public void Tar_Create_New()
[Fact]
public void Tar_Random_Write_Add()
{
string jpg = Path.Combine(ORIGINAL_FILES_PATH, "jpg","test.jpg");
string jpg = Path.Combine(ORIGINAL_FILES_PATH, "jpg", "test.jpg");
string scratchPath = Path.Combine(SCRATCH_FILES_PATH, "Tar.mod.tar");
string unmodified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.mod.tar");
string modified = Path.Combine(TEST_ARCHIVES_PATH, "Tar.noEmptyDirs.tar");
Expand Down
Loading

0 comments on commit a8b6def

Please sign in to comment.