gestament 0.1.0
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/README.md +122 -0
- package/dist/element.d.ts +15 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/generated/packageMetadata.d.ts +18 -0
- package/dist/generated/packageMetadata.d.ts.map +1 -0
- package/dist/gestament-config.cjs +87 -0
- package/dist/gestament-config.cjs.map +1 -0
- package/dist/gestament-config.d.ts +18 -0
- package/dist/gestament-config.d.ts.map +1 -0
- package/dist/gestament-config.mjs +86 -0
- package/dist/gestament-config.mjs.map +1 -0
- package/dist/gestament-tray-host.cjs +12 -0
- package/dist/gestament-tray-host.cjs.map +1 -0
- package/dist/gestament-tray-host.d.ts +13 -0
- package/dist/gestament-tray-host.d.ts.map +1 -0
- package/dist/gestament-tray-host.mjs +11 -0
- package/dist/gestament-tray-host.mjs.map +1 -0
- package/dist/gestament-xvfb-worker.cjs +138 -0
- package/dist/gestament-xvfb-worker.cjs.map +1 -0
- package/dist/gestament-xvfb-worker.d.ts +13 -0
- package/dist/gestament-xvfb-worker.d.ts.map +1 -0
- package/dist/gestament-xvfb-worker.mjs +137 -0
- package/dist/gestament-xvfb-worker.mjs.map +1 -0
- package/dist/gestament-xvfb.cjs +132 -0
- package/dist/gestament-xvfb.cjs.map +1 -0
- package/dist/gestament-xvfb.d.ts +13 -0
- package/dist/gestament-xvfb.d.ts.map +1 -0
- package/dist/gestament-xvfb.mjs +131 -0
- package/dist/gestament-xvfb.mjs.map +1 -0
- package/dist/index.cjs +1077 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1077 -0
- package/dist/index.mjs.map +1 -0
- package/dist/launchGtkApp.d.ts +37 -0
- package/dist/launchGtkApp.d.ts.map +1 -0
- package/dist/native-BRnrsqMn.cjs +249 -0
- package/dist/native-BRnrsqMn.cjs.map +1 -0
- package/dist/native-DAhTiLnf.js +249 -0
- package/dist/native-DAhTiLnf.js.map +1 -0
- package/dist/native.d.ts +170 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/testing.cjs +1180 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.ts +329 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.mjs +1158 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/tray.d.ts +17 -0
- package/dist/tray.d.ts.map +1 -0
- package/dist/types.d.ts +920 -0
- package/dist/types.d.ts.map +1 -0
- package/images/gestament-120.png +0 -0
- package/include/gestament/gtk.h +112 -0
- package/package.json +92 -0
- package/prebuilds/linux-arm/gtk3/node.napi.armv7.glibc.node +0 -0
- package/prebuilds/linux-arm/gtk4/node.napi.armv7.glibc.node +0 -0
- package/prebuilds/linux-arm64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-arm64/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-ia32/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-ia32/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-riscv64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-riscv64/gtk4/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/gtk3/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/gtk4/node.napi.glibc.node +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# gestament
|
|
2
|
+
|
|
3
|
+
TypeScript based test driver for GTK
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://www.repostatus.org/#wip)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## What is this?
|
|
13
|
+
|
|
14
|
+
Have you ever wanted to write tests for GTK 3 and 4 applications more easily?
|
|
15
|
+
For browser-based applications, there are various methods for UI/UX testing, but when it comes to GTK, things aren’t quite so straightforward.
|
|
16
|
+
|
|
17
|
+
While there are test drivers available for Python, I’m used to TypeScript, so I’d prefer to write in TypeScript.
|
|
18
|
+
Furthermore, even in TypeScript, there are various test drivers for browser-based applications, and we can expect synergistic benefits by repurposing this testing infrastructure.
|
|
19
|
+
|
|
20
|
+
In other words, suppose we have the following GTK3 code:
|
|
21
|
+
|
|
22
|
+
```cpp
|
|
23
|
+
#include <gestament/gtk.h>
|
|
24
|
+
|
|
25
|
+
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
26
|
+
|
|
27
|
+
// Create GtkLabel
|
|
28
|
+
GtkWidget *label = gtk_label_new("Hello, gestament");
|
|
29
|
+
gestament_gtk_assign_accessible_id(label, "greeting_label");
|
|
30
|
+
|
|
31
|
+
gtk_container_add(GTK_CONTAINER(window), label);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This means you can write this UI test in TypeScript as follows:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { describe, expect, it } from 'vitest';
|
|
38
|
+
import { launchGtkApp } from 'gestament';
|
|
39
|
+
|
|
40
|
+
// Vitest test code
|
|
41
|
+
describe('sample GTK app', () => {
|
|
42
|
+
it('shows greeting text', async () => {
|
|
43
|
+
// Run a GTK app
|
|
44
|
+
const app = await launchGtkApp('./sample-app', []);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
// Get GtkLabel
|
|
48
|
+
const label = await app.getById('greeting_label');
|
|
49
|
+
if (label.kind !== 'label') {
|
|
50
|
+
throw new Error(`Unexpected widget kind: ${label.kind}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Validate label text string
|
|
54
|
+
expect(await label.text()).toBe('Hello, gestament');
|
|
55
|
+
} finally {
|
|
56
|
+
await app.release();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
- Launches GTK applications as child processes, allowing them to be controlled from within tests.
|
|
65
|
+
- Provides APIs for identifying GTK application windows and widgets within those windows.
|
|
66
|
+
- These APIs can be used to check and manipulate widget states.
|
|
67
|
+
- Captures the rendering output of GTK applications to verify the display area and clip state.
|
|
68
|
+
- Detects StatusNotifierItem-based tray icons and allows you to click them, retrieve metadata, and capture screenshots.
|
|
69
|
+
- Runs GTK applications on `xvfb` to enable stable testing in headless environments.
|
|
70
|
+
|
|
71
|
+
### Environment
|
|
72
|
+
|
|
73
|
+
- Node.js version 20 or higher
|
|
74
|
+
- GTK3 or GTK4 (Note: GTK4 requires version 4.22 or later)
|
|
75
|
+
- Linux glibc i686,amd64,arm64,armv7l,riscv64
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
This section shows an example of building a test project from scratch.
|
|
80
|
+
|
|
81
|
+
First, install the native packages other than GTK before installing the NPM package.
|
|
82
|
+
This assumes that the GTK application development environment already has GTK itself, GLib, GDK Pixbuf, and related GTK libraries installed.
|
|
83
|
+
|
|
84
|
+
The following example is for Debian/Ubuntu:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
sudo apt-get update
|
|
88
|
+
sudo apt-get install -y \
|
|
89
|
+
at-spi2-core dbus dbus-x11 \
|
|
90
|
+
libx11-6 libxtst6 \
|
|
91
|
+
xauth xvfb
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- `at-spi2-core` is the AT-SPI runtime environment that gestament uses to identify and operate widgets.
|
|
95
|
+
- `libx11-6` and `libxtst6` are used for X11 screen capture and input operations.
|
|
96
|
+
- `dbus` / `dbus-x11` and `xvfb` / `xauth` are used when running tests headlessly with `gestament-xvfb`.
|
|
97
|
+
|
|
98
|
+
This completes the native environment setup.
|
|
99
|
+
|
|
100
|
+
NPM projects can choose from many test frameworks.
|
|
101
|
+
gestament does not depend on a specific test framework, but the following example uses Vite and Vitest:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Generate a Vite project with the scaffolder.
|
|
105
|
+
npm create vite@latest gestament-tests -- --template vanilla-ts
|
|
106
|
+
|
|
107
|
+
cd gestament-tests
|
|
108
|
+
|
|
109
|
+
# Install the Vitest test driver and gestament.
|
|
110
|
+
npm install
|
|
111
|
+
npm install -D vitest @types/node gestament
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Documentation
|
|
117
|
+
|
|
118
|
+
See [the repository documentation](https://github.com/kekyo/gestament/).
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
Under MIT.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: gestament
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: TypeScript based test driver for GTK
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
8
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { NativeElementHandle } from './native.js';
|
|
12
|
+
import { GtkWidgetElement } from './types.js';
|
|
13
|
+
/** Creates an element bound to an opaque native accessible handle. */
|
|
14
|
+
export declare const createGtkElement: (handle: NativeElementHandle) => GtkWidgetElement;
|
|
15
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAgCL,KAAK,mBAAmB,EAEzB,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAUV,gBAAgB,EAEjB,MAAM,YAAS,CAAC;AAs2BjB,yEAAsE;AACtE,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,mBAAmB,KAC1B,gBAwIF,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: gestament
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: TypeScript based test driver for GTK
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
8
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { GtkAutomationError } from './types.js';
|
|
12
|
+
/** Creates an error for a GTK application that exited before an operation completed. */
|
|
13
|
+
export declare const createGtkAppExitedError: (message: string) => GtkAutomationError;
|
|
14
|
+
/** Creates an error for an invalid public API argument. */
|
|
15
|
+
export declare const createGtkInvalidArgumentError: (message: string) => GtkAutomationError;
|
|
16
|
+
/** Creates an error for an accessible element that was not found. */
|
|
17
|
+
export declare const createGtkElementNotFoundError: (message: string) => GtkAutomationError;
|
|
18
|
+
/** Creates an error for an element whose host object no longer exists. */
|
|
19
|
+
export declare const createGtkStaleElementError: (message: string) => GtkAutomationError;
|
|
20
|
+
/** Creates an error for an operation that exceeded its timeout. */
|
|
21
|
+
export declare const createGtkOperationTimeoutError: (message: string) => GtkAutomationError;
|
|
22
|
+
/** Creates an error for an operation that failed. */
|
|
23
|
+
export declare const createGtkOperationFailedError: (message: string) => GtkAutomationError;
|
|
24
|
+
/** Creates an error for an operation that is not supported by the element. */
|
|
25
|
+
export declare const createGtkUnsupportedInterfaceError: (message: string) => GtkAutomationError;
|
|
26
|
+
/** Converts native addon errors into the public error shape. */
|
|
27
|
+
export declare const normalizeNativeError: (error: unknown) => GtkAutomationError;
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,KAAK,EAAE,kBAAkB,EAA0B,MAAM,SAAS,CAAC;AAiB1E,2FAAwF;AACxF,eAAO,MAAM,uBAAuB,GAAI,SAAS,MAAM,KAAG,kBACT,CAAC;AAElD,2DAA2D;AAC3D,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,KACd,kBAA2E,CAAC;AAE/E,qEAAqE;AACrE,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,KACd,kBAA4E,CAAC;AAEhF,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,GACrC,SAAS,MAAM,KACd,kBAAwE,CAAC;AAE5E,mEAAmE;AACnE,eAAO,MAAM,8BAA8B,GACzC,SAAS,MAAM,KACd,kBAAkE,CAAC;AAEtE,qDAAqD;AACrD,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,KACd,kBAA2E,CAAC;AAE/E,8EAA8E;AAC9E,eAAO,MAAM,kCAAkC,GAC7C,SAAS,MAAM,KACd,kBACyD,CAAC;AAE7D,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,kBAkBrD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: gestament
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: TypeScript based test driver for GTK
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
8
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export declare const name = "gestament";
|
|
12
|
+
export declare const version = "0.1.0";
|
|
13
|
+
export declare const description = "TypeScript based test driver for GTK";
|
|
14
|
+
export declare const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
15
|
+
export declare const license = "MIT";
|
|
16
|
+
export declare const repository_url = "https://github.com/kekyo/gestament.git";
|
|
17
|
+
export declare const git_commit_hash = "2e2298272ff7a9fff6945b8d87de6223ac4d7847";
|
|
18
|
+
//# sourceMappingURL=packageMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageMetadata.d.ts","sourceRoot":"","sources":["../../src/generated/packageMetadata.ts"],"names":[],"mappings":";;;;;;;;;AAIA,eAAO,MAAM,IAAI,cAAc,CAAC;AAChC,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,WAAW,yCAAyC,CAAC;AAClE,eAAO,MAAM,MAAM,uCAAuC,CAAC;AAC3D,eAAO,MAAM,OAAO,QAAQ,CAAC;AAC7B,eAAO,MAAM,cAAc,2CAA2C,CAAC;AACvE,eAAO,MAAM,eAAe,6CAA6C,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const node_fs = require("node:fs");
|
|
5
|
+
const node_path = require("node:path");
|
|
6
|
+
const node_url = require("node:url");
|
|
7
|
+
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
8
|
+
const usageText = [
|
|
9
|
+
"Usage: gestament-config --includedir",
|
|
10
|
+
" gestament-config --cflags",
|
|
11
|
+
" gestament-config --help",
|
|
12
|
+
"",
|
|
13
|
+
"Prints build flags for the gestament GTK helper header.",
|
|
14
|
+
""
|
|
15
|
+
].join("\n");
|
|
16
|
+
const createGestamentConfigOutput = (args, includeDir) => {
|
|
17
|
+
if (args.length !== 1) {
|
|
18
|
+
return {
|
|
19
|
+
exitCode: 2,
|
|
20
|
+
stderr: 'gestament-config: expected exactly one option.\nRun "gestament-config --help" for usage.\n',
|
|
21
|
+
stdout: ""
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const option = args[0];
|
|
25
|
+
if (option === "--help" || option === "-h") {
|
|
26
|
+
return {
|
|
27
|
+
exitCode: 0,
|
|
28
|
+
stderr: "",
|
|
29
|
+
stdout: usageText
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (option === "--includedir") {
|
|
33
|
+
return {
|
|
34
|
+
exitCode: 0,
|
|
35
|
+
stderr: "",
|
|
36
|
+
stdout: `${includeDir}
|
|
37
|
+
`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (option === "--cflags") {
|
|
41
|
+
return {
|
|
42
|
+
exitCode: 0,
|
|
43
|
+
stderr: "",
|
|
44
|
+
stdout: `-I${includeDir}
|
|
45
|
+
`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
exitCode: 2,
|
|
50
|
+
stderr: `gestament-config: unknown option: ${option}
|
|
51
|
+
Run "gestament-config --help" for usage.
|
|
52
|
+
`,
|
|
53
|
+
stdout: ""
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const includeDirFromExecutable = (executablePath) => {
|
|
57
|
+
const executableRealPath = node_fs.realpathSync(executablePath);
|
|
58
|
+
const packageRoot = node_path.dirname(node_path.dirname(executableRealPath));
|
|
59
|
+
return node_path.resolve(packageRoot, "include");
|
|
60
|
+
};
|
|
61
|
+
const isMainModule = () => {
|
|
62
|
+
const executablePath = process.argv[1];
|
|
63
|
+
if (executablePath === void 0) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return node_fs.realpathSync(executablePath) === node_fs.realpathSync(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("gestament-config.cjs", document.baseURI).href));
|
|
67
|
+
};
|
|
68
|
+
const run = () => {
|
|
69
|
+
const executablePath = process.argv[1];
|
|
70
|
+
if (executablePath === void 0) {
|
|
71
|
+
process.stderr.write("gestament-config: missing executable path.\n");
|
|
72
|
+
process.exitCode = 2;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const output = createGestamentConfigOutput(
|
|
76
|
+
process.argv.slice(2),
|
|
77
|
+
includeDirFromExecutable(executablePath)
|
|
78
|
+
);
|
|
79
|
+
process.stdout.write(output.stdout);
|
|
80
|
+
process.stderr.write(output.stderr);
|
|
81
|
+
process.exitCode = output.exitCode;
|
|
82
|
+
};
|
|
83
|
+
if (isMainModule()) {
|
|
84
|
+
run();
|
|
85
|
+
}
|
|
86
|
+
exports.createGestamentConfigOutput = createGestamentConfigOutput;
|
|
87
|
+
//# sourceMappingURL=gestament-config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-config.cjs","sources":["../src/gestament-config.ts"],"sourcesContent":["#!/usr/bin/env node\n// gestament - TypeScript based test driver for GTK.\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/gestament\n\nimport { realpathSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\nexport interface GestamentConfigOutput {\n readonly exitCode: 0 | 2;\n readonly stderr: string;\n readonly stdout: string;\n}\n\nconst usageText = [\n 'Usage: gestament-config --includedir',\n ' gestament-config --cflags',\n ' gestament-config --help',\n '',\n 'Prints build flags for the gestament GTK helper header.',\n '',\n].join('\\n');\n\nexport const createGestamentConfigOutput = (\n args: readonly string[],\n includeDir: string\n): GestamentConfigOutput => {\n if (args.length !== 1) {\n return {\n exitCode: 2,\n stderr:\n 'gestament-config: expected exactly one option.\\n' +\n 'Run \"gestament-config --help\" for usage.\\n',\n stdout: '',\n };\n }\n\n const option = args[0];\n if (option === '--help' || option === '-h') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: usageText,\n };\n }\n\n if (option === '--includedir') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: `${includeDir}\\n`,\n };\n }\n\n if (option === '--cflags') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: `-I${includeDir}\\n`,\n };\n }\n\n return {\n exitCode: 2,\n stderr:\n `gestament-config: unknown option: ${option}\\n` +\n 'Run \"gestament-config --help\" for usage.\\n',\n stdout: '',\n };\n};\n\nconst includeDirFromExecutable = (executablePath: string): string => {\n const executableRealPath = realpathSync(executablePath);\n const packageRoot = dirname(dirname(executableRealPath));\n return resolve(packageRoot, 'include');\n};\n\nconst isMainModule = (): boolean => {\n const executablePath = process.argv[1];\n if (executablePath === undefined) {\n return false;\n }\n\n return (\n realpathSync(executablePath) ===\n realpathSync(fileURLToPath(import.meta.url))\n );\n};\n\nconst run = (): void => {\n const executablePath = process.argv[1];\n if (executablePath === undefined) {\n process.stderr.write('gestament-config: missing executable path.\\n');\n process.exitCode = 2;\n return;\n }\n\n const output = createGestamentConfigOutput(\n process.argv.slice(2),\n includeDirFromExecutable(executablePath)\n );\n process.stdout.write(output.stdout);\n process.stderr.write(output.stderr);\n process.exitCode = output.exitCode;\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\nif (isMainModule()) {\n run();\n}\n"],"names":["realpathSync","dirname","resolve","fileURLToPath"],"mappings":";;;;;;;AAkBA,MAAM,YAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEJ,MAAM,8BAA8B,CACzC,MACA,eAC0B;AAC1B,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QACE;AAAA,MAEF,QAAQ;AAAA,IAAA;AAAA,EAEZ;AAEA,QAAM,SAAS,KAAK,CAAC;AACrB,MAAI,WAAW,YAAY,WAAW,MAAM;AAC1C,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,QAAQ;AAAA,IAAA;AAAA,EAEZ;AAEA,MAAI,WAAW,gBAAgB;AAC7B,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,QAAQ,GAAG,UAAU;AAAA;AAAA,IAAA;A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/usr/bin/env node
|
|
2
|
+
/*!
|
|
3
|
+
* name: gestament
|
|
4
|
+
* version: 0.1.0
|
|
5
|
+
* description: TypeScript based test driver for GTK
|
|
6
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
7
|
+
* license: MIT
|
|
8
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
9
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface GestamentConfigOutput {
|
|
13
|
+
readonly exitCode: 0 | 2;
|
|
14
|
+
readonly stderr: string;
|
|
15
|
+
readonly stdout: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const createGestamentConfigOutput: (args: readonly string[], includeDir: string) => GestamentConfigOutput;
|
|
18
|
+
//# sourceMappingURL=gestament-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-config.d.ts","sourceRoot":"","sources":["../src/gestament-config.ts"],"names":[],"mappings":";;;;;;;;;;AAYA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAWD,eAAO,MAAM,2BAA2B,GACtC,MAAM,SAAS,MAAM,EAAE,EACvB,YAAY,MAAM,KACjB,qBA2CF,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const usageText = [
|
|
6
|
+
"Usage: gestament-config --includedir",
|
|
7
|
+
" gestament-config --cflags",
|
|
8
|
+
" gestament-config --help",
|
|
9
|
+
"",
|
|
10
|
+
"Prints build flags for the gestament GTK helper header.",
|
|
11
|
+
""
|
|
12
|
+
].join("\n");
|
|
13
|
+
const createGestamentConfigOutput = (args, includeDir) => {
|
|
14
|
+
if (args.length !== 1) {
|
|
15
|
+
return {
|
|
16
|
+
exitCode: 2,
|
|
17
|
+
stderr: 'gestament-config: expected exactly one option.\nRun "gestament-config --help" for usage.\n',
|
|
18
|
+
stdout: ""
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const option = args[0];
|
|
22
|
+
if (option === "--help" || option === "-h") {
|
|
23
|
+
return {
|
|
24
|
+
exitCode: 0,
|
|
25
|
+
stderr: "",
|
|
26
|
+
stdout: usageText
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (option === "--includedir") {
|
|
30
|
+
return {
|
|
31
|
+
exitCode: 0,
|
|
32
|
+
stderr: "",
|
|
33
|
+
stdout: `${includeDir}
|
|
34
|
+
`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (option === "--cflags") {
|
|
38
|
+
return {
|
|
39
|
+
exitCode: 0,
|
|
40
|
+
stderr: "",
|
|
41
|
+
stdout: `-I${includeDir}
|
|
42
|
+
`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
exitCode: 2,
|
|
47
|
+
stderr: `gestament-config: unknown option: ${option}
|
|
48
|
+
Run "gestament-config --help" for usage.
|
|
49
|
+
`,
|
|
50
|
+
stdout: ""
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const includeDirFromExecutable = (executablePath) => {
|
|
54
|
+
const executableRealPath = realpathSync(executablePath);
|
|
55
|
+
const packageRoot = dirname(dirname(executableRealPath));
|
|
56
|
+
return resolve(packageRoot, "include");
|
|
57
|
+
};
|
|
58
|
+
const isMainModule = () => {
|
|
59
|
+
const executablePath = process.argv[1];
|
|
60
|
+
if (executablePath === void 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return realpathSync(executablePath) === realpathSync(fileURLToPath(import.meta.url));
|
|
64
|
+
};
|
|
65
|
+
const run = () => {
|
|
66
|
+
const executablePath = process.argv[1];
|
|
67
|
+
if (executablePath === void 0) {
|
|
68
|
+
process.stderr.write("gestament-config: missing executable path.\n");
|
|
69
|
+
process.exitCode = 2;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const output = createGestamentConfigOutput(
|
|
73
|
+
process.argv.slice(2),
|
|
74
|
+
includeDirFromExecutable(executablePath)
|
|
75
|
+
);
|
|
76
|
+
process.stdout.write(output.stdout);
|
|
77
|
+
process.stderr.write(output.stderr);
|
|
78
|
+
process.exitCode = output.exitCode;
|
|
79
|
+
};
|
|
80
|
+
if (isMainModule()) {
|
|
81
|
+
run();
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
createGestamentConfigOutput
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=gestament-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-config.mjs","sources":["../src/gestament-config.ts"],"sourcesContent":["#!/usr/bin/env node\n// gestament - TypeScript based test driver for GTK.\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/gestament\n\nimport { realpathSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\nexport interface GestamentConfigOutput {\n readonly exitCode: 0 | 2;\n readonly stderr: string;\n readonly stdout: string;\n}\n\nconst usageText = [\n 'Usage: gestament-config --includedir',\n ' gestament-config --cflags',\n ' gestament-config --help',\n '',\n 'Prints build flags for the gestament GTK helper header.',\n '',\n].join('\\n');\n\nexport const createGestamentConfigOutput = (\n args: readonly string[],\n includeDir: string\n): GestamentConfigOutput => {\n if (args.length !== 1) {\n return {\n exitCode: 2,\n stderr:\n 'gestament-config: expected exactly one option.\\n' +\n 'Run \"gestament-config --help\" for usage.\\n',\n stdout: '',\n };\n }\n\n const option = args[0];\n if (option === '--help' || option === '-h') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: usageText,\n };\n }\n\n if (option === '--includedir') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: `${includeDir}\\n`,\n };\n }\n\n if (option === '--cflags') {\n return {\n exitCode: 0,\n stderr: '',\n stdout: `-I${includeDir}\\n`,\n };\n }\n\n return {\n exitCode: 2,\n stderr:\n `gestament-config: unknown option: ${option}\\n` +\n 'Run \"gestament-config --help\" for usage.\\n',\n stdout: '',\n };\n};\n\nconst includeDirFromExecutable = (executablePath: string): string => {\n const executableRealPath = realpathSync(executablePath);\n const packageRoot = dirname(dirname(executableRealPath));\n return resolve(packageRoot, 'include');\n};\n\nconst isMainModule = (): boolean => {\n const executablePath = process.argv[1];\n if (executablePath === undefined) {\n return false;\n }\n\n return (\n realpathSync(executablePath) ===\n realpathSync(fileURLToPath(import.meta.url))\n );\n};\n\nconst run = (): void => {\n const executablePath = process.argv[1];\n if (executablePath === undefined) {\n process.stderr.write('gestament-config: missing executable path.\\n');\n process.exitCode = 2;\n return;\n }\n\n const output = createGestamentConfigOutput(\n process.argv.slice(2),\n includeDirFromExecutable(executablePath)\n );\n process.stdout.write(output.stdout);\n process.stderr.write(output.stderr);\n process.exitCode = output.exitCode;\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\nif (isMainModule()) {\n run();\n}\n"],"names":[],"mappings":";;;;AAkBA,MAAM,YAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEJ,MAAM,8BAA8B,CACzC,MACA,eAC0B;AAC1B,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QACE;AAAA,MAEF,QAAQ;AAAA,IAAA;AAAA,EAEZ;AAEA,QAAM,SAAS,KAAK,CAAC;AACrB,MAAI,WAAW,YAAY,WAAW,MAAM;AAC1C,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QA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
|
|
3
|
+
const native = require("./native-BRnrsqMn.cjs");
|
|
4
|
+
try {
|
|
5
|
+
native.nativeRunTrayHost();
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8
|
+
process.stderr.write(`gestament-tray-host: ${message}
|
|
9
|
+
`);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=gestament-tray-host.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-tray-host.cjs","sources":["../src/gestament-tray-host.ts"],"sourcesContent":["#!/usr/bin/env node\n// gestament - TypeScript based test driver for GTK.\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/gestament\n\nimport { nativeRunTrayHost } from './native';\n\ntry {\n nativeRunTrayHost();\n} catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`gestament-tray-host: ${message}\\n`);\n process.exitCode = 1;\n}\n"],"names":["nativeRunTrayHost"],"mappings":";;;AAQA,IAAI;AACFA,2BAAA;AACF,SAAS,OAAO;AACd,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,wBAAwB,OAAO;AAAA,CAAI;AACxD,UAAQ,WAAW;AACrB;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*!
|
|
3
|
+
* name: gestament
|
|
4
|
+
* version: 0.1.0
|
|
5
|
+
* description: TypeScript based test driver for GTK
|
|
6
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
7
|
+
* license: MIT
|
|
8
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
9
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=gestament-tray-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-tray-host.d.ts","sourceRoot":"","sources":["../src/gestament-tray-host.ts"],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { S as nativeRunTrayHost } from "./native-DAhTiLnf.js";
|
|
3
|
+
try {
|
|
4
|
+
nativeRunTrayHost();
|
|
5
|
+
} catch (error) {
|
|
6
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
7
|
+
process.stderr.write(`gestament-tray-host: ${message}
|
|
8
|
+
`);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=gestament-tray-host.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-tray-host.mjs","sources":["../src/gestament-tray-host.ts"],"sourcesContent":["#!/usr/bin/env node\n// gestament - TypeScript based test driver for GTK.\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/gestament\n\nimport { nativeRunTrayHost } from './native';\n\ntry {\n nativeRunTrayHost();\n} catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`gestament-tray-host: ${message}\\n`);\n process.exitCode = 1;\n}\n"],"names":[],"mappings":";;AAQA,IAAI;AACF,oBAAA;AACF,SAAS,OAAO;AACd,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,wBAAwB,OAAO;AAAA,CAAI;AACxD,UAAQ,WAAW;AACrB;"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const node_child_process = require("node:child_process");
|
|
4
|
+
const node_fs = require("node:fs");
|
|
5
|
+
const node_path = require("node:path");
|
|
6
|
+
const trayHostReadyLine = "gestament-tray-host-ready";
|
|
7
|
+
const trayHostReadyTimeoutMs = 3e4;
|
|
8
|
+
const parseArguments = (args) => {
|
|
9
|
+
let withTrayHost = false;
|
|
10
|
+
let index = 0;
|
|
11
|
+
while (index < args.length) {
|
|
12
|
+
const argument = args[index];
|
|
13
|
+
if (argument === "--") {
|
|
14
|
+
return {
|
|
15
|
+
command: args.slice(index + 1),
|
|
16
|
+
withTrayHost
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (argument === "--with-tray-host") {
|
|
20
|
+
withTrayHost = true;
|
|
21
|
+
index += 1;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Unknown gestament-xvfb worker option: ${argument}`);
|
|
25
|
+
}
|
|
26
|
+
throw new Error("Missing command separator: --");
|
|
27
|
+
};
|
|
28
|
+
const waitForTrayHostReady = (host) => new Promise((resolve2, reject) => {
|
|
29
|
+
if (host.stdout === null) {
|
|
30
|
+
reject(new Error("gestament tray host did not expose stdout."));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let output = "";
|
|
34
|
+
let settled = false;
|
|
35
|
+
const timeout = setTimeout(() => {
|
|
36
|
+
if (!settled) {
|
|
37
|
+
settled = true;
|
|
38
|
+
reject(new Error("Timed out waiting for gestament tray host."));
|
|
39
|
+
}
|
|
40
|
+
}, trayHostReadyTimeoutMs);
|
|
41
|
+
host.stdout.on("data", (chunk) => {
|
|
42
|
+
const text = chunk.toString("utf8");
|
|
43
|
+
output += text;
|
|
44
|
+
if (!settled && output.includes(trayHostReadyLine)) {
|
|
45
|
+
settled = true;
|
|
46
|
+
clearTimeout(timeout);
|
|
47
|
+
resolve2();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (settled) {
|
|
51
|
+
process.stdout.write(text);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
host.on("exit", (code, signal) => {
|
|
55
|
+
if (!settled) {
|
|
56
|
+
settled = true;
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
reject(
|
|
59
|
+
new Error(
|
|
60
|
+
`gestament tray host exited before ready: code=${String(
|
|
61
|
+
code
|
|
62
|
+
)}, signal=${String(signal)}`
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
host.on("error", (error) => {
|
|
68
|
+
if (!settled) {
|
|
69
|
+
settled = true;
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
reject(error);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
const startTrayHost = async () => {
|
|
76
|
+
const executablePath = process.argv[1];
|
|
77
|
+
if (executablePath === void 0) {
|
|
78
|
+
throw new Error("Missing executable path.");
|
|
79
|
+
}
|
|
80
|
+
const hostPath = node_path.resolve(
|
|
81
|
+
node_path.dirname(node_fs.realpathSync(executablePath)),
|
|
82
|
+
"gestament-tray-host.cjs"
|
|
83
|
+
);
|
|
84
|
+
const host = node_child_process.spawn(process.execPath, [hostPath], {
|
|
85
|
+
env: process.env,
|
|
86
|
+
stdio: ["ignore", "pipe", "inherit"]
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
await waitForTrayHostReady(host);
|
|
90
|
+
return host;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (host.exitCode === null && host.signalCode === null) {
|
|
93
|
+
host.kill("SIGTERM");
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const runCommand = (command) => new Promise((resolve2, reject) => {
|
|
99
|
+
if (command.length === 0) {
|
|
100
|
+
reject(new Error("Missing command to run under Xvfb."));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const child = node_child_process.spawn(command[0], command.slice(1), {
|
|
104
|
+
env: process.env,
|
|
105
|
+
stdio: "inherit"
|
|
106
|
+
});
|
|
107
|
+
child.on("error", reject);
|
|
108
|
+
child.on("exit", (code, signal) => {
|
|
109
|
+
resolve2({ code, signal });
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
const run = async () => {
|
|
113
|
+
const parsed = parseArguments(process.argv.slice(2));
|
|
114
|
+
const trayHost = parsed.withTrayHost ? await startTrayHost() : void 0;
|
|
115
|
+
try {
|
|
116
|
+
const result = await runCommand(parsed.command);
|
|
117
|
+
if (result.code !== null) {
|
|
118
|
+
process.exitCode = result.code;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
process.stderr.write(
|
|
122
|
+
`gestament-xvfb command exited by signal: ${result.signal}
|
|
123
|
+
`
|
|
124
|
+
);
|
|
125
|
+
process.exitCode = 1;
|
|
126
|
+
} finally {
|
|
127
|
+
if (trayHost !== void 0 && trayHost.exitCode === null) {
|
|
128
|
+
trayHost.kill("SIGTERM");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
run().catch((error) => {
|
|
133
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
134
|
+
process.stderr.write(`gestament-xvfb worker: ${message}
|
|
135
|
+
`);
|
|
136
|
+
process.exitCode = 2;
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=gestament-xvfb-worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-xvfb-worker.cjs","sources":["../src/gestament-xvfb-worker.ts"],"sourcesContent":["#!/usr/bin/env node\n// gestament - TypeScript based test driver for GTK.\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/gestament\n\nimport { spawn, type ChildProcess } from 'node:child_process';\nimport { realpathSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\ninterface WorkerArguments {\n readonly command: readonly string[];\n readonly withTrayHost: boolean;\n}\n\nconst trayHostReadyLine = 'gestament-tray-host-ready';\nconst trayHostReadyTimeoutMs = 30_000;\n\nconst parseArguments = (args: readonly string[]): WorkerArguments => {\n let withTrayHost = false;\n let index = 0;\n\n while (index < args.length) {\n const argument = args[index];\n if (argument === '--') {\n return {\n command: args.slice(index + 1),\n withTrayHost,\n };\n }\n\n if (argument === '--with-tray-host') {\n withTrayHost = true;\n index += 1;\n continue;\n }\n\n throw new Error(`Unknown gestament-xvfb worker option: ${argument}`);\n }\n\n throw new Error('Missing command separator: --');\n};\n\nconst waitForTrayHostReady = (host: ChildProcess): Promise<void> =>\n new Promise<void>((resolve, reject) => {\n if (host.stdout === null) {\n reject(new Error('gestament tray host did not expose stdout.'));\n return;\n }\n\n let output = '';\n let settled = false;\n\n const timeout = setTimeout(() => {\n if (!settled) {\n settled = true;\n reject(new Error('Timed out waiting for gestament tray host.'));\n }\n }, trayHostReadyTimeoutMs);\n\n host.stdout.on('data', (chunk: Buffer) => {\n const text = chunk.toString('utf8');\n output += text;\n if (!settled && output.includes(trayHostReadyLine)) {\n settled = true;\n clearTimeout(timeout);\n resolve();\n return;\n }\n if (settled) {\n process.stdout.write(text);\n }\n });\n\n host.on('exit', (code, signal) => {\n if (!settled) {\n settled = true;\n clearTimeout(timeout);\n reject(\n new Error(\n `gestament tray host exited before ready: code=${String(\n code\n )}, signal=${String(signal)}`\n )\n );\n }\n });\n\n host.on('error', (error) => {\n if (!settled) {\n settled = true;\n clearTimeout(timeout);\n reject(error);\n }\n });\n });\n\nconst startTrayHost = async (): Promise<ChildProcess> => {\n const executablePath = process.argv[1];\n if (executablePath === undefined) {\n throw new Error('Missing executable path.');\n }\n\n const hostPath = resolve(\n dirname(realpathSync(executablePath)),\n 'gestament-tray-host.cjs'\n );\n const host = spawn(process.execPath, [hostPath], {\n env: process.env,\n stdio: ['ignore', 'pipe', 'inherit'],\n });\n try {\n await waitForTrayHostReady(host);\n return host;\n } catch (error) {\n if (host.exitCode === null && host.signalCode === null) {\n host.kill('SIGTERM');\n }\n throw error;\n }\n};\n\nconst runCommand = (\n command: readonly string[]\n): Promise<{\n readonly code: number | null;\n readonly signal: NodeJS.Signals | null;\n}> =>\n new Promise((resolve, reject) => {\n if (command.length === 0) {\n reject(new Error('Missing command to run under Xvfb.'));\n return;\n }\n\n const child = spawn(command[0] as string, command.slice(1), {\n env: process.env,\n stdio: 'inherit',\n });\n\n child.on('error', reject);\n child.on('exit', (code, signal) => {\n resolve({ code, signal });\n });\n });\n\nconst run = async (): Promise<void> => {\n const parsed = parseArguments(process.argv.slice(2));\n const trayHost = parsed.withTrayHost ? await startTrayHost() : undefined;\n\n try {\n const result = await runCommand(parsed.command);\n if (result.code !== null) {\n process.exitCode = result.code;\n return;\n }\n\n process.stderr.write(\n `gestament-xvfb command exited by signal: ${result.signal}\\n`\n );\n process.exitCode = 1;\n } finally {\n if (trayHost !== undefined && trayHost.exitCode === null) {\n trayHost.kill('SIGTERM');\n }\n }\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\nrun().catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`gestament-xvfb worker: ${message}\\n`);\n process.exitCode = 2;\n});\n"],"names":["resolve","dirname","realpathSync","spawn"],"mappings":";;;;;AAiBA,MAAM,oBAAoB;AAC1B,MAAM,yBAAyB;AAE/B,MAAM,iBAAiB,CAAC,SAA6C;AACnE,MAAI,eAAe;AACnB,MAAI,QAAQ;AAEZ,SAAO,QAAQ,KAAK,QAAQ;AAC1B,UAAM,WAAW,KAAK,KAAK;AAC3B,QAAI,aAAa,MAAM;AACrB,aAAO;AAAA,QACL,SAAS,KAAK,MAAM,QAAQ,CAAC;AAAA,QAC7B;AAAA,MAAA;AAAA,IAEJ;AAEA,QAAI,aAAa,oBAAoB;AACnC,qBAAe;AACf,eAAS;AACT;AAAA,IACF;AAEA,UAAM,IAAI,MAAM,yCAAyC,QAAQ,EAAE;AAAA,EACrE;AAEA,QAAM,IAAI,MAAM,+BAA+B;AACjD;AAEA,MAAM,uBAAuB,CAAC,SAC5B,IAAI,QAAc,CAACA,UAAS,WAAW;AACrC,MAAI,KAAK,WAAW,MAAM;AACxB,WAAO,IAAI,MAAM,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AAO;AAAA,CAAI;AAC1D,UAAQ,WAAW;AACrB,CAAC;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*!
|
|
3
|
+
* name: gestament
|
|
4
|
+
* version: 0.1.0
|
|
5
|
+
* description: TypeScript based test driver for GTK
|
|
6
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
7
|
+
* license: MIT
|
|
8
|
+
* repository.url: https://github.com/kekyo/gestament.git
|
|
9
|
+
* git.commit.hash: 2e2298272ff7a9fff6945b8d87de6223ac4d7847
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=gestament-xvfb-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestament-xvfb-worker.d.ts","sourceRoot":"","sources":["../src/gestament-xvfb-worker.ts"],"names":[],"mappings":";;;;;;;;;"}
|