Skip to content

Commit

Permalink
Merge pull request chocolatey#2435 from TheCakeIsNaOH/linux-integration
Browse files Browse the repository at this point in the history
(chocolatey#2434) Integration tests run on non-windows platforms.
  • Loading branch information
gep13 authored Nov 12, 2021
2 parents 3ae9fe8 + 740252f commit 0745b64
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
chmod +x build.sh
$GITHUB_WORKSPACE//build.sh -v
- name: Test with Nunit on Mono
run: $GITHUB_WORKSPACE//test.sh
run: $GITHUB_WORKSPACE//test.sh integration
- name: Upload Ubuntu build results
uses: actions/upload-artifact@v2
# Always upload build results
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
chmod +x build.sh
$GITHUB_WORKSPACE//build.sh -v
- name: Test with Nunit on Mono
run: $GITHUB_WORKSPACE//test.sh
run: $GITHUB_WORKSPACE//test.sh integration
- name: Upload MacOS build results
uses: actions/upload-artifact@v2
# Always upload build results
Expand Down
2 changes: 1 addition & 1 deletion src/chocolatey.tests.integration/Scenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static ChocolateyConfiguration baseline_configuration()
// prior commands, so ensure that all items go back to the default values here
var config = NUnitSetup.Container.GetInstance<ChocolateyConfiguration>();

config.Information.PlatformType = PlatformType.Windows;
config.Information.PlatformType = Platform.get_platform();
config.Information.IsInteractive = false;
config.Information.ChocolateyVersion = "1.2.3";
config.Information.PlatformVersion = new Version(6, 1, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace chocolatey.tests.integration.infrastructure.app.services
using chocolatey.infrastructure.results;
using chocolatey.infrastructure.services;
using Moq;
using NUnit.Framework;
using Should;

public class FilesServiceSpecs
Expand Down Expand Up @@ -88,6 +89,8 @@ public void should_log_a_warning()
}

[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public void should_log_a_warning_about_locked_files()
{
bool lockedFiles = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace chocolatey.tests.integration.infrastructure.commands
using chocolatey.infrastructure.app;
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.filesystem;
using NUnit.Framework;
using Should;

public class CommandExecutorSpecs
Expand All @@ -35,6 +36,8 @@ public override void Context()
}
}

[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_CommandExecutor_errors : CommandExecutorSpecsBase
{
private int result;
Expand Down Expand Up @@ -77,6 +80,8 @@ public void should_message_the_error()
}
}

[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_CommandExecutor_is_given_a_nonexisting_process : CommandExecutorSpecsBase
{
private string result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void GetExecutablePath_should_find_existing_executable_with_extension()
FileSystem.get_executable_path("cmd.exe").ShouldEqual(
Platform.get_platform() == PlatformType.Windows
? "c:\\windows\\system32\\cmd.exe"
: "cmd",
: "cmd.exe",
StringComparer.OrdinalIgnoreCase
);
}
Expand Down Expand Up @@ -139,6 +139,8 @@ public void GetFiles_should_return_files_that_meet_the_pattern()
}

[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public void GetFiles_should_return_files_that_meet_the_pattern_regardless_of_case()
{
string filePath = FileSystem.combine_paths(ContextPath, "chocolateyInstall.ps1");
Expand Down Expand Up @@ -189,6 +191,8 @@ public void GetDirectories_should_return_a_string_array_with_directories()
}

[Category("Integration")]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_setting_file_attributes_with_dotNetFileSystem : DotNetFileSystemSpecsBase
{
public override void Context()
Expand Down
25 changes: 23 additions & 2 deletions src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.results;
using NuGet;
using NUnit.Framework;
using Should;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;

Expand Down Expand Up @@ -55,6 +56,8 @@ public override void Context()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_noop_installing_a_package : ScenariosBase
{
public override void Context()
Expand Down Expand Up @@ -150,6 +153,8 @@ public void should_contain_a_message_that_it_was_unable_to_find_package()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_installing_a_package_happy_path : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -327,7 +332,7 @@ public class when_installing_packages_with_packages_config : ScenariosBase
public override void Context()
{
base.Context();
var packagesConfig = "{0}\\context\\testing.packages.config".format_with(Scenario.get_top_level());
var packagesConfig = "{0}{1}context{1}testing.packages.config".format_with(Scenario.get_top_level(), Path.DirectorySeparatorChar);
Configuration.PackageNames = Configuration.Input = packagesConfig;
Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
Expand Down Expand Up @@ -539,6 +544,8 @@ public void should_ave_warning_package_result()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_force_installing_an_already_installed_package : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -641,6 +648,8 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_force_installing_an_already_installed_package_that_errors : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -720,6 +729,8 @@ public void should_not_have_warning_package_result()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_force_installing_an_already_installed_package_with_a_read_and_delete_share_locked_file : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -820,6 +831,8 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_force_installing_an_already_installed_package_with_with_an_exclusively_locked_file : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -1083,6 +1096,8 @@ public void should_have_expected_error_in_package_result()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_installing_a_package_that_errors : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -1262,6 +1277,8 @@ public void should_have_a_version_of_one_dot_zero()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_installing_a_package_that_has_nonterminating_errors_with_fail_on_stderr : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -3107,14 +3124,16 @@ public void should_not_have_warning_package_result()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_installing_a_package_from_a_nupkg_file : ScenariosBase
{
private PackageResult packageResult;

public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "{0}\\installpackage.1.0.0.nupkg".format_with(Configuration.Sources);
Configuration.PackageNames = Configuration.Input = "{0}{1}installpackage.1.0.0.nupkg".format_with(Configuration.Sources, Path.DirectorySeparatorChar);
}

public override void Because()
Expand Down Expand Up @@ -3279,6 +3298,8 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
}

[Concern(typeof(ChocolateyInstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_installing_a_package_with_config_transforms : ScenariosBase
{
private PackageResult packageResult;
Expand Down
3 changes: 3 additions & 0 deletions src/chocolatey.tests.integration/scenarios/ListScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.results;
using NuGet;
using NUnit.Framework;
using Should;

public class ListScenarios
Expand Down Expand Up @@ -58,6 +59,8 @@ public override void Because()
}

[Fact]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public void should_list_available_packages_only_once()
{
MockLogger.contains_message_count("upgradepackage").ShouldEqual(1);
Expand Down
18 changes: 17 additions & 1 deletion src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public override void Context()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_noop_uninstalling_a_package : ScenariosBase
{
public override void Context()
Expand Down Expand Up @@ -135,6 +137,8 @@ public void should_contain_a_message_that_it_was_unable_to_find_package()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_happy_path : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -326,7 +330,7 @@ public class when_uninstalling_packages_with_packages_config : ScenariosBase
public override void Context()
{
base.Context();
var packagesConfig = "{0}\\context\\testing.packages.config".format_with(Scenario.get_top_level());
var packagesConfig = "{0}{1}context{1}testing.packages.config".format_with(Scenario.get_top_level(), Path.DirectorySeparatorChar);
Configuration.PackageNames = Configuration.Input = packagesConfig;
}

Expand All @@ -343,6 +347,8 @@ public void should_throw_an_error_that_it_is_not_allowed()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_with_readonly_files : ScenariosBase
{
private PackageResult _packageResult;
Expand Down Expand Up @@ -409,6 +415,8 @@ public void should_not_have_warning_package_result()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_with_a_read_and_delete_share_locked_file : ScenariosBase
{
private PackageResult _packageResult;
Expand Down Expand Up @@ -563,6 +571,8 @@ public void should_not_have_warning_package_result()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_with_added_files : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -661,6 +671,8 @@ public void config_should_match_package_result_name()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_with_changed_files : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -759,6 +771,8 @@ public void config_should_match_package_result_name()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_force_uninstalling_a_package_with_added_and_changed_files : ScenariosBase
{
private PackageResult packageResult;
Expand Down Expand Up @@ -940,6 +954,8 @@ public void should_have_an_error_package_result()
}

[Concern(typeof(ChocolateyUninstallCommand))]
[WindowsOnly]
[Platform(Exclude = "Mono")]
public class when_uninstalling_a_package_that_errors : ScenariosBase
{
private PackageResult packageResult;
Expand Down
Loading

0 comments on commit 0745b64

Please sign in to comment.