Cotton code
88 lines · 3.3 KB · ShellRaw
#!/usr/bin/env bash# The apps' own UI tests (XCUITest on a simulator, never in the checks): their# targets live in a project generated here for the run, `UITests.xcodeproj`# beside the shipped one, as the deck walk's do, so the# shipped spec keeps its one scheme and its test targets# (the ios-project-spec test). The shipped spec is included# whole, gated as gen-ios-project.sh gates it.##   bash scripts/gen-ios-ui-tests.sh## Schemes, each Debug, each its app and its tests:#   story-ui  CottonStory    + StoryUITests (UITests/Story)#   chat-ui   CottonMessages + ChatUITests  (UITests/Chat)#   days-ui   CottonDays     + DaysUITests  (UITests/Days)#   notes-ui  CottonNotes    + NotesUITests (UITests/Notes)#   sites-ui  CottonSites    + SitesUITests (UITests/Sites)#   cinemas-ui CottonCinemas + CinemasUITests (UITests/Cinemas)#   data-ui   CottonData     + DataUITests  (UITests/Data)#   albums-ui CottonAlbums   + AlbumsUITests (UITests/Albums)#   mail-ui   CottonMail     + PostUITests  (UITests/Post)#   contacts-ui CottonContacts + ContactsUITests (UITests/Contacts)# then, for example:#   xcodebuild test -project apps/cotton/UITests.xcodeproj -scheme story-ui \#     -destination 'platform=iOS Simulator,id=<udid>' -only-testing:StoryUITests COTTON_FLAVOR=devset -euo pipefailROOT="$(cd "$(dirname "$0")/.." && pwd)"IOS="$ROOT/apps/cotton"command -v xcodegen >/dev/null 2>&1 || { echo "gen-ios-ui-tests: xcodegen is not on PATH (brew install xcodegen)" >&2; exit 1; }bash "$ROOT/scripts/ffi-stub.sh"cd "$IOS"SHIPPED=project.ymlrm -f .uitests.gated.ymlif npx tsx "$ROOT/scripts/ios-spec-gate.ts" project.yml .uitests.gated.yml; then SHIPPED=.uitests.gated.yml; fi# name|app target|folderSUITES="StoryUITests|CottonStory|UITests/Story story-uiChatUITests|CottonMessages|UITests/Chat chat-uiDaysUITests|CottonDays|UITests/Days days-uiNotesUITests|CottonNotes|UITests/Notes notes-uiSitesUITests|CottonSites|UITests/Sites sites-uiCinemasUITests|CottonCinemas|UITests/Cinemas cinemas-uiDataUITests|CottonData|UITests/Data data-uiAlbumsUITests|CottonAlbums|UITests/Albums albums-uiPostUITests|CottonMail|UITests/Post mail-uiContactsUITests|CottonContacts|UITests/Contacts contacts-ui"{  echo "include:"  echo "  - path: $SHIPPED"  echo "name: UITests"  echo "targets:"  while read -r suite scheme; do    IFS='|' read -r name app folder <<<"$suite"    cat <<YML  $name:    type: bundle.ui-testing    platform: iOS    sources:      - path: $folder      - path: UITests/Shared    dependencies:      - target: $app    settings:      base:        TEST_TARGET_NAME: $app        GENERATE_INFOPLIST_FILE: YESYML  done <<<"$SUITES"  echo "schemes:"  while read -r suite scheme; do    IFS='|' read -r name app folder <<<"$suite"    cat <<YML  $scheme:    build:      targets:        $app: all        $name: [test]    test:      config: Debug      targets:        - $nameYML  done <<<"$SUITES"} > .uitests.ymlxcodegen generate --spec .uitests.yml --project . --quietmkdir -p UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpmcp Package.resolved UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedecho "gen-ios-ui-tests: apps/cotton/UITests.xcodeproj (schemes story-ui, chat-ui, days-ui, notes-ui, sites-ui, cinemas-ui, data-ui, albums-ui, mail-ui, contacts-ui)"