From fe65ba9d67a19942b4f04f438727520585ccc6e1 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Sat, 31 Oct 2026 20:37:25 +1100 Subject: [PATCH 1/3] Command line argument tests on macOS, Linux and Windows CI; unknown options, a bare value option at the end and --platform are errors --- commandLine/src/main.cpp | 13 +- scripts/linux/test_cmdline.sh | 3 + scripts/osx/test_cmdline.sh | 7 +- scripts/test_cmdline_args.sh | 304 ++++++++++++++++++++++++++++++++++ scripts/vs/test_cmdline.sh | 3 + 5 files changed, 325 insertions(+), 5 deletions(-) create mode 100755 scripts/test_cmdline_args.sh diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 9737ae2ae..b11b23e9b 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -56,7 +56,7 @@ constexpr option::Descriptor usage[] = { { SRCEXTERNAL, 0, "s", "source", option::Arg::Optional, " --source, -s \trelative or absolute path to source or include folders external to the project (such as ../../../../common_utils/" }, { VERSION, 0, "w", "version", option::Arg::None, " --version, -w \treturn the current version" }, { GET_OFPATH, 0, "g", "getofpath", option::Arg::None, " --getofpath, -g \treturn the current ofPath" }, - { GET_HOST_PLATFORM, 0, "i", "platform", option::Arg::None, " --getplatform, -i \treturn the current host platform" }, + { GET_HOST_PLATFORM, 0, "i", "getplatform", option::Arg::None, " --getplatform, -i \treturn the current host platform" }, { GET_EMSDK, 0, "e", "getemsdk", option::Arg::None, " --getemsdk, -e \tdetect the Emscripten SDK (EMSDK env var, PATH, or a Homebrew install) and return its location" }, { OFMENU, 0, "m", "ofmenu", option::Arg::Optional, " --ofmenu, -m \trun an oF Menu (scripts/of.sh) command: status | update-libs" }, { COMMAND, 0, "c", "command", option::Arg::None, " --command, -c \truns command" }, @@ -482,8 +482,9 @@ int pgMain(int argc, char ** argv) { std::string a { argv[i] }; bool isValueOption = (a.size() == 2 && a[0] == '-' && valueShort.find(a[1]) != std::string::npos) || (a.rfind("--", 0) == 0 && std::find(valueLong.begin(), valueLong.end(), a.substr(2)) != valueLong.end()); - bool keyword = a == "-m" || a == "--ofmenu"; // status / update-libs, no project path after it - if (isValueOption && i + 1 < argc && argv[i + 1][0] != '-' && (i + 2 < argc || keyword)) { + // only -f / --frameworks / --system-libs mean something empty (remove), so -f keeps the path + bool emptyMeansRemove = a == "-f" || a == "--frameworks" || a == "--system-libs"; + if (isValueOption && i + 1 < argc && argv[i + 1][0] != '-' && (i + 2 < argc || !emptyMeansRemove)) { joinedArgs.emplace_back(a + (a.size() == 2 ? "" : "=") + argv[i + 1]); i++; } else { @@ -505,6 +506,12 @@ int pgMain(int argc, char ** argv) { messageError("Parse error for arguments"); return 1; } + if (options[UNKNOWN].count() > 0) { + std::string unknown; + for (option::Option * o = options[UNKNOWN]; o; o = o->next()) unknown += std::string(unknown.empty() ? "" : ", ") + o->name; + messageError("Unknown option: " + unknown + " - see --help"); + return EXIT_USAGE; + } if (options[VERBOSE].count() > 0) { bVerbose = true; diff --git a/scripts/linux/test_cmdline.sh b/scripts/linux/test_cmdline.sh index e7e0a2092..8a32dedc2 100755 --- a/scripts/linux/test_cmdline.sh +++ b/scripts/linux/test_cmdline.sh @@ -45,4 +45,7 @@ errorcode=$? if [[ $errorcode -ne 0 ]]; then exit $errorcode fi +echo "Test command line arguments" +"${CURRENT_DIR}/../test_cmdline_args.sh" ./projectGenerator ../../../../ linux64 + echo "Successful projectGenerator tests for [linux64]"; diff --git a/scripts/osx/test_cmdline.sh b/scripts/osx/test_cmdline.sh index 6c5adac16..d0e662210 100755 --- a/scripts/osx/test_cmdline.sh +++ b/scripts/osx/test_cmdline.sh @@ -31,18 +31,21 @@ fi echo "Test: projectGenerator building" echo "Test 1: test examples templates - auto path to openFrameworks core" -./projectGenerator --recursive -posx ../../examples/templates +./projectGenerator --recursive -posx ../../examples/templates || exit 1 echo "Test 1: test examples templates - success" echo "Test: projectGenerator building" echo "Test 2: all examples - defined core openFrameworks path ../../" -./projectGenerator --recursive -posx -o../../ ../../examples/ ./projectGenerator +./projectGenerator --recursive -posx -o../../ ../../examples/ || exit 1 echo "Test 2: all examples - success" echo "Test 3: addon defines / cflags / sources in every Xcode app target (osx, macos, ios, tvos)" "${CURRENT_DIR}/test_xcode_addon_flags.sh" ./projectGenerator "${PG_DIR}/../.." || exit 1 echo "Test 3: addon defines / cflags / sources - success" +echo "Test 4: command line arguments" +"${CURRENT_DIR}/../test_cmdline_args.sh" ./projectGenerator "${PG_DIR}/../.." osx || exit 1 + # echo "test out of folder -o [vs]"; # rm -rf ../../../../../pg2 # mkdir -p ../../../../../pg2 diff --git a/scripts/test_cmdline_args.sh b/scripts/test_cmdline_args.sh new file mode 100755 index 000000000..d7c8752ca --- /dev/null +++ b/scripts/test_cmdline_args.sh @@ -0,0 +1,304 @@ +#!/usr/bin/env bash + +# projectGenerator command line argument tests: attached / separate / = values, options before and +# after the project path, empty and bad values, and the project never ending up somewhere else +# (a value taken as the path once made projects at the OF root or named after an option value) +# +# usage: test_cmdline_args.sh [platform] +# platform defaults to the host's: osx, linux64 or vs + +PG="$1" +OF="$2" +PLATFORM="$3" +if [ -z "$PG" ] || [ -z "$OF" ] || [ ! -f "$PG" ] || [ ! -d "$OF/scripts/templates" ]; then + echo "usage: $0 [platform]" + exit 2 +fi +PG="$(cd "$(dirname "$PG")" && pwd)/$(basename "$PG")" +OF="$(cd "$OF" && pwd)" +if [ -z "$PLATFORM" ]; then + case "$(uname -s)" in + Darwin) PLATFORM=osx ;; + Linux) PLATFORM=linux64 ;; + *) PLATFORM=vs ;; + esac +fi +case "$PLATFORM" in + osx|ios|tvos|macos) PROJECT_FILE="myApp.xcodeproj" ;; + vs) PROJECT_FILE="myApp.vcxproj" ;; + *) PROJECT_FILE="Makefile" ;; +esac +XCODE=0 +[ "$PROJECT_FILE" = "myApp.xcodeproj" ] && XCODE=1 +# vs has no config.make template, so defines / version only go to the vcxproj there +HAS_CONFIG_TEMPLATE=0 +[ -f "$OF/scripts/templates/$PLATFORM/config.make" ] && HAS_CONFIG_TEMPLATE=1 + +# everything runs from apps/ with relative paths (no MSYS path conversion on Windows) +RUN_DIR="$OF/apps" +TEST_DIR="$RUN_DIR/myApps/pgArgTests" +APP="myApps/pgArgTests/myApp" +APP_DIR="$TEST_DIR/myApp" + +FAILS=0 +CASES=0 +CASE="" +OUT="" +CODE=0 + +listing() { + ls -a "$OF" "$RUN_DIR" "$RUN_DIR/myApps" 2>/dev/null | grep -v '^pgArgTests$' +} +BEFORE="$(listing)" + +reset() { + rm -rf "$TEST_DIR" + mkdir -p "$APP_DIR/src" + if [ -d "$OF/examples/templates/emptyExample/src" ]; then + cp "$OF/examples/templates/emptyExample/src/"* "$APP_DIR/src/" + else + printf '#include "ofMain.h"\nint main() { return 0; }\n' > "$APP_DIR/src/main.cpp" + fi +} + +pg() { + OUT="$(cd "$RUN_DIR" && "$PG" "$@" 2>&1)" + CODE=$? +} + +fail() { + echo " FAIL [$CASE]: $1" + FAILS=$((FAILS + 1)) +} + +start() { + CASE="$1" + CASES=$((CASES + 1)) + reset +} + +config() { + tr -d '\r' < "$APP_DIR/config.make" 2>/dev/null | grep -E "^$1[[:space:]]*=" | tail -1 | sed -E "s/^$1[[:space:]]*=[[:space:]]*//" +} + +expect_exit() { + [ "$CODE" = "$1" ] || fail "exit $CODE, expected $1" +} + +expect_updated() { + [ -e "$APP_DIR/$PROJECT_FILE" ] || fail "$APP/$PROJECT_FILE not written" +} + +expect_not_updated() { + [ ! -e "$APP_DIR/$PROJECT_FILE" ] || fail "$APP/$PROJECT_FILE written" +} + +expect_config() { + local got + got="$(config "$1")" + [ "$got" = "$2" ] || fail "config.make $1 = '$got', expected '$2'" +} + +expect_no_config() { + local got + got="$(config "$1")" + [ -z "$got" ] || fail "config.make $1 = '$got', expected none" +} + +expect_output() { + echo "$OUT" | grep -qE "$1" || fail "output has no '$1'" +} + +expect_pbxproj() { + [ "$XCODE" = 1 ] || return 0 + grep -q "$1" "$APP_DIR/myApp.xcodeproj/project.pbxproj" 2>/dev/null || fail "project.pbxproj has no $1" +} + +expect_no_pbxproj() { + [ "$XCODE" = 1 ] || return 0 + ! grep -q "$1" "$APP_DIR/myApp.xcodeproj/project.pbxproj" 2>/dev/null || fail "project.pbxproj has $1" +} + +# nothing new at the OF root, in apps/ or apps/myApps/ (a project named after an option value) +expect_no_stray() { + local now + now="$(listing)" + if [ "$now" != "$BEFORE" ]; then + fail "stray files: $(diff <(echo "$BEFORE") <(echo "$now") | grep '^>' | tr '\n' ' ')" + # clean up so later cases start clean + for f in $(diff <(echo "$BEFORE") <(echo "$now") | grep '^>' | sed 's/^> //'); do + for d in "$OF" "$RUN_DIR" "$RUN_DIR/myApps"; do + if [ -e "$d/$f" ] && ! echo "$BEFORE" | grep -qx "$f"; then rm -rf "${d:?}/$f"; fi + done + done + fi +} + +echo "projectGenerator argument tests: $PG" +echo "openFrameworks: $OF platform: $PLATFORM" +"$PG" --version 2>/dev/null | grep -i projectGenerator + +# ---------------------------------------------------------------- the project path + +start "attached values: -o.. -p$PLATFORM path" +pg -o.. -p"$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_no_stray + +start "= values: --ofPath=.. --platforms=$PLATFORM path" +pg --ofPath=.. --platforms="$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_no_stray + +start "separate values: -o .. -p $PLATFORM path" +pg -o .. -p "$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_no_stray + +start "separate long values: --ofPath .. --platforms $PLATFORM path" +pg --ofPath .. --platforms "$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_no_stray + +start "separate values, absolute OF path" +pg -o "$OF" -p "$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_no_stray + +start "-o .. -p $PLATFORM -f Security path (was: project at the OF root)" +pg -o .. -p "$PLATFORM" -f Security "$APP" +expect_exit 0; expect_updated; expect_config PROJECT_FRAMEWORKS "Security"; expect_no_stray + +start "--frameworks Security --platforms $PLATFORM path (was: project named Security)" +pg -o.. --frameworks Security --platforms "$PLATFORM" "$APP" +expect_exit 0; expect_updated; expect_config PROJECT_FRAMEWORKS "Security"; expect_no_stray + +start "--platforms $PLATFORM --frameworks Security path (was: project named $PLATFORM)" +pg -o.. --platforms "$PLATFORM" --frameworks Security "$APP" +expect_exit 0; expect_updated; expect_config PROJECT_FRAMEWORKS "Security"; expect_no_stray + +start "every value option separated: -a -D -P -s" +mkdir -p "$TEST_DIR/shared" && printf 'int shared() { return 1; }\n' > "$TEST_DIR/shared/shared.cpp" +pg -o .. -p "$PLATFORM" -a ofxGui -D A=1 -P "echo done" -s myApps/pgArgTests/shared "$APP" +expect_exit 0; expect_updated; expect_no_stray +grep -q ofxGui "$APP_DIR/addons.make" 2>/dev/null || fail "addons.make has no ofxGui" + +start "project path only (host platform, OF path from -o)" +pg -o.. "$APP" +expect_exit 0; expect_no_stray + +start "missing project path" +pg -o.. -p"$PLATFORM" +expect_exit 64; expect_output "Missing project path"; expect_no_stray + +start "bare value option at the end: -p $PLATFORM (was: project named $PLATFORM)" +pg -o.. -p "$PLATFORM" +expect_exit 64; expect_output "Missing project path"; expect_no_stray + +start "two project paths" +pg -o.. -p"$PLATFORM" "$APP" myApps/pgArgTests/other +expect_exit 64; expect_output "More than one project path"; expect_not_updated; expect_no_stray + +start "option after the project path" +pg -o.. "$APP" -p"$PLATFORM" +expect_exit 64; expect_output "More than one project path"; expect_not_updated; expect_no_stray + +start "the OF folder as the project" +pg -o.. -p"$PLATFORM" .. +expect_exit 64; expect_output "openFrameworks folder"; expect_no_stray + +start "unknown option" +pg -o.. --bogus -p"$PLATFORM" "$APP" +expect_exit 64; expect_output "Unknown option"; expect_not_updated; expect_no_stray + +start "misspelled option: --platform $PLATFORM (was: printed the host platform, exit 0)" +pg -o.. --platform "$PLATFORM" "$APP" +expect_exit 64; expect_not_updated; expect_no_stray + +start "--getplatform / -i print the host platform" +pg --getplatform +expect_exit 0; expect_output "ofHostPlatform" + +start "OF path that doesn't exist: an error, or the OF folder found above the projectGenerator" +pg -o../nope -p"$PLATFORM" "$APP" +[ "$CODE" = 0 ] && expect_updated; expect_no_stray + +start "dry run writes nothing" +pg -o.. -p"$PLATFORM" -d "$APP" +expect_exit 0; expect_not_updated; expect_no_stray + +start "recursive update of a folder" +mkdir -p "$TEST_DIR/other/src" && cp "$APP_DIR/src/"* "$TEST_DIR/other/src/" +pg -o.. -p"$PLATFORM" -r myApps/pgArgTests +expect_exit 0; expect_updated; expect_no_stray +[ -e "$TEST_DIR/other/${PROJECT_FILE/myApp/other}" ] || fail "other/${PROJECT_FILE/myApp/other} not written" + +# ---------------------------------------------------------------- system frameworks / libraries + +start "frameworks: commas" +pg -o.. -p"$PLATFORM" -fSecurity,CoreBluetooth "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security CoreBluetooth" +expect_pbxproj "Security.framework"; expect_pbxproj "CoreBluetooth.framework" + +start "frameworks: comma and space" +pg -o.. -p"$PLATFORM" -f"Security, CoreBluetooth" "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security CoreBluetooth" + +start "frameworks: spaces only" +pg -o.. -p"$PLATFORM" -f"Security CoreBluetooth" "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security CoreBluetooth" +expect_no_pbxproj "Security CoreBluetooth" + +start "frameworks: .framework suffix and duplicates" +pg -o.. -p"$PLATFORM" -fSecurity.framework,Security,CoreBluetooth "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security CoreBluetooth" + +start "system libs: libX.tbd, -lX, libX, X" +pg -o.. -p"$PLATFORM" --system-libs=libsqlite3.tbd,-lz,libiconv,c++ "$APP" +expect_exit 0; expect_config PROJECT_SYSTEM_LIBS "sqlite3 z iconv c++" +expect_pbxproj "usr/lib/libsqlite3.tbd"; expect_pbxproj "usr/lib/libz.tbd" + +start "libraries given to -f go to PROJECT_SYSTEM_LIBS" +pg -o.. -p"$PLATFORM" -fSecurity,libsqlite3 "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security"; expect_config PROJECT_SYSTEM_LIBS "sqlite3" + +start "update without -f / --system-libs keeps them, empty removes them" +pg -o.. -p"$PLATFORM" -fSecurity --system-libs=sqlite3 "$APP" +pg -o.. -p"$PLATFORM" "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security"; expect_config PROJECT_SYSTEM_LIBS "sqlite3" +pg -o.. -p"$PLATFORM" --system-libs= "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security"; expect_no_config PROJECT_SYSTEM_LIBS +pg -o.. -p"$PLATFORM" -f "$APP" +expect_exit 0; expect_updated; expect_no_config PROJECT_FRAMEWORKS; expect_no_stray +expect_no_pbxproj "Security.framework" + +start "config.make PROJECT_FRAMEWORKS += lines are read" +printf 'PROJECT_FRAMEWORKS = Security\nPROJECT_FRAMEWORKS += CoreBluetooth\n' > "$APP_DIR/config.make" +pg -o.. -p"$PLATFORM" "$APP" +expect_exit 0; expect_config PROJECT_FRAMEWORKS "Security CoreBluetooth"; expect_pbxproj "CoreBluetooth.framework" + +# ---------------------------------------------------------------- defines / version / emscripten + +if [ "$HAS_CONFIG_TEMPLATE" = 1 ]; then + start "defines: -D A=1,B" + pg -o.. -p"$PLATFORM" -D A=1,B "$APP" + expect_exit 0; expect_config PROJECT_DEFINES "A=1 B" + + start "app version and build" + pg -o.. -p"$PLATFORM" --app-version 1.2.3 --app-build 42 "$APP" + expect_exit 0; expect_config APP_VERSION "1.2.3"; expect_config APP_BUILD "42" + + start "bad app version / build keep the project's" + pg -o.. -p"$PLATFORM" --app-version=1.2.3 --app-build=42 "$APP" + pg -o.. -p"$PLATFORM" --app-version=1.x --app-build=0 "$APP" + expect_exit 0; expect_output "should be digits and dots"; expect_output "should be a positive integer" + expect_config APP_VERSION "1.2.3"; expect_config APP_BUILD "42" + + start "emscripten wasm: 64, then a bad value keeps it" + pg -o.. -p"$PLATFORM" -W 64 "$APP" + expect_config PROJECT_EMSCRIPTEN_WASM "64" + pg -o.. -p"$PLATFORM" -W48 "$APP" + expect_exit 0; expect_output "unknown emscripten wasm"; expect_config PROJECT_EMSCRIPTEN_WASM "64" +fi + +rm -rf "$TEST_DIR" +expect_no_stray + +echo "$CASES cases, $FAILS failures" +[ "$FAILS" = 0 ] || exit 1 +echo "projectGenerator argument tests passed" diff --git a/scripts/vs/test_cmdline.sh b/scripts/vs/test_cmdline.sh index a5d55abdd..861555497 100755 --- a/scripts/vs/test_cmdline.sh +++ b/scripts/vs/test_cmdline.sh @@ -96,4 +96,7 @@ if ! grep -q "1" "../openFrameworks/apps/myApps/t exit 1 fi +echo "Test command line arguments" +"${CURRENT_DIR}/../test_cmdline_args.sh" ./"${EXE_FILE}" ../openFrameworks vs || exit 1 + echo "Successful projectGenerator tests for [vs]" From b3bc90d1eeca52eb9ca30b091fa64a3f0c0e082c Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Sat, 31 Oct 2026 20:37:25 +1100 Subject: [PATCH 2/3] Updated cmdLine from 0.120.0 to 0.121.0 and PG GUI from 0.114.0 to 0.115.0 --- commandLine/src/defines.h | 2 +- frontend/npm-shrinkwrap.json | 4 ++-- frontend/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 7988f49e6..fd7c7967b 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "120" +#define OFPROJECTGENERATOR_MINOR_VERSION "121" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.json index 7fca93899..6ccf35578 100644 --- a/frontend/npm-shrinkwrap.json +++ b/frontend/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "projectGenerator", - "version": "0.114.0", + "version": "0.115.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "projectGenerator", - "version": "0.114.0", + "version": "0.115.0", "license": "MIT", "dependencies": { "@types/jquery": "^3.5.34", diff --git a/frontend/package.json b/frontend/package.json index a8380a672..b93707037 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "projectGenerator", "productName": "projectGenerator", - "version": "0.114.0", + "version": "0.115.0", "description": "Build electron GUI openFrameworks projectGenerator", "license": "MIT", "main": "index.js", From b0e00fda36165ba5d683fbf2cc0ece882f1c8203 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Sat, 31 Oct 2026 20:50:46 +1100 Subject: [PATCH 3/3] Unknown platforms are an error instead of a crash, Windows host platform is vs again; tests only report stray files --- commandLine/src/main.cpp | 8 ++++++++ commandLine/src/utils/Utils.cpp | 2 +- scripts/test_cmdline_args.sh | 25 ++++++++++++++++--------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index b11b23e9b..aca8fc391 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -619,6 +619,14 @@ int pgMain(int argc, char ** argv) { } } + // getTargetProject has no project for these, which crashed (-p bogus, or no host platform) + for (auto & t : targets) { + if (!getTargetProject(t)) { + messageError("Unknown platform: \"" + t + "\" - see --help"); + return EXIT_USAGE; + } + } + if (options[MSYS2ENV].count() > 0 && options[MSYS2ENV].arg != NULL) { std::string env = ofToLower(ofTrim(options[MSYS2ENV].arg)); if (env == "ucrt64" || env == "mingw64" || env == "clang64" || env == "clangarm64") { diff --git a/commandLine/src/utils/Utils.cpp b/commandLine/src/utils/Utils.cpp index 4d6ba712c..1d3f9c6ee 100644 --- a/commandLine/src/utils/Utils.cpp +++ b/commandLine/src/utils/Utils.cpp @@ -82,7 +82,7 @@ std::string getPlatformString() { else { return "linux64"; } -#elif defined(__WIN32__) +#elif defined(_WIN32) || defined(__WIN32__) #if defined(__MINGW32__) || defined(__MINGW64__) return "msys2"; #else diff --git a/scripts/test_cmdline_args.sh b/scripts/test_cmdline_args.sh index d7c8752ca..2b699ec6d 100755 --- a/scripts/test_cmdline_args.sh +++ b/scripts/test_cmdline_args.sh @@ -46,8 +46,14 @@ CASE="" OUT="" CODE=0 +# apps/myApps may not exist in a fresh checkout; made before the snapshot, removed at the end +CREATED_MYAPPS=0 +[ -d "$RUN_DIR/myApps" ] || { mkdir -p "$RUN_DIR/myApps"; CREATED_MYAPPS=1; } + listing() { - ls -a "$OF" "$RUN_DIR" "$RUN_DIR/myApps" 2>/dev/null | grep -v '^pgArgTests$' + for d in "$OF" "$RUN_DIR" "$RUN_DIR/myApps"; do + ls -A "$d" 2>/dev/null | grep -vx pgArgTests | sed "s|^|$d/|" + done } BEFORE="$(listing)" @@ -119,18 +125,14 @@ expect_no_pbxproj() { ! grep -q "$1" "$APP_DIR/myApp.xcodeproj/project.pbxproj" 2>/dev/null || fail "project.pbxproj has $1" } -# nothing new at the OF root, in apps/ or apps/myApps/ (a project named after an option value) +# nothing new at the OF root, in apps/ or apps/myApps/ (a project named after an option value); +# only reported (each once), never deleted expect_no_stray() { local now now="$(listing)" if [ "$now" != "$BEFORE" ]; then - fail "stray files: $(diff <(echo "$BEFORE") <(echo "$now") | grep '^>' | tr '\n' ' ')" - # clean up so later cases start clean - for f in $(diff <(echo "$BEFORE") <(echo "$now") | grep '^>' | sed 's/^> //'); do - for d in "$OF" "$RUN_DIR" "$RUN_DIR/myApps"; do - if [ -e "$d/$f" ] && ! echo "$BEFORE" | grep -qx "$f"; then rm -rf "${d:?}/$f"; fi - done - done + fail "stray files: $(diff <(echo "$BEFORE") <(echo "$now") | grep '^>' | sed 's/^> //' | tr '\n' ' ')" + BEFORE="$now" fi } @@ -202,6 +204,10 @@ start "the OF folder as the project" pg -o.. -p"$PLATFORM" .. expect_exit 64; expect_output "openFrameworks folder"; expect_no_stray +start "unknown platform (was: crash)" +pg -o.. -pbogus "$APP" +expect_exit 64; expect_output "Unknown platform"; expect_not_updated; expect_no_stray + start "unknown option" pg -o.. --bogus -p"$PLATFORM" "$APP" expect_exit 64; expect_output "Unknown option"; expect_not_updated; expect_no_stray @@ -298,6 +304,7 @@ fi rm -rf "$TEST_DIR" expect_no_stray +[ "$CREATED_MYAPPS" = 1 ] && rmdir "$RUN_DIR/myApps" 2>/dev/null echo "$CASES cases, $FAILS failures" [ "$FAILS" = 0 ] || exit 1