@aarwitz/tapp 0.35.6 → 0.35.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +2 -2
- package/AGENTS.md +13 -1
- package/Harness/OCQAHarnessUITests/ExplorerTests.swift +242 -32
- package/bin/tapp.js +96 -1
- package/browser/app.css +90 -1
- package/browser/app.js +295 -14
- package/browser/index.html +36 -1
- package/browser/product-contract.js +11 -0
- package/browser/view-model.js +185 -0
- package/docs/BROWSER-PRODUCT.md +54 -8
- package/mcp-server/src/account-store.js +46 -2
- package/mcp-server/src/android-flow.js +5 -0
- package/mcp-server/src/browser-product.js +136 -3
- package/mcp-server/src/flow-recording.js +27 -3
- package/mcp-server/src/flow-runtime.js +20 -2
- package/mcp-server/src/index.js +5 -4
- package/mcp-server/src/journeys.js +29 -1
- package/mcp-server/src/macos-flow.js +2 -0
- package/mcp-server/src/sim-recorder.js +273 -0
- package/mcp-server/src/studio-client.js +47 -1
- package/mcp-server/src/web-audit.js +2 -2
- package/mcp-server/src/web-explorer.js +51 -3
- package/mcp-server/src/web-flow.js +120 -5
- package/package.json +2 -2
- package/scripts/ci-gate.sh +1 -1
- package/scripts/flow_lib.py +4 -1
- package/scripts/quick-capture.sh +44 -24
|
@@ -203,7 +203,7 @@ export function distillPlaywrightFailure(message) {
|
|
|
203
203
|
return `${firstLine} — ${reason}`;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout = DEFAULT_TIMEOUT }) {
|
|
206
|
+
export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout = DEFAULT_TIMEOUT, stepScreenshotDir = "" }) {
|
|
207
207
|
const raw = normalizeFlowStep(step);
|
|
208
208
|
const action = raw.action;
|
|
209
209
|
const target = substituteFlowValue(raw.target, vars);
|
|
@@ -236,11 +236,123 @@ export async function executeWebFlowStep({ page, step, vars = {}, defaultTimeout
|
|
|
236
236
|
await submit.locator.click();
|
|
237
237
|
await page.waitForTimeout(400);
|
|
238
238
|
if (await password.isVisible().catch(() => false)) throw new Error("submit left the app on the login screen");
|
|
239
|
+
} else if (action === "press") {
|
|
240
|
+
// TM-593: a journey could not press a key, so anything a keyboard drives — a slider, a
|
|
241
|
+
// shortcut, a combobox — was unreachable. `press: ArrowRight` or
|
|
242
|
+
// `press: { key: ArrowRight, on: <target>, times: 5 }`.
|
|
243
|
+
const key = String(raw.params.key ?? value ?? target ?? "").trim();
|
|
244
|
+
if (!key) throw new Error("press needs a key, e.g. `press: ArrowRight`");
|
|
245
|
+
// `on:` is unusable as a key here: YAML 1.1 reads a bare `on` as the boolean true, so
|
|
246
|
+
// `on: price-max` arrives as {"true": "price-max"} and the target silently vanishes. Say so
|
|
247
|
+
// rather than pressing into the void and passing, which is what this step did first.
|
|
248
|
+
if (raw.params.true !== undefined) {
|
|
249
|
+
throw new Error("press takes `target:`, not `on:` — YAML reads a bare `on` as true, so the target is lost");
|
|
250
|
+
}
|
|
251
|
+
// Only the object form can name a control to focus. In the string form — `press: ArrowRight`,
|
|
252
|
+
// which is the form the story and the reporter both asked for — normalizeFlowStep puts the
|
|
253
|
+
// key in `target` as well, so reading a focus target from there looked for a control called
|
|
254
|
+
// "ArrowRight" and the step failed (Linux's check of 6d8d531). A bare key presses wherever
|
|
255
|
+
// the focus already is, which is what a shortcut means.
|
|
256
|
+
const onTarget = "key" in raw.params
|
|
257
|
+
? substituteFlowValue(String(raw.target || raw.params.onTarget || ""), vars)
|
|
258
|
+
: "";
|
|
259
|
+
const times = Math.max(1, Math.min(50, Number(raw.params.times) || 1));
|
|
260
|
+
const el = onTarget ? await locateWebElement(page, onTarget) : null;
|
|
261
|
+
if (onTarget && !el) throw new Error(`could not find ‘${onTarget}’ to press ${key} on`);
|
|
262
|
+
if (el) await el.focus();
|
|
263
|
+
for (let i = 0; i < times; i += 1) {
|
|
264
|
+
if (el) await el.press(key);
|
|
265
|
+
else await page.keyboard.press(key);
|
|
266
|
+
}
|
|
267
|
+
} else if (action === "drag") {
|
|
268
|
+
// TM-593: `type` on a range input calls fill(), which sets the value without the handle
|
|
269
|
+
// ever moving, so nothing the page listens for fires and the step proves nothing. A drag
|
|
270
|
+
// moves it the way a person does. `drag: { from: <target>, by: [dx, dy] }` or `{ from, to }`.
|
|
271
|
+
const from = substituteFlowValue(String(raw.params.from ?? target ?? ""), vars);
|
|
272
|
+
if (!from) throw new Error("drag needs `from`, e.g. `drag: { from: price-min, by: [60, 0] }`");
|
|
273
|
+
const handle = await locateWebElement(page, from);
|
|
274
|
+
if (!handle) throw new Error(`could not find ‘${from}’ to drag`);
|
|
275
|
+
// Playwright's own click() scrolls a control into view first; raw mouse moves do not, so a
|
|
276
|
+
// handle below the fold would be "dragged" at coordinates pointing somewhere else entirely —
|
|
277
|
+
// passing, and moving nothing.
|
|
278
|
+
await handle.scrollIntoViewIfNeeded().catch(() => {});
|
|
279
|
+
const start = await handle.boundingBox();
|
|
280
|
+
if (!start) throw new Error(`‘${from}’ is not on screen, so it cannot be dragged`);
|
|
281
|
+
const startX = start.x + start.width / 2;
|
|
282
|
+
const startY = start.y + start.height / 2;
|
|
283
|
+
let endX;
|
|
284
|
+
let endY;
|
|
285
|
+
const to = substituteFlowValue(String(raw.params.to ?? ""), vars);
|
|
286
|
+
if (to) {
|
|
287
|
+
const dest = await locateWebElement(page, to);
|
|
288
|
+
if (dest) await dest.scrollIntoViewIfNeeded().catch(() => {});
|
|
289
|
+
const box = dest && await dest.boundingBox();
|
|
290
|
+
if (!box) throw new Error(`could not find ‘${to}’ to drag onto`);
|
|
291
|
+
endX = box.x + box.width / 2;
|
|
292
|
+
endY = box.y + box.height / 2;
|
|
293
|
+
} else {
|
|
294
|
+
const by = Array.isArray(raw.params.by) ? raw.params.by : [Number(raw.params.by) || 0, 0];
|
|
295
|
+
endX = startX + (Number(by[0]) || 0);
|
|
296
|
+
endY = startY + (Number(by[1]) || 0);
|
|
297
|
+
}
|
|
298
|
+
await page.mouse.move(startX, startY);
|
|
299
|
+
await page.mouse.down();
|
|
300
|
+
// In steps, because a single jump is not a drag to a listener watching movement.
|
|
301
|
+
const steps = 12;
|
|
302
|
+
for (let i = 1; i <= steps; i += 1) {
|
|
303
|
+
await page.mouse.move(startX + ((endX - startX) * i) / steps, startY + ((endY - startY) * i) / steps);
|
|
304
|
+
}
|
|
305
|
+
await page.mouse.up();
|
|
239
306
|
} else if (action === "swipe") {
|
|
307
|
+
// TM-593: this only ever scrolled the window, so content inside a drawer or modal could not
|
|
308
|
+
// be brought into view and the step passed having moved nothing. With a target it scrolls
|
|
309
|
+
// that container, and either way it fails when nothing actually moved.
|
|
240
310
|
const dy = target.toLowerCase() === "down" ? -600 : 600;
|
|
241
|
-
|
|
311
|
+
const within = substituteFlowValue(String(raw.params.within ?? raw.params.in ?? ""), vars);
|
|
312
|
+
if (within) {
|
|
313
|
+
const box = await locateWebElement(page, within);
|
|
314
|
+
if (!box) throw new Error(`could not find ‘${within}’ to scroll`);
|
|
315
|
+
const moved = await box.evaluate((node, y) => {
|
|
316
|
+
const before = node.scrollTop;
|
|
317
|
+
node.scrollBy({ top: y, behavior: "instant" });
|
|
318
|
+
return { before, after: node.scrollTop, canScroll: node.scrollHeight > node.clientHeight };
|
|
319
|
+
}, dy);
|
|
320
|
+
if (!moved.canScroll) throw new Error(`‘${within}’ has nothing to scroll`);
|
|
321
|
+
if (moved.before === moved.after) {
|
|
322
|
+
throw new Error(`‘${within}’ did not move: it is already at the ${dy > 0 ? "bottom" : "top"}`);
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
const moved = await page.evaluate((y) => {
|
|
326
|
+
const before = window.scrollY;
|
|
327
|
+
window.scrollBy({ top: y, behavior: "instant" });
|
|
328
|
+
return { before, after: window.scrollY };
|
|
329
|
+
}, dy);
|
|
330
|
+
if (moved.before === moved.after) {
|
|
331
|
+
throw new Error(`the page did not scroll: it is already at the ${dy > 0 ? "bottom" : "top"}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} else if (action === "screenshot") {
|
|
335
|
+
// TM-593: evidence was one full-page shot at the end, in which a fixed overlay cannot be
|
|
336
|
+
// located at all — the reporter could not find an open drawer in a 1170x18972 capture. A
|
|
337
|
+
// named shot at the moment that matters, viewport-sized, so it shows what a person sees.
|
|
338
|
+
const name = String(raw.params.name ?? target ?? value ?? "").trim() || "step";
|
|
339
|
+
const safe = name.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(0, 60);
|
|
340
|
+
if (stepScreenshotDir) {
|
|
341
|
+
fs.mkdirSync(stepScreenshotDir, { recursive: true });
|
|
342
|
+
await page.screenshot({ path: path.join(stepScreenshotDir, `flow-${safe}.png`) });
|
|
343
|
+
detail = `saved flow-${safe}.png`;
|
|
344
|
+
} else {
|
|
345
|
+
// The step's promise is a picture. Passing green with nothing written is the same empty
|
|
346
|
+
// success this story exists to remove, so say which it was (Linux's check of 6d8d531).
|
|
347
|
+
status = "skip";
|
|
348
|
+
detail = "not saved: this run has no evidence folder";
|
|
349
|
+
}
|
|
242
350
|
} else if (action === "back") {
|
|
243
351
|
await page.goBack({ waitUntil: "domcontentloaded" });
|
|
352
|
+
} else if (action === "open_url") {
|
|
353
|
+
// A journey starting from an email link ("tap the sign-in link in your receipt") is just a
|
|
354
|
+
// navigation on web — the one-time part of the link substitutes like any other target.
|
|
355
|
+
await page.goto(target, { waitUntil: "domcontentloaded" });
|
|
244
356
|
} else if (action === "wait_for") {
|
|
245
357
|
if (!await waitForScreen(page, target, timeout)) throw new Error(`‘${target}’ never appeared within ${timeout}ms${await visibleLabelsHint(page)}`);
|
|
246
358
|
} else if (action === "wait") {
|
|
@@ -316,8 +428,8 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
|
|
|
316
428
|
const loggedFlow = { ...flow, steps: [...setup, ...flow.steps, ...teardown] };
|
|
317
429
|
const log = new FlowLog({ logPath, flow: loggedFlow });
|
|
318
430
|
const pw = playwright || await loadPlaywright();
|
|
319
|
-
const { webBrowserLaunchOptions } = await import("./web-explorer.js");
|
|
320
|
-
const browser = await pw.chromium
|
|
431
|
+
const { webBrowserLaunchOptions, launchWebBrowser } = await import("./web-explorer.js");
|
|
432
|
+
const browser = await launchWebBrowser(pw.chromium, webBrowserLaunchOptions());
|
|
321
433
|
const contextOptions = webContextOptions({ device, viewport, devices: pw.devices });
|
|
322
434
|
// Without an explicit size Playwright fits the recording into 800px, so a replay filmed at a
|
|
323
435
|
// desktop viewport came out small and soft however large the window was. Film at the size the
|
|
@@ -362,7 +474,7 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
|
|
|
362
474
|
emit({action:"origin",target:"connected app",status:"fail",detail:"The workflow left the connected app origin. Authorize a supported sign-in route before continuing."});
|
|
363
475
|
break;
|
|
364
476
|
}
|
|
365
|
-
const outcome = await executeWebFlowStep({ page, step, vars, defaultTimeout: timeout });
|
|
477
|
+
const outcome = await executeWebFlowStep({ page, step, vars, defaultTimeout: timeout, stepScreenshotDir: screenshotDir });
|
|
366
478
|
emit(outcome);
|
|
367
479
|
if (outcome.status === "fail" && screenshotDir) {
|
|
368
480
|
fs.mkdirSync(screenshotDir, { recursive: true });
|
|
@@ -374,6 +486,9 @@ export async function runWebFlow({ flow, url, logPath, screenshotDir, recordVide
|
|
|
374
486
|
if (screenshotDir) {
|
|
375
487
|
fs.mkdirSync(screenshotDir, { recursive: true });
|
|
376
488
|
await page.screenshot({ path: path.join(screenshotDir, "flow-final.png"), fullPage: true }).catch(() => {});
|
|
489
|
+
// Beside it, what the person actually sees: a fixed header, an open drawer or a toast is
|
|
490
|
+
// placeable here and invisible in a full-page capture (TM-593).
|
|
491
|
+
await page.screenshot({ path: path.join(screenshotDir, "flow-final-screen.png") }).catch(() => {});
|
|
377
492
|
}
|
|
378
493
|
} finally {
|
|
379
494
|
await requestPhase(teardown);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aarwitz/tapp",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.8",
|
|
4
4
|
"mcpName": "io.github.aarwitz/tapp",
|
|
5
5
|
"description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"mobile"
|
|
99
99
|
],
|
|
100
100
|
"scripts": {
|
|
101
|
-
"test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/flow-variables.test.js tests/flow-recording.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/platforms.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
|
|
101
|
+
"test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/focused-navigation.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/flow-variables.test.js tests/flow-recording.test.js tests/sim-recorder.test.js tests/feedback.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-link-audit.test.js tests/web-overlay.test.js tests/web-audit.test.js tests/page-observations.test.js tests/capture-provenance.test.js tests/capture-frames.test.js tests/actor-store.test.js tests/account-store.test.js tests/alerts.test.js tests/access-jwt.test.js tests/oauth.test.js tests/studio-client.test.js tests/journeys.test.js tests/ios-crash-attribution.test.js tests/ios-simulator-selection.test.js tests/ios-recording-stop.test.js tests/web-flow.test.js tests/sign-in.test.js tests/signin-honesty.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/evidence-retention.test.js tests/android-flow.test.js tests/macos-driver.test.js tests/macos-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/job-lanes.test.js tests/browser-product.test.js tests/browser-chat-narration.test.js tests/browser-run-reading.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/platforms.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
|
|
102
102
|
"test:browser-journey": "node --test tests/browser-journey.test.js",
|
|
103
103
|
"test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
|
|
104
104
|
}
|
package/scripts/ci-gate.sh
CHANGED
|
@@ -374,7 +374,7 @@ xcrun simctl install "$UDID" "$APP_PATH" || { echo "❌ simctl install failed
|
|
|
374
374
|
# ── Autonomous exploration (quick-capture builds the harness itself if needed).
|
|
375
375
|
# --actions 0 = flows-only: the reviewed suites are the whole deterministic surface. No
|
|
376
376
|
# explorer touches the app — the point, for targets wired to production backends (#11).
|
|
377
|
-
CAPTURE_ROOT="${TAPP_HOME:-$
|
|
377
|
+
CAPTURE_ROOT="${TAPP_HOME:-$HOME/.tapp}/captures" # never the repository (TM-651)
|
|
378
378
|
mkdir -p "$CAPTURE_ROOT"
|
|
379
379
|
CAPTURE_DIR="$(mktemp -d "$CAPTURE_ROOT/ci.XXXXXX")"
|
|
380
380
|
MARKERS=""
|
package/scripts/flow_lib.py
CHANGED
|
@@ -63,7 +63,10 @@ def to_json(path):
|
|
|
63
63
|
}
|
|
64
64
|
# Multi-actor Scenarios deliberately reuse the Flow step language and marker
|
|
65
65
|
# protocol, while preserving actor/session and lifecycle orchestration.
|
|
66
|
-
|
|
66
|
+
# `alerts: allow|dismiss` says what to do with a one-time system alert (TM-497). It is a
|
|
67
|
+
# flow-level setting rather than a step because the alerts it covers appear on some runs and
|
|
68
|
+
# not others, so there is no step to attach it to.
|
|
69
|
+
for key in ("actors", "setup", "teardown", "timeoutMs", "taskPlan", "releaseContract", "alerts"):
|
|
67
70
|
if key in flow:
|
|
68
71
|
out[key] = flow[key]
|
|
69
72
|
print(json.dumps(out))
|
package/scripts/quick-capture.sh
CHANGED
|
@@ -18,16 +18,16 @@ PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
18
18
|
# TAPP_CAPTURE_DIR selects one exact run directory (used by CI so a failed run can never
|
|
19
19
|
# accidentally reuse stale markers). TAPP_HOME redirects all writable output otherwise —
|
|
20
20
|
# set by the `tapp` CLI when running as an installed npm package, where the package dir
|
|
21
|
-
# must stay read-only. Unset (
|
|
22
|
-
|
|
21
|
+
# must stay read-only. Unset (a run from a source checkout), evidence still goes to
|
|
22
|
+
# ~/.tapp/captures like everywhere else in Tapp (TM-651): never into the repository,
|
|
23
|
+
# where the evidence clearing-out (evidence-retention.js) never looks.
|
|
24
|
+
TAPP_RUNTIME_HOME="${TAPP_HOME:-$HOME/.tapp}"
|
|
23
25
|
if [[ -n "${TAPP_CAPTURE_DIR:-}" ]]; then
|
|
24
26
|
CAPTURE_DIR="$TAPP_CAPTURE_DIR"
|
|
25
|
-
elif [[ -n "$TAPP_RUNTIME_HOME" ]]; then
|
|
26
|
-
CAPTURE_DIR="$TAPP_RUNTIME_HOME/captures/ios-$(date +%Y%m%d-%H%M%S)"
|
|
27
27
|
else
|
|
28
|
-
CAPTURE_DIR="$
|
|
28
|
+
CAPTURE_DIR="$TAPP_RUNTIME_HOME/captures/ios-$(date +%Y%m%d-%H%M%S)"
|
|
29
29
|
fi
|
|
30
|
-
if [[ -n "$
|
|
30
|
+
if [[ -n "${TAPP_HOME:-}" ]]; then
|
|
31
31
|
HARNESS_DERIVED="$TAPP_RUNTIME_HOME/harness-derived"
|
|
32
32
|
else
|
|
33
33
|
HARNESS_DERIVED="/tmp/tapp-harness-derived"
|
|
@@ -104,24 +104,44 @@ ensure_harness_built() {
|
|
|
104
104
|
fi
|
|
105
105
|
echo "Preparing harness for $sim_name (source, simulator, or Xcode cache changed)..." >&2
|
|
106
106
|
local src_fp=$(harness_fingerprint)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
#
|
|
110
|
-
#
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
# TM-973: a build-for-testing into ~/.tapp/harness-derived has failed with
|
|
108
|
+
# errors that only show up under disk/memory pressure ("disk I/O error" on
|
|
109
|
+
# XCBuildData/build.db) — an identical build into a FRESH derived-data
|
|
110
|
+
# folder succeeds. One retry from a clean folder recovers from that, and
|
|
111
|
+
# the full log (not just xcodebuild's own tail) names what actually failed
|
|
112
|
+
# when both attempts fail, instead of a bare "(5 failures)".
|
|
113
|
+
local log_dir; log_dir="$(dirname "$HARNESS_DERIVED")"
|
|
114
|
+
mkdir -p "$log_dir"
|
|
115
|
+
local build_log build_rc attempt products
|
|
116
|
+
for attempt in 1 2; do
|
|
117
|
+
mkdir -p "$HARNESS_DERIVED/Build/Products"
|
|
118
|
+
rm -f "$marker"
|
|
119
|
+
# Xcode leaves old SDK descriptors beside the new one. Only the descriptor emitted by
|
|
120
|
+
# this successful build may become current; never select an arbitrary directory entry.
|
|
121
|
+
find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f -delete
|
|
122
|
+
build_log="$log_dir/harness-build-attempt-$attempt.log"
|
|
123
|
+
build_rc=0
|
|
124
|
+
xcodebuild build-for-testing \
|
|
125
|
+
-project "$HARNESS_PROJECT" \
|
|
126
|
+
-scheme OCQAHarnessUITests \
|
|
127
|
+
-destination "platform=iOS Simulator,id=$UDID" \
|
|
128
|
+
-derivedDataPath "$HARNESS_DERIVED" \
|
|
129
|
+
> "$build_log" 2>&1 || build_rc=$?
|
|
130
|
+
tail -5 "$build_log" >&2
|
|
131
|
+
products=()
|
|
132
|
+
while IFS= read -r product; do products+=("$product"); done < <(find "$HARNESS_DERIVED/Build/Products" -maxdepth 1 -name '*.xctestrun' -type f 2>/dev/null)
|
|
133
|
+
if [[ $build_rc -eq 0 && ${#products[@]} -eq 1 ]]; then
|
|
134
|
+
printf '%s\n%s\n%s\n' "$udid" "$src_fp" "$(basename "${products[0]}")" > "$marker"
|
|
135
|
+
return 0
|
|
136
|
+
fi
|
|
137
|
+
if [[ $attempt -eq 1 ]]; then
|
|
138
|
+
echo "Harness build failed (exit $build_rc, ${#products[@]} test descriptor(s)); deleting $HARNESS_DERIVED and retrying once into a clean folder..." >&2
|
|
139
|
+
rm -rf "$HARNESS_DERIVED"
|
|
140
|
+
fi
|
|
141
|
+
done
|
|
142
|
+
echo "ERROR: Harness build failed twice (exit $build_rc, ${#products[@]} test descriptor(s) produced). Full log: $build_log" >&2
|
|
143
|
+
grep -i "error:" "$build_log" >&2 || tail -20 "$build_log" >&2
|
|
144
|
+
return 1
|
|
125
145
|
}
|
|
126
146
|
|
|
127
147
|
run_harness_test() {
|