From d4f3670056041e8cb87bb20ab5a3a8d9dd5d68db Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Wed, 4 Oct 2017 17:34:00 +0200 Subject: [PATCH] AutomatedTests: set defaults for RETRO68_LAUNCH_METHOD on old Mac OS X platforms, where "classic" and "carbon" are the obvious choices --- AutomatedTests/CMakeLists.txt | 33 +++++++++++++++++++++++++----- CMakeLists.txt | 2 +- LaunchAPPL/LaunchAPPL.cc | 38 +++++++++++++++++++++++++++++------ README.md | 3 ++- 4 files changed, 63 insertions(+), 13 deletions(-) diff --git a/AutomatedTests/CMakeLists.txt b/AutomatedTests/CMakeLists.txt index 5367f3141d..7b49a44b3c 100644 --- a/AutomatedTests/CMakeLists.txt +++ b/AutomatedTests/CMakeLists.txt @@ -1,10 +1,32 @@ -enable_testing() +cmake_minimum_required(VERSION 3.3) -set(RETRO68_LAUNCH_METHOD classic CACHE String "How to launch Mac applications (for automated testing)") - -set(RETRO68_TEST_CONFIG "--timeout=4") find_program(LAUNCH_APPL LaunchAPPL PATH "${CMAKE_INSTALL_PREFIX}/../bin/") +execute_process(COMMAND ${LAUNCH_APPL} --list-emulators + OUTPUT_VARIABLE EMULATOR_LIST) +separate_arguments(EMULATOR_LIST) + +if(CMAKE_SYSTEM_NAME MATCHES "RetroCarbon") + if("carbon" IN_LIST EMULATOR_LIST) + set(RETRO68_LAUNCH_METHOD carbon CACHE String "How to launch Mac applications (for automated testing)") + else() + set(RETRO68_LAUNCH_METHOD NONE CACHE String "How to launch Mac applications (for automated testing)") + endif() +else() + if("classic" IN_LIST EMULATOR_LIST) + set(RETRO68_LAUNCH_METHOD classic CACHE String "How to launch Mac applications (for automated testing)") + else() + set(RETRO68_LAUNCH_METHOD NONE CACHE String "How to launch Mac applications (for automated testing)") + endif() +endif() +set(RETRO68_TEST_CONFIG "--timeout=10" CACHE String "Options to pass to LaunchAPPL when running tests") + +if(RETRO68_LAUNCH_METHOD MATCHES "NONE") +else() # extends to end of file + +enable_testing() + + function(test FILE) get_filename_component(NAME ${FILE} NAME_WE) @@ -13,7 +35,7 @@ function(test FILE) -e ${RETRO68_LAUNCH_METHOD} ${RETRO68_TEST_CONFIG} ${ARGN} ${NAME}.bin) endfunction() -if(CMAKE_SYSTEM_NAME MATCHES Retro68) +if(CMAKE_SYSTEM_NAME MATCHES "Retro68") test(ReallyEmpty.c) set_target_properties(ReallyEmpty PROPERTIES LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-single") endif() @@ -36,3 +58,4 @@ set_tests_properties(Log PROPERTIES PASS_REGULAR_EXPRESSION "One\nTwo\nThree") test(Init.cc) set_tests_properties(Init PROPERTIES PASS_REGULAR_EXPRESSION "constructor\nmain\ndestructor") +endif() # RETRO68_LAUNCH_METHOD diff --git a/CMakeLists.txt b/CMakeLists.txt index d5514ae520..dd10799454 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with Retro68. If not, see . -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.3) project(Retro) set(CMAKE_CXX_STANDARD 11) diff --git a/LaunchAPPL/LaunchAPPL.cc b/LaunchAPPL/LaunchAPPL.cc index af532d75ea..64baf29173 100644 --- a/LaunchAPPL/LaunchAPPL.cc +++ b/LaunchAPPL/LaunchAPPL.cc @@ -102,6 +102,7 @@ int main(int argc, char *argv[]) desc.add_options() ("help,h", "show this help message") + ("list-emulators,l", "get the list of available, fully configured emulators/environments") ("make-executable,x", po::value(), "make a MacBinary file executable") ; po::options_description configdesc; @@ -159,19 +160,44 @@ int main(int argc, char *argv[]) po::notify(options); - if(options.count("help") || (!options.count("application") && !options.count("make-executable"))) + vector commandModes = {"application", "help", "make-executable", "list-emulators"}; + int nModes = 0; + string mode; + + for(string aMode : commandModes) + { + if(options.count(aMode)) + { + nModes++; + mode = aMode; + } + } + if(nModes > 1) + { + std::cerr << "Need to specify either an application file or exactly one of "; + for(int i = 1, n = commandModes.size(); i < n-1; i++) + std::cerr << "--" << commandModes[i] << ", "; + std::cerr << "or " << commandModes.back() << "." << std::endl << std::endl; + usage(); + return 1; + } + if(mode == "" || mode == "help") { usage(); return 0; } - - if(options.count("make-executable")) + else if(mode == "make-executable") { string fn = options["make-executable"].as(); MakeExecutable(fn); - - if(!options.count("application")) - return 0; + return 0; + } + else if(mode == "list-emulators") + { + for(LaunchMethod *method : launchMethods) + if(method->CheckOptions(options)) + std::cout << method->GetName() << std::endl; + return 0; } if(!options.count("emulator")) diff --git a/README.md b/README.md index 3e52a8ee5a..e7756fe3a9 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,8 @@ Sample programs are built in several formats: Look under `Retro68-build/build-target/` (68K), `Retro68-build/build-target-ppc/` (PowerPC Classic) and -`Retro68-build/build-target-carbon/` (PowerPC Carbon) for the compiled examples. +`Retro68-build/build-target-carbon/` (PowerPC Carbon) for the compiled examples, +especially under the `Samples` subdirectory. Components ----------