diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/CMakeLists.txt b/Code/Tools/TestImpactFramework/Frontend/Console/CMakeLists.txt index a25d506156..8298bb7123 100644 --- a/Code/Tools/TestImpactFramework/Frontend/Console/CMakeLists.txt +++ b/Code/Tools/TestImpactFramework/Frontend/Console/CMakeLists.txt @@ -9,5 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -add_subdirectory(Executable) -add_subdirectory(Static) \ No newline at end of file +add_subdirectory(Code) \ No newline at end of file diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/CMakeLists.txt b/Code/Tools/TestImpactFramework/Frontend/Console/Code/CMakeLists.txt similarity index 64% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/CMakeLists.txt rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/CMakeLists.txt index 2302cb5484..a26814fa51 100644 --- a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/CMakeLists.txt +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/CMakeLists.txt @@ -24,27 +24,42 @@ ly_add_target( AZ::TestImpact.Runtime.Static ) +ly_add_target( + NAME TestImpact.Frontend.Console EXECUTABLE + OUTPUT_NAME tiaf + NAMESPACE AZ + FILES_CMAKE + testimpactframework_frontend_console_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Source + BUILD_DEPENDENCIES + PRIVATE + AZ::TestImpact.Frontend.Console.Static +) + ################################################################################ # Tests ################################################################################ -ly_add_target( - NAME TestImpact.Frontend.Console.Static.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE AZ - FILES_CMAKE - testimpactframework_frontend_console_static_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Include - Source - Tests - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTestShared - AZ::AzTest - AZ::TestImpact.Frontend.Console.Static -) - -ly_add_googletest( - NAME AZ::TestImpact.Frontend.Console.Static.Tests -) +# Disbled:SPEC-7246 +#ly_add_target( +# NAME TestImpact.Frontend.Console.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} +# NAMESPACE AZ +# FILES_CMAKE +# testimpactframework_frontend_console_static_tests_files.cmake +# INCLUDE_DIRECTORIES +# PRIVATE +# Include +# Source +# Tests +# BUILD_DEPENDENCIES +# PRIVATE +# AZ::AzTestShared +# AZ::AzTest +# AZ::TestImpact.Frontend.Console.Static +#) +# +#ly_add_googletest( +# NAME AZ::TestImpact.Frontend.Console.Static.Tests +#) diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Include/TestImpactFramework/TestImpactConsoleMain.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Include/TestImpactFramework/TestImpactConsoleMain.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Include/TestImpactFramework/TestImpactConsoleMain.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Include/TestImpactFramework/TestImpactConsoleMain.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptions.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptions.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptions.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptions.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptions.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptions.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptions.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptions.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsException.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsException.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsException.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsException.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsUtils.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsUtils.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsUtils.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsUtils.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsUtils.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsUtils.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactCommandLineOptionsUtils.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactCommandLineOptionsUtils.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/Source/TestImpactConsole.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsole.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/Source/TestImpactConsole.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsole.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleMain.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleMain.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleMain.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleMain.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleTestSequenceEventHandler.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleTestSequenceEventHandler.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleTestSequenceEventHandler.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleTestSequenceEventHandler.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleTestSequenceEventHandler.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleTestSequenceEventHandler.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleTestSequenceEventHandler.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleTestSequenceEventHandler.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleUtils.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleUtils.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleUtils.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleUtils.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleUtils.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleUtils.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactConsoleUtils.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactConsoleUtils.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactRuntimeConfigurationFactory.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactRuntimeConfigurationFactory.cpp similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactRuntimeConfigurationFactory.cpp rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactRuntimeConfigurationFactory.cpp diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactRuntimeConfigurationFactory.h b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactRuntimeConfigurationFactory.h similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/Source/TestImpactRuntimeConfigurationFactory.h rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/Source/TestImpactRuntimeConfigurationFactory.h diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactCommandLineOptionsTest.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactCommandLineOptionsTest.cpp new file mode 100644 index 0000000000..cd02f5c5c7 --- /dev/null +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactCommandLineOptionsTest.cpp @@ -0,0 +1,1436 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#include +#include + +#include +#include +#include +#include + +namespace UnitTest +{ + class CommandLineOptionsTestFixture + : public AllocatorsTestFixture + { + public: + void SetUp() override + { + AllocatorsTestFixture::SetUp(); + m_args.push_back("program.exe"); + } + protected: + void InitOptions(); + + AZStd::unique_ptr m_options; + AZStd::vector m_args; + }; + + void CommandLineOptionsTestFixture::InitOptions() + { + m_options = AZStd::make_unique(m_args.size(), const_cast(m_args.data())); + } + + TEST_F(CommandLineOptionsTestFixture, CheckEmptyArgs_ExpectDefaultValues) + { + InitOptions(); + EXPECT_EQ(m_options->GetConfigurationFile(), LY_TEST_IMPACT_DEFAULT_CONFIG_FILE); + EXPECT_EQ(m_options->GetFailedTestCoveragePolicy(), TestImpact::Policy::FailedTestCoverage::Keep); + EXPECT_EQ(m_options->GetExecutionFailurePolicy(), TestImpact::Policy::ExecutionFailure::Continue); + EXPECT_FALSE(m_options->GetGlobalTimeout().has_value()); + EXPECT_FALSE(m_options->GetTestTargetTimeout().has_value()); + EXPECT_FALSE(m_options->GetMaxConcurrency().has_value()); + EXPECT_FALSE(m_options->HasOutputChangeList()); + EXPECT_EQ(m_options->GetTargetOutputCapture(), TestImpact::Policy::TargetOutputCapture::None); + EXPECT_EQ(m_options->GetTestFailurePolicy(), TestImpact::Policy::TestFailure::Abort); + EXPECT_EQ(m_options->GetIntegrityFailurePolicy(), TestImpact::Policy::IntegrityFailure::Abort); + EXPECT_EQ(m_options->GetTestPrioritizationPolicy(), TestImpact::Policy::TestPrioritization::None); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::None); + EXPECT_EQ(m_options->GetTestShardingPolicy(), TestImpact::Policy::TestSharding::Never); + EXPECT_FALSE(m_options->HasChangeListFile()); + EXPECT_FALSE(m_options->GetChangeListFile().has_value()); + EXPECT_FALSE(m_options->HasSafeMode()); + EXPECT_EQ(m_options->GetSuiteFilter(), TestImpact::SuiteType::Main); + } + + TEST_F(CommandLineOptionsTestFixture, ConfigurationFileHasEmptyPath_ExpectCommandLineOptionsException) + { + m_args.push_back("-config"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, ConfigurationFileHasSpecifiedPath_ExpectPath) + { + m_args.push_back("-config"); + m_args.push_back("Foo\\Bar"); + InitOptions(); + EXPECT_STREQ(m_options->GetConfigurationFile().c_str(), "Foo\\Bar"); + } + + TEST_F(CommandLineOptionsTestFixture, ConfigurationFileHasMultiplePaths_ExpectCommandLineOptionsException) + { + m_args.push_back("-config"); + m_args.push_back("value1,value2"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, UnifiedDiffFileHasEmptyPath_ExpectCommandLineOptionsException) + { + m_args.push_back("-changelist"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, UnifiedDiffFileHasSpecifiedPath_ExpectPath) + { + m_args.push_back("-changelist"); + m_args.push_back("Foo\\Bar"); + InitOptions(); + EXPECT_TRUE(m_options->HasChangeListFile()); + EXPECT_STREQ(m_options->GetChangeListFile()->c_str(), "Foo\\Bar"); + } + + TEST_F(CommandLineOptionsTestFixture, UnifiedDiffFileHasMultiplePaths_ExpectCommandLineOptionsException) + { + m_args.push_back("-changelist"); + m_args.push_back("value1,value2"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, OutputChangeListHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ochangelist"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, OutputChangeListHasMultipleValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-ochangelist"); + m_args.push_back("value1,value2,value3"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-sequence"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasNoneOption_ExpectNoneTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("none"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::None); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasSeedOption_ExpectSeedTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("seed"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::Seed); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasRegularOption_ExpectRegularTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("regular"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::Regular); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasImpactAnalysisOption_ExpectImpactAnalysisTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("tia"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::ImpactAnalysis); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasImpactAnalysisNoWriteOption_ExpectImpactAnalysisNoWriteTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("tianowrite"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::ImpactAnalysisNoWrite); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasSafeImpactAnalysisOption_ExpectSafeImpactAnalysisTestSequenceType) + { + m_args.push_back("-sequence"); + m_args.push_back("tiaorseed"); + InitOptions(); + EXPECT_EQ(m_options->GetTestSequenceType(), TestImpact::TestSequenceType::ImpactAnalysisOrSeed); + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-sequence"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestSequenceTypeHasMultipleValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-sequence"); + m_args.push_back("seed,tia"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TestPrioritizationPolicyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ppolicy"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestPrioritizationPolicyHasNoneOption_ExpectNoneTestPrioritizationPolicy) + { + m_args.push_back("-ppolicy"); + m_args.push_back("none"); + InitOptions(); + EXPECT_EQ(m_options->GetTestPrioritizationPolicy(), TestImpact::Policy::TestPrioritization::None); + } + + TEST_F(CommandLineOptionsTestFixture, TestPrioritizationPolicyHasDependencyLocalityOption_ExpectDependencyLocalityTestPrioritizationPolicy) + { + m_args.push_back("-ppolicy"); + m_args.push_back("locality"); + InitOptions(); + EXPECT_EQ(m_options->GetTestPrioritizationPolicy(), TestImpact::Policy::TestPrioritization::DependencyLocality); + } + + TEST_F(CommandLineOptionsTestFixture, TestPrioritizationPolicyInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ppolicy"); + m_args.push_back("none,locality"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ppolicy"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasAbortOption_ExpectAbortExecutionFailurePolicy) + { + m_args.push_back("-epolicy"); + m_args.push_back("abort"); + InitOptions(); + EXPECT_EQ(m_options->GetExecutionFailurePolicy(), TestImpact::Policy::ExecutionFailure::Abort); + } + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasContinueOption_ExpectContinueExecutionFailurePolicy) + { + m_args.push_back("-epolicy"); + m_args.push_back("continue"); + InitOptions(); + EXPECT_EQ(m_options->GetExecutionFailurePolicy(), TestImpact::Policy::ExecutionFailure::Continue); + } + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasIgnoreOption_ExpectIgnoreExecutionFailurePolicy) + { + m_args.push_back("-epolicy"); + m_args.push_back("ignore"); + InitOptions(); + EXPECT_EQ(m_options->GetExecutionFailurePolicy(), TestImpact::Policy::ExecutionFailure::Ignore); + } + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-epolicy"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailurePolicyHasMultipleValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-epolicy"); + m_args.push_back("abort,ingore"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, ExecutionFailureDraftingPolicyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-rexecfailures"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, FailedTestCoveragePolicyHasKeepOption_ExpectKeepFailedTestCoveragePolicy) + { + m_args.push_back("-cpolicy"); + m_args.push_back("keep"); + InitOptions(); + EXPECT_EQ(m_options->GetFailedTestCoveragePolicy(), TestImpact::Policy::FailedTestCoverage::Keep); + } + + TEST_F(CommandLineOptionsTestFixture, FailedTestCoveragePolicyHasDiscardOption_ExpectDiscardFailedTestCoveragePolicy) + { + m_args.push_back("-cpolicy"); + m_args.push_back("discard"); + InitOptions(); + EXPECT_EQ(m_options->GetFailedTestCoveragePolicy(), TestImpact::Policy::FailedTestCoverage::Discard); + } + + TEST_F(CommandLineOptionsTestFixture, FailedTestCoveragePolicyInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-cpolicy"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, FailedTestCoveragePolicyPolicyHasMultipleValues_ExpectCommandLineOptionsException) + { + m_args.push_back("--cpolicy"); + m_args.push_back("keep,discard"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TestFailurePolicyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-fpolicy"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestFailurePolicyHasAbortOption_ExpectAbortTestFailurePolicy) + { + m_args.push_back("-fpolicy"); + m_args.push_back("abort"); + InitOptions(); + EXPECT_EQ(m_options->GetTestFailurePolicy(), TestImpact::Policy::TestFailure::Abort); + } + + TEST_F(CommandLineOptionsTestFixture, TestFailurePolicyHasContinueOption_ExpectContinueTestFailurePolicy) + { + m_args.push_back("-fpolicy"); + m_args.push_back("continue"); + InitOptions(); + EXPECT_EQ(m_options->GetTestFailurePolicy(), TestImpact::Policy::TestFailure::Continue); + } + + TEST_F(CommandLineOptionsTestFixture, TestFailurePolicyInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-fpolicy"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestFailurePolicyHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-fpolicy"); + m_args.push_back("abort,continue"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, IntegrityFailurePolicyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ipolicy"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, IntegrityFailurePolicyHasAbortOption_ExpectAbortIntegrityFailurePolicy) + { + m_args.push_back("-ipolicy"); + m_args.push_back("abort"); + InitOptions(); + EXPECT_EQ(m_options->GetIntegrityFailurePolicy(), TestImpact::Policy::IntegrityFailure::Abort); + } + + TEST_F(CommandLineOptionsTestFixture, IntegrityFailurePolicyHasContinueOption_ExpectContinueIntegrityFailurePolicy) + { + m_args.push_back("-ipolicy"); + m_args.push_back("continue"); + InitOptions(); + EXPECT_EQ(m_options->GetIntegrityFailurePolicy(), TestImpact::Policy::IntegrityFailure::Continue); + } + + TEST_F(CommandLineOptionsTestFixture, IntegrityFailurePolicyInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ipolicy"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, IntegrityFailurePolicyHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-ipolicy"); + m_args.push_back("abort,continue"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TestShardingHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-shard"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestShardingHasOnOption_ExpectOnTestSharding) + { + m_args.push_back("-shard"); + m_args.push_back("on"); + InitOptions(); + EXPECT_EQ(m_options->GetTestShardingPolicy(), TestImpact::Policy::TestSharding::Always); + } + + TEST_F(CommandLineOptionsTestFixture, TestShardingHasOffOption_ExpectOffTestSharding) + { + m_args.push_back("-shard"); + m_args.push_back("off"); + InitOptions(); + EXPECT_EQ(m_options->GetTestShardingPolicy(), TestImpact::Policy::TestSharding::Never); + } + + TEST_F(CommandLineOptionsTestFixture, TestShardingInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-shard"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestShardingHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-shard"); + m_args.push_back("on,off"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-targetout"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureHasStdOutOption_ExpectStdOutTargetOutputCapture) + { + m_args.push_back("-targetout"); + m_args.push_back("stdout"); + InitOptions(); + EXPECT_EQ(m_options->GetTargetOutputCapture(), TestImpact::Policy::TargetOutputCapture::StdOut); + } + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureHasFileOption_ExpectFileTargetOutputCapture) + { + m_args.push_back("-targetout"); + m_args.push_back("file"); + InitOptions(); + EXPECT_EQ(m_options->GetTargetOutputCapture(), TestImpact::Policy::TargetOutputCapture::File); + } + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureHasStdOutAndFileOption_ExpectStdOutAndFileTargetOutputCapture) + { + m_args.push_back("-targetout"); + m_args.push_back("stdout,file"); + InitOptions(); + EXPECT_EQ(m_options->GetTargetOutputCapture(), TestImpact::Policy::TargetOutputCapture::StdOutAndFile); + } + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-targetout"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TargetOutputCaptureHasExcessValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-targetout"); + m_args.push_back("stdout,file,stdout"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, MaxConcurrencyHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-maxconcurrency"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, MaxConcurrencyHasInRangeOptions_ExpectInRangeMaxConcurrency) + { + m_args.push_back("-maxconcurrency"); + m_args.push_back("10"); + InitOptions(); + EXPECT_EQ(m_options->GetMaxConcurrency(), 10); + } + + TEST_F(CommandLineOptionsTestFixture, MaxConcurrencyHasOutOfRangeOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-maxconcurrency"); + m_args.push_back("-1"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, MaxConcurrencyInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-maxconcurrency"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, MaxConcurrencyHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-maxconcurrency"); + m_args.push_back("10,20"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, TestTargetTimeoutHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ttimeout"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestTargetTimeoutHasInRangeOptions_ExpectInRangeTestTargetTimeout) + { + m_args.push_back("-ttimeout"); + m_args.push_back("10"); + InitOptions(); + EXPECT_EQ(m_options->GetTestTargetTimeout(), AZStd::chrono::seconds(10)); + } + + TEST_F(CommandLineOptionsTestFixture, TestTargetTimeoutHasOutOfRangeOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ttimeout"); + m_args.push_back("-1"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestTargetTimeoutInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-ttimeout"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, TestTargetTimeoutHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-ttimeout"); + m_args.push_back("10,20"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, GlobalTimeoutHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-gtimeout"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, GlobalTimeoutHasInRangeOptions_ExpectInRangeGlobalTimeout) + { + m_args.push_back("-gtimeout"); + m_args.push_back("10"); + InitOptions(); + EXPECT_EQ(m_options->GetGlobalTimeout(), AZStd::chrono::seconds(10)); + } + + TEST_F(CommandLineOptionsTestFixture, GlobalTimeoutHasOutOfRangeOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-gtimeout"); + m_args.push_back("-1"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, GlobalTimeoutInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-gtimeout"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, GlobalTimeoutHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-gtimeout"); + m_args.push_back("10,20"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + // + + TEST_F(CommandLineOptionsTestFixture, SafeModeHasEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-safemode"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, SafeModeHasOnOption_ExpectOnSafeMode) + { + m_args.push_back("-safemode"); + m_args.push_back("on"); + InitOptions(); + EXPECT_TRUE(m_options->HasSafeMode()); + } + + TEST_F(CommandLineOptionsTestFixture, SafeModeHasOffOption_ExpectOffSafeMode) + { + m_args.push_back("-safemode"); + m_args.push_back("off"); + InitOptions(); + EXPECT_FALSE(m_options->HasSafeMode()); + } + + TEST_F(CommandLineOptionsTestFixture, SafeModeInvalidOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-safemode"); + m_args.push_back("foo"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, SafeModeHasMultipeValues_ExpectCommandLineOptionsException) + { + m_args.push_back("-safemode"); + m_args.push_back("on,off"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, SuiteFilterEmptyOption_ExpectCommandLineOptionsException) + { + m_args.push_back("-suite"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } + catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } + catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, SuiteFilterMultipleOptions_ExpectCommandLineOptionsException) + { + m_args.push_back("-suite"); + m_args.push_back("periodic,smoke"); + + try + { + InitOptions(); + + // Do not expect the command line options construction to succeed + FAIL(); + } catch ([[maybe_unused]] const TestImpact::CommandLineOptionsException& e) + { + // Expect a command line options to be thrown + SUCCEED(); + } catch (...) + { + // Do not expect any other exceptions + FAIL(); + } + } + + TEST_F(CommandLineOptionsTestFixture, SuitesFilterMainOption_ExpectMainSuiteFilter) + { + m_args.push_back("-suites"); + m_args.push_back("main"); + InitOptions(); + EXPECT_EQ(m_options->GetSuiteFilter(), TestImpact::SuiteType::Main); + } + + TEST_F(CommandLineOptionsTestFixture, SuitesFilterPeriodicOption_ExpectPeriodicSuiteFilter) + { + m_args.push_back("-suites"); + m_args.push_back("periodic"); + InitOptions(); + EXPECT_EQ(m_options->GetSuiteFilter(), TestImpact::SuiteType::Periodic); + } + + TEST_F(CommandLineOptionsTestFixture, SuitesFilterSandboxOption_ExpectSandboxSuiteFilter) + { + m_args.push_back("-suites"); + m_args.push_back("sandbox"); + InitOptions(); + EXPECT_EQ(m_options->GetSuiteFilter(), TestImpact::SuiteType::Sandbox); + } +} diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactConsoleMainTest.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactConsoleMainTest.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactConsoleTestSequenceEventHandlerTest.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactConsoleTestSequenceEventHandlerTest.cpp new file mode 100644 index 0000000000..52422daa31 --- /dev/null +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactConsoleTestSequenceEventHandlerTest.cpp @@ -0,0 +1,42 @@ +///* +// * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +// * its licensors. +// * +// * For complete copyright and license terms please see the LICENSE at the root of this +// * distribution (the "License"). All use of this software is governed by the License, +// * or, if provided, by the license below or the license accompanying this file. Do not +// * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * +// */ +// +//#include +//#include +// +//#include +// +//#include +//#include +//#include +//#include +// +//namespace UnitTest +//{ +// class ConsoleTestSequenceTestFixture +// : public AllocatorsTestFixture +// { +// }; +// +// TEST_F(ConsoleTestSequenceTestFixture, CheckEmptyArgs_ExpectDefaultValues) +// { +// AZStd::unordered_set suites = { "PERIODIC","MAIN" }; +// TestImpact::Console::TestSequenceEventHandler seq(&suites); +// AZStd::vector selectedTests = { "Test1", "Test2", "Test3", "Test4", "Test5" }; +// seq.operator()(TestImpact::Client::TestRunSelection(selectedTests, {"Test6"})); +// +// for (auto i = 0; i < selectedTests.size(); i++) +// { +// seq.operator()(TestImpact::Client::TestRun(selectedTests[i], (TestImpact::Client::TestRunResult)i, AZStd::chrono::milliseconds(i))); +// } +// } +//} diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactFrontendConsoleStaticTestMain.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactFrontendConsoleStaticTestMain.cpp new file mode 100644 index 0000000000..9e128f90af --- /dev/null +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactFrontendConsoleStaticTestMain.cpp @@ -0,0 +1,34 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#include +#include +#include + +class TestImpactTestEnvironment + : public AZ::Test::ITestEnvironment +{ +protected: + void SetupEnvironment() override + { + AZ::AllocatorInstance::Create(); + AZ::AllocatorInstance::Create(); + } + + void TeardownEnvironment() override + { + AZ::AllocatorInstance::Destroy(); + AZ::AllocatorInstance::Destroy(); + } +}; + +AZ_UNIT_TEST_HOOK(new TestImpactTestEnvironment); diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactRuntimeConfigurationFactoryTest.cpp b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactRuntimeConfigurationFactoryTest.cpp new file mode 100644 index 0000000000..4b1b3f162e --- /dev/null +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/Tests/TestImpactRuntimeConfigurationFactoryTest.cpp @@ -0,0 +1,27 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#include + +#include + +#include + +namespace UnitTest +{ + //TEST(FOO, BAR) + //{ + // std::ifstream configFile("C:\\o3de_TIF_Feature\\windows_vs2019\\bin\\debug\\tiaf.debug.json"); + // AZStd::string configData((std::istreambuf_iterator(configFile)), std::istreambuf_iterator()); + // const auto configuration = TestImpact::ConfigurationFactory(configData); + //} +} diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/testimpactframework_frontend_console_files.cmake b/Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_files.cmake similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/testimpactframework_frontend_console_files.cmake rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_files.cmake diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/testimpactframework_frontend_console_static_files.cmake b/Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_static_files.cmake similarity index 100% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/testimpactframework_frontend_console_static_files.cmake rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_static_files.cmake diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/testimpactframework_frontend_console_static_tests_files.cmake b/Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_static_tests_files.cmake similarity index 67% rename from Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/testimpactframework_frontend_console_static_tests_files.cmake rename to Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_static_tests_files.cmake index 5714be5dfb..4d8e65b2cc 100644 --- a/Code/Tools/TestImpactFramework/Frontend/Console/Static/Code/testimpactframework_frontend_console_static_tests_files.cmake +++ b/Code/Tools/TestImpactFramework/Frontend/Console/Code/testimpactframework_frontend_console_static_tests_files.cmake @@ -10,4 +10,9 @@ # set(FILES + Tests/TestImpactCommandLineOptionsTest.cpp + Tests/TestImpactRuntimeConfigurationFactoryTest.cpp + Tests/TestImpactFrontendConsoleStaticTestMain.cpp + Tests/TestImpactConsoleMainTest.cpp + Tests/TestImpactConsoleTestSequenceEventHandlerTest.cpp ) diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/CMakeLists.txt b/Code/Tools/TestImpactFramework/Frontend/Console/Executable/CMakeLists.txt deleted file mode 100644 index 8298bb7123..0000000000 --- a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -add_subdirectory(Code) \ No newline at end of file diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/CMakeLists.txt b/Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/CMakeLists.txt deleted file mode 100644 index 88da472e1e..0000000000 --- a/Code/Tools/TestImpactFramework/Frontend/Console/Executable/Code/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -ly_add_target( - NAME TestImpact.Frontend.Console EXECUTABLE - OUTPUT_NAME tiaf - NAMESPACE AZ - FILES_CMAKE - testimpactframework_frontend_console_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Source - BUILD_DEPENDENCIES - PRIVATE - AZ::TestImpact.Frontend.Console.Static -) - diff --git a/Code/Tools/TestImpactFramework/Frontend/Console/Static/CMakeLists.txt b/Code/Tools/TestImpactFramework/Frontend/Console/Static/CMakeLists.txt deleted file mode 100644 index 8298bb7123..0000000000 --- a/Code/Tools/TestImpactFramework/Frontend/Console/Static/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -add_subdirectory(Code) \ No newline at end of file diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/CMakeLists.txt b/Code/Tools/TestImpactFramework/Runtime/Code/CMakeLists.txt index 4c021a12b4..bcfeeacb33 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/CMakeLists.txt +++ b/Code/Tools/TestImpactFramework/Runtime/Code/CMakeLists.txt @@ -40,48 +40,49 @@ ly_add_target( # Tests ################################################################################ -ly_add_target( - NAME TestImpact.Runtime.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE AZ - FILES_CMAKE - testimpactframework_runtime_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Include - Source - Tests - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTestShared - AZ::AzTest - AZ::TestImpact.Runtime.Static - RUNTIME_DEPENDENCIES - AZ::AzTestRunner - AZ::TestImpact.TestProcess.Console - AZ::TestImpact.TestTargetA.Tests - AZ::TestImpact.TestTargetB.Tests - AZ::TestImpact.TestTargetC.Tests - AZ::TestImpact.TestTargetD.Tests - COMPILE_DEFINITIONS - PRIVATE - LY_TEST_IMPACT_AZ_TESTRUNNER_BIN="$" - LY_TEST_IMPACT_TEST_PROCESS_BIN="$" - LY_TEST_IMPACT_TEST_TARGET_A_BIN="$" - LY_TEST_IMPACT_TEST_TARGET_B_BIN="$" - LY_TEST_IMPACT_TEST_TARGET_C_BIN="$" - LY_TEST_IMPACT_TEST_TARGET_D_BIN="$" - LY_TEST_IMPACT_TEST_TARGET_A_BASE_NAME="$" - LY_TEST_IMPACT_TEST_TARGET_B_BASE_NAME="$" - LY_TEST_IMPACT_TEST_TARGET_C_BASE_NAME="$" - LY_TEST_IMPACT_TEST_TARGET_D_BASE_NAME="$" - LY_TEST_IMPACT_TEST_TARGET_ENUMERATION_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Enum" - LY_TEST_IMPACT_TEST_TARGET_RESULTS_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Result" - LY_TEST_IMPACT_TEST_TARGET_COVERAGE_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Coverage" - LY_TEST_IMPACT_INSTRUMENTATION_BIN="${LY_TEST_IMPACT_INSTRUMENTATION_BIN}" - LY_TEST_IMPACT_MODULES_DIR="${CMAKE_BINARY_DIR}" - LY_TEST_IMPACT_COVERAGE_SOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}" -) - -ly_add_googletest( - NAME AZ::TestImpact.Runtime.Tests -) +# Disabled: SPEC-7246 +#ly_add_target( +# NAME TestImpact.Runtime.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} +# NAMESPACE AZ +# FILES_CMAKE +# testimpactframework_runtime_tests_files.cmake +# INCLUDE_DIRECTORIES +# PRIVATE +# Include +# Source +# Tests +# BUILD_DEPENDENCIES +# PRIVATE +# AZ::AzTestShared +# AZ::AzTest +# AZ::TestImpact.Runtime.Static +# RUNTIME_DEPENDENCIES +# AZ::AzTestRunner +# AZ::TestImpact.TestProcess.Console +# AZ::TestImpact.TestTargetA.Tests +# AZ::TestImpact.TestTargetB.Tests +# AZ::TestImpact.TestTargetC.Tests +# AZ::TestImpact.TestTargetD.Tests +# COMPILE_DEFINITIONS +# PRIVATE +# LY_TEST_IMPACT_AZ_TESTRUNNER_BIN="$" +# LY_TEST_IMPACT_TEST_PROCESS_BIN="$" +# LY_TEST_IMPACT_TEST_TARGET_A_BIN="$" +# LY_TEST_IMPACT_TEST_TARGET_B_BIN="$" +# LY_TEST_IMPACT_TEST_TARGET_C_BIN="$" +# LY_TEST_IMPACT_TEST_TARGET_D_BIN="$" +# LY_TEST_IMPACT_TEST_TARGET_A_BASE_NAME="$" +# LY_TEST_IMPACT_TEST_TARGET_B_BASE_NAME="$" +# LY_TEST_IMPACT_TEST_TARGET_C_BASE_NAME="$" +# LY_TEST_IMPACT_TEST_TARGET_D_BASE_NAME="$" +# LY_TEST_IMPACT_TEST_TARGET_ENUMERATION_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Enum" +# LY_TEST_IMPACT_TEST_TARGET_RESULTS_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Result" +# LY_TEST_IMPACT_TEST_TARGET_COVERAGE_DIR="${GTEST_XML_OUTPUT_DIR}/TestImpact/Temp/Exclusive/Coverage" +# LY_TEST_IMPACT_INSTRUMENTATION_BIN="${LY_TEST_IMPACT_INSTRUMENTATION_BIN}" +# LY_TEST_IMPACT_MODULES_DIR="${CMAKE_BINARY_DIR}" +# LY_TEST_IMPACT_COVERAGE_SOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}" +#) +# +#ly_add_googletest( +# NAME AZ::TestImpact.Runtime.Tests +#) diff --git a/cmake/LYTestWrappers.cmake b/cmake/LYTestWrappers.cmake index eebc281d06..1bacc4feb0 100644 --- a/cmake/LYTestWrappers.cmake +++ b/cmake/LYTestWrappers.cmake @@ -315,6 +315,7 @@ function(ly_add_pytest) ${ly_add_pytest_UNPARSED_ARGUMENTS} ) + set_property(GLOBAL APPEND PROPERTY LY_ALL_TESTS_${ly_add_pytest_NAME}_SCRIPT_PATH ${ly_add_pytest_PATH}) set_tests_properties(${LY_ADDED_TEST_NAME} PROPERTIES RUN_SERIAL "${ly_add_pytest_TEST_SERIAL}") endfunction() diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 9201e13a80..81100eead7 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -88,7 +88,7 @@ "COMMAND": "python_windows.cmd", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/TestImpactAnalysis/tiaf_driver.py", - "SCRIPT_PARAMETERS": "--testFailurePolicy abort --safeMode --suite main --pipeline !PIPELINE_NAME! --destCommit !CHANGE_ID! --config \"build\\windows_vs2019\\bin\\TestImpactFramework\\persistent\\tiaf.profile.json\"" + "SCRIPT_PARAMETERS": "--testFailurePolicy abort --safeMode --suite main --pipeline !PIPELINE_NAME! --destCommit !CHANGE_ID! --config \"!OUTPUT_DIRECTORY!\\TestImpactFramework\\persistent\\tiaf.profile.json\"" } }, "debug_vs2019": { diff --git a/scripts/build/TestImpactAnalysis/tiaf.py b/scripts/build/TestImpactAnalysis/tiaf.py index c040ae1147..19c1b2754d 100644 --- a/scripts/build/TestImpactAnalysis/tiaf.py +++ b/scripts/build/TestImpactAnalysis/tiaf.py @@ -219,49 +219,4 @@ class TestImpact: else: print(f"The test impact analysis runtime returned with error: '{result.returncode}'.") return result.returncode - - - - #args = [] - #print("Please note: test impact analysis sequences will be run in read-only mode (seed sequences are unaffected).") - #if sequence_type == SequenceType.REGULAR: - # print("Sequence type: regular.") - # args.append("--sequence=regular") - # args.append("--fpolicy=abort") - #elif sequence_type == SequenceType.SEED: - # print("Sequence type: seed.") - # args.append("--sequence=seed") - # args.append("--fpolicy=continue") - #elif sequence_type == SequenceType.TEST_IMPACT_ANALYSIS: - # print("Sequence type: test impact analysis (no write).") - # args.append("--fpolicy=abort") - # if self.__has_change_list: - # args.append(f"-changelist={self.__change_list_path}") - # args.append("--sequence=tianowrite") - # else: - # print(f"No change list was generated, falling back to a regular sequence.") - # print("Sequence type: Regular.") - # args.append("--sequence=regular") - #else: - # raise ValueError(sequence_type) - # - #if test_timeout != None: - # args.append(f"--ttimeout={test_timeout}") - # print(f"Test target timeout is set to {test_timeout} seconds.") - #if global_timeout != None: - # args.append(f"--gtimeout={global_timeout}") - # print(f"Global sequence timeout is set to {test_timeout} seconds.") - # - #print("Args: ", end='') - #print(*args) - #result = subprocess.run([self.__tiaf_bin] + args) - #if result.returncode == 0: - # print("Test impact analysis runtime returned successfully.") - # if sequence_type == SequenceType.SEED: - # print("Writing historical meta-data...") - # self.__write_last_run_hash(self.__dst_commit) - # print("Complete!") - #else: - # print(f"The test impact analysis runtime returned with error: '{result.returncode}'.") - #return result.returncode - + \ No newline at end of file diff --git a/scripts/build/TestImpactAnalysis/tiaf_driver.py b/scripts/build/TestImpactAnalysis/tiaf_driver.py index 7ff73e505b..f452b9738f 100644 --- a/scripts/build/TestImpactAnalysis/tiaf_driver.py +++ b/scripts/build/TestImpactAnalysis/tiaf_driver.py @@ -57,4 +57,5 @@ if __name__ == "__main__": args = parse_args() tiaf = TestImpact(args.config, args.pipeline, args.dst_commit) return_code = tiaf.run(args.suite, args.test_failure_policy, args.safe_mode, args.test_timeout, args.global_timeout) - sys.exit(return_code) \ No newline at end of file + sys.exit(return_code) + \ No newline at end of file