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

#Issue 847 - Fix runtime dependencies if developer dependencies are excluded #848

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions CycloneDX.Tests/CycloneDX.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
<None Update="FunctionalTests\Issue830-rsMultipleFrameworks\project2csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue847-FineGrainedDependencies\ReferringFineGrainedDependency.csproj.project.assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue847-FineGrainedDependencies\ReferringFineGrainedDependency.csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue847-FineGrainedDependencies\FineGrainedDependency.csproj.project.assets.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\Issue847-FineGrainedDependencies\FineGrainedDependency.csproj.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FunctionalTests\TestcaseFiles\DevDependencies.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
27 changes: 20 additions & 7 deletions CycloneDX.Tests/FunctionalTests/ExcludeDevDepenceny.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using CycloneDX.Models;
using Xunit;
Expand Down Expand Up @@ -42,8 +37,26 @@ public async Task DevDependenciesAreExcludedWithExcludeDevDependencies()

Assert.True(bom.Components.Count == 0);
Assert.True(bom.Dependencies.Count == 1); // only the meta component


}

[Fact]
public async Task DevDependenciesAreExcludedIfNoRuntimepartRemainsWithExcludeDevDependencies()
{
var assetsJson = File.ReadAllText(Path.Combine("FunctionalTests", "Issue847-FineGrainedDependencies", "FineGrainedDependency.csproj.project.assets.json"));
var options = new RunOptions
{
excludeDev = true
};
var bom = await FunctionalTestHelper.Test(assetsJson, options);

Assert.Equal(10, bom.Dependencies.Count);
Assert.Equal(9, bom.Components.Count);

options.excludeDev = false;
bom = await FunctionalTestHelper.Test(assetsJson, options);

Assert.Equal(17, bom.Dependencies.Count);
Assert.Equal(16, bom.Components.Count);
}
}
}
Loading
Loading