runtest
プロジェクトの airbuild.yaml にある名前付きテストスクリプトを 1 つ実行し、その出力を持ち帰ります。
runtest は、プロジェクトの airbuild.yaml の test: にある名前付きエントリを実行し、そのエントリが出力として挙げているファイルを集めます。チームの環境の中で動作します。
| チーム | テストが実行される場所 |
|---|---|
| クラウドチーム | ios: 選択したソースが新しい macOS ビルダーにアップロードされます。android_beta: Linux ビルダー。pocketjs_beta: チーム自身のホスト。 |
| Mac チーム | チーム自身の Mac 上。--environment と --list-environments はクラウドチーム専用です。 |
runtest は何にも署名せず、アプリのプレビューを要求することもありません。
書式
runtest <project-id> [--platform <platform>] [--source <directory>] [--script <name>] [--additional-options '<flags>'] [--environment ID] [--no-cache]
runtest <project-id> --follow [--run ID] # reattach; starts nothing
runtest --cancel [--run ID]
runtest --list-environments
runtest --helpオプション
| オプション | 値 | デフォルト | 動作 |
|---|---|---|---|
<project-id> |
UUID | 必須 | テストするプロジェクト。 |
--script |
テスト名 | エントリが 1 つだけならそれ | test: のどのエントリを実行するか。複数ある場合は必須です。 |
--additional-options |
1 行のフラグ | 空 | 環境変数 additional_options として、そのままスクリプトに渡されます。空白区切りのフラグを使ってください。シェルの式や入れ子の引用符は使えません。 |
--platform |
ios、pocketjs_beta、android_beta |
デフォルトのマニフェスト | デフォルトの airbuild.yaml の代わりに .airbuild/airbuild.<platform>.yaml を読み取ります。 |
--source |
ディレクトリ | プロジェクトのディレクトリ | そのディレクトリ(git worktree など)をテストします。そのディレクトリに airbuild.yaml があればそれを、なければプロジェクトのものを使います。現在のディレクトリからの相対パスです。 |
--environment |
--list-environments で得られる ID |
デフォルト | クラウドチーム: 別のビルダー環境(macOS と Xcode のバージョン)で実行します。 |
--no-cache |
— | キャッシュあり | ビルダーのキャッシュ(airbuild-cache、DerivedData、android_beta では Gradle のビルドキャッシュ)を使わずに実行し、何も保存しません。 |
--follow |
— | — | 実行中の run に再接続します。終了済みの run ではその旨を伝え、保存済みの出力を再生します。run を開始することはありません。 |
--run |
実行 ID | 実行中のもの、なければ最新のもの | --follow または --cancel と併用。複数の run が進行中の場合に必要です。 |
--cancel |
— | — | run に停止を要求し、確認を最大 30 秒待ちます。 |
--list-environments |
— | — | クラウドチーム: ビルダー環境を一覧表示します。 |
runtest は --sign、--unsigned、--command、--output を受け付けません。マニフェストなしでインラインのスクリプトを実行するには、runmacos または runlinux を使ってください。
runtest が airbuild.yaml から読み取るもの
runtest には version: 3 または 4 が必要です。build: セクションは不要です。マニフェストは runbuild と同じ方法で探します。
version: 3
test:
app:
script: |
airbuild-xcode test -project App.xcodeproj -scheme App \
-resultBundlePath .airbuild/artifacts/Tests.xcresult $additional_options
outputs:
- .airbuild/artifacts/Tests.xcresult
unit:
script: swift test| キー | 内容 |
|---|---|
test.<name> |
テストエントリ 1 つ。名前に使えるのは ASCII の英字、数字、ドット、アンダースコア、ハイフンだけです。各エントリが受け付けるのは script と outputs だけです。 |
test.<name>.script |
Bash スクリプト。ソースのルートから -e -o pipefail で実行されます。 |
test.<name>.outputs |
省略可能。スクリプトが書き出すファイルまたはディレクトリ(ソースのルートからの相対パス)。 |
出力のパスは具体的な相対パスでなければなりません。絶対パス、..、ワイルドカード、シンボリックリンク、特殊ファイルは使えず、ほかのパスの内側にあるパスも使えません。出力は相対パスを保ったまま 1 つのディレクトリに集められます。
スクリプトの PATH には airbuild-cache もあり、node_modules などのファイルを実行間で保持できます。Mac では最初の airbuild-xcode install または test がプロジェクトの DerivedData を復元します。android_beta では、runtest 自身が Gradle のビルドキャッシュを復元・保存します。
出力
• Build started in the Environment. Run: <run-id>
• It runs to completion even if this command is interrupted (reattach with: runtest <project-id> --follow --run <run-id>).
Airbuild remote execution
… the test script's output …
✓ Command succeeded in <time>.
✓ Test finished.
Build: <build-id>
Artifact: <path to the collected outputs>失敗した run でも存在する出力は持ち帰られ、runtest はスクリプトの終了コードで終了します。
✗ Test failed.
Reason: <why>
Artifact: <path to the collected outputs>出力がない場合は No outputs requested; skipping artifact download. と表示されます。
複数を実行する
runtest には runbuild、runmacos、runlinux とは別の専用スロットがあります。クラウドチームでは複数の runtest をそれぞれ新しいビルダーで同時に実行でき、Mac チームでは一度に 1 つずつ実行します。開始すると実行 ID が表示されます。複数が実行中のときは、--follow と --cancel に --run ID が必要です。Ctrl-C は切り離すだけです。
終了コード
| コード | 意味 |
|---|---|
0 |
スクリプトが成功し、宣言されたすべての出力が書き出されました。 |
1 |
run を開始できなかったか、見失われました。 |
2 |
オプションまたは引数が誤っており、何も実行されていません。 |
65 |
スクリプトは成功しましたが、宣言された出力がないか、書き出せません。 |
130 |
キャンセルされたか、Ctrl-C で切り離しました。 |
| その他 | テストスクリプト自身の終了コード。 |
エラー
| メッセージ | 対処 |
|---|---|
runtest requires airbuild.yaml with version: 3 or 4 and named test scripts. |
test: セクションのあるマニフェストを追加してください。 |
runtest requires airbuild.yaml version: 3 or 4. |
マニフェストで version: 3 または version: 4 を指定してください。 |
test must contain named scripts; names use only ASCII letters, digits, dots, underscores and hyphens. |
test: セクションを修正してください。 |
Select a test with --script. Available scripts: … |
一覧にある名前のいずれかを --script で指定してください。 |
--additional-options must be a single line. |
改行を取り除いてください。 |
Outputs must be concrete relative paths inside the project, without parent traversal or glob patterns. |
outputs を修正してください。 |
Output paths must not repeat or contain another declared output. |
重複を取り除いてください。 |
Declared output was not produced: <path> |
スクリプトがそれを書き出すようにするか、outputs から削除してください。 |
Cannot export a symbolic link: <path> / Output contains a symbolic link or special file: <path> |
通常のファイルとディレクトリだけを書き出してください。 |
runtest does not accept build or signing options. |
--sign / --unsigned を外してください。 |
A runtest execution is already running in this Team's Environment. |
それを follow するか、キャンセルしてください。 |
N runtest executions are running; choose one with --run. |
一覧にある実行 ID のいずれかを渡してください。 |
例
# The only test entry
runtest 3f6c1a2e-8b4d-4f0a-9c1e-2d7b5a6e9f10# One XCTest class from the "app" entry
runtest 3f6c1a2e-8b4d-4f0a-9c1e-2d7b5a6e9f10 --script app \
--additional-options '-only-testing:AppTests/ExampleTests'# Android tests
runtest 3f6c1a2e-8b4d-4f0a-9c1e-2d7b5a6e9f10 --platform android_beta