Skip to content

Commit 37e637b

Browse files
committed
feat(std): testing checkpoint
- assertJsonSnapshot, used in std - improve binary testing syntax - fix pkg-config testing bug - proper library testing - fix tgld transitive discovery bug
1 parent 1380d84 commit 37e637b

File tree

32 files changed

+1106
-697
lines changed

32 files changed

+1106
-697
lines changed

packages/acl/tangram.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,12 @@ export const build = async (...args: std.Args<Arg>) => {
8888
export default build;
8989

9090
export const test = async () => {
91-
const displaysUsage = (name: string) => {
92-
return {
93-
name,
94-
testArgs: [],
95-
testPredicate: (stdout: string) => stdout.includes("Usage:"),
96-
};
97-
};
9891
const spec = {
9992
...std.assert.defaultSpec(metadata),
100-
binaries: metadata.provides.binaries.map(displaysUsage),
93+
binaries: std.assert.allBinaries(metadata.provides.binaries, {
94+
testArgs: [],
95+
snapshot: "Usage:",
96+
}),
10197
};
10298
return await std.assert.pkg(build, spec);
10399
};

packages/attr/tangram.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,12 @@ const provides = {
7575
};
7676

7777
export const test = async () => {
78-
const displaysUsage = (name: string) => {
79-
return {
80-
name,
81-
testArgs: [],
82-
testPredicate: (stdout: string) => stdout.includes("Usage:"),
83-
};
84-
};
8578
const spec = {
8679
...provides,
87-
binaries: provides.binaries.map(displaysUsage),
80+
binaries: std.assert.allBinaries(provides.binaries, {
81+
testArgs: [],
82+
snapshot: "Usage:",
83+
}),
8884
metadata,
8985
};
9086
return await std.assert.pkg(build, spec);

packages/bun/tangram.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export const metadata = {
55
license: "MIT",
66
name: "bun",
77
repository: "https://github.com/oven-sh/bun",
8-
version: "1.2.20",
9-
tag: "bun/1.2.20",
8+
version: "1.3.0",
9+
tag: "bun/1.3.0",
1010
provides: {
1111
binaries: ["bun"],
1212
},
@@ -52,13 +52,13 @@ export default self;
5252
// Taken from https://github.com/oven-sh/bun/releases/download/bun-v${version}/SHASUMS256.txt.asc
5353
const binaryChecksums: { [key: string]: tg.Checksum } = {
5454
["aarch64-linux"]:
55-
"sha256:98d2e0b2c09421569172b4d46b6f81378c2dbdd77480ebb27f3989dd4e72e18b",
55+
"sha256:68b7dcd86a35e7d5e156b37e4cef4b4ab6d6b37fd2179570c0e815f13890febd",
5656
["x86_64-linux"]:
57-
"sha256:4e9edc4cba0c7c1623a288be01e53bbde11a4d073f2cf339cab026627858b548",
57+
"sha256:60c39d92b8bd090627524c98b3012f0c08dc89024cfdaa7c9c98cb5fd4359376",
5858
["aarch64-darwin"]:
59-
"sha256:404f5a6dd1f604b40eb3b156d4197bb8d398bb26e0ae4c8ac8e7aa490f7e235f",
59+
"sha256:85848e3f96481efcabe75a500fd3b94b9bb95686ab7ad0a3892976c7be15036a",
6060
["x86_64-darwin"]:
61-
"sha256:e1cc2f4b8e4d4172dde107982db42a22f8c5c8d8bb26078c23285704a4b72cd6",
61+
"sha256:09d54af86ec45354bb63ff7ccc3ce9520d74f4e45f9f7cac8ceb7fac422fcc19",
6262
};
6363

6464
export const test = async () => {

packages/bzip2/tangram.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ export default build;
9494
export const test = async () => {
9595
const spec = {
9696
...std.assert.defaultSpec(metadata),
97-
binaries: metadata.provides.binaries.map((name) => {
98-
return {
99-
name,
100-
testArgs: ["--help"],
101-
};
97+
binaries: std.assert.allBinaries(metadata.provides.binaries, {
98+
testArgs: ["--help"],
10299
}),
103100
};
104101
return await std.assert.pkg(build, spec);

packages/esbuild/tangram.ts

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,63 @@ import * as std from "std" with { local: "../std" };
55
import { $ } from "std" with { local: "../std" };
66

77
export const metadata = {
8-
home: "https://esbuild.github.io",
9-
license: "MIT",
10-
name: "esbuild",
11-
repository: "https://github.com/evanw/esbuild",
12-
version: "0.25.2",
13-
tag: "esbuild/0.25.2",
8+
home: "https://esbuild.github.io",
9+
license: "MIT",
10+
name: "esbuild",
11+
repository: "https://github.com/evanw/esbuild",
12+
version: "0.25.2",
13+
tag: "esbuild/0.25.2",
1414
};
1515

1616
export const source = async () => {
17-
const { name, version } = metadata;
18-
const checksum =
19-
"sha256:01a6c0a5949e5c2d53e19be52aec152b3186f8bbcf98df6996a20a972a78c330";
20-
const owner = "evanw";
21-
const repo = name;
22-
const tag = `v${version}`;
23-
return std.download.fromGithub({
24-
checksum,
25-
owner,
26-
repo,
27-
source: "tag",
28-
tag,
29-
});
17+
const { name, version } = metadata;
18+
const checksum =
19+
"sha256:01a6c0a5949e5c2d53e19be52aec152b3186f8bbcf98df6996a20a972a78c330";
20+
const owner = "evanw";
21+
const repo = name;
22+
const tag = `v${version}`;
23+
return std.download.fromGithub({
24+
checksum,
25+
owner,
26+
repo,
27+
source: "tag",
28+
tag,
29+
});
3030
};
3131

3232
export type Arg = {
33-
dependencies?: {
34-
go?: go.Arg;
35-
nodejs?: nodejs.Arg;
36-
};
37-
env?: std.env.Arg;
38-
host?: string;
39-
source?: tg.Directory;
33+
dependencies?: {
34+
go?: go.Arg;
35+
nodejs?: nodejs.Arg;
36+
};
37+
env?: std.env.Arg;
38+
host?: string;
39+
source?: tg.Directory;
4040
};
4141

4242
export const build = async (...args: std.Args<Arg>) => {
43-
const {
44-
dependencies: { go: goArg = {}, nodejs: nodejsArg = {} } = {},
45-
env: env_,
46-
host,
47-
source: source_,
48-
} = await std.packages.applyArgs<Arg>(...args);
43+
const {
44+
dependencies: { go: goArg = {}, nodejs: nodejsArg = {} } = {},
45+
env: env_,
46+
host,
47+
source: source_,
48+
} = await std.packages.applyArgs<Arg>(...args);
4949

50-
const sourceDir = source_ ?? source();
50+
const sourceDir = source_ ?? source();
5151

52-
const certFile = tg`${std.caCertificates()}/cacert.pem`;
53-
const env = std.env.arg(
54-
std.sdk({ host }),
55-
go.self(goArg),
56-
nodejs.self(nodejsArg),
57-
make.build({ host }),
58-
{
59-
SSL_CERT_FILE: certFile,
60-
},
61-
env_,
62-
);
52+
const certFile = tg`${std.caCertificates()}/cacert.pem`;
53+
const env = std.env.arg(
54+
std.sdk({ host }),
55+
go.self(goArg),
56+
nodejs.self(nodejsArg),
57+
make.build({ host }),
58+
{
59+
SSL_CERT_FILE: certFile,
60+
},
61+
env_,
62+
);
6363

64-
return await $`mkdir work
64+
return await $`mkdir work
6565
cp -R ${sourceDir}/* ./work
6666
chmod -R u+w ./work
6767
TMPDIR=$PWD/tmp
@@ -74,15 +74,15 @@ export const build = async (...args: std.Args<Arg>) => {
7474
mkdir -p $OUTPUT/bin
7575
cp esbuild $OUTPUT/bin
7676
`
77-
.env(env)
78-
.checksum("sha256:any")
79-
.network(true)
80-
.then(tg.Directory.expect);
77+
.env(env)
78+
.checksum("sha256:any")
79+
.network(true)
80+
.then(tg.Directory.expect);
8181
};
8282

8383
export default build;
8484

8585
export const test = async () => {
86-
const spec = std.assert.defaultSpec(metadata);
87-
return await std.assert.pkg(build, spec);
86+
const spec = std.assert.defaultSpec(metadata);
87+
return await std.assert.pkg(build, spec);
8888
};

packages/eslint/tangram.ts

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,58 @@ import * as std from "std" with { local: "../std" };
44
import packageLock from "./package-lock.json" with { type: "file" };
55

66
export const metadata = {
7-
home: "https://eslint.org",
8-
license: "MIT",
9-
name: "eslint",
10-
repository: "https://github.com/eslint/eslint",
11-
version: "9.1.1",
12-
tag: "eslint/9.1.1",
13-
provides: {
14-
binaries: ["eslint"],
15-
},
7+
home: "https://eslint.org",
8+
license: "MIT",
9+
name: "eslint",
10+
repository: "https://github.com/eslint/eslint",
11+
version: "9.1.1",
12+
tag: "eslint/9.1.1",
13+
provides: {
14+
binaries: ["eslint"],
15+
},
1616
};
1717

1818
export const source = async () => {
19-
const { name, version } = metadata;
20-
const checksum =
21-
"sha256:4f39cb81c3540cbb5e0ccbbb7afff672fec31ac835b1f0be9bbf353083c61b38";
22-
const owner = name;
23-
const repo = name;
24-
const tag = `v${version}`;
25-
return std.download.fromGithub({
26-
checksum,
27-
owner,
28-
repo,
29-
source: "tag",
30-
tag,
31-
});
19+
const { name, version } = metadata;
20+
const checksum =
21+
"sha256:4f39cb81c3540cbb5e0ccbbb7afff672fec31ac835b1f0be9bbf353083c61b38";
22+
const owner = name;
23+
const repo = name;
24+
const tag = `v${version}`;
25+
return std.download.fromGithub({
26+
checksum,
27+
owner,
28+
repo,
29+
source: "tag",
30+
tag,
31+
});
3232
};
3333

3434
export type Arg = {
35-
env?: std.env.Arg;
36-
host?: string;
37-
nodejs?: node.Arg;
38-
source?: tg.Directory;
35+
env?: std.env.Arg;
36+
host?: string;
37+
nodejs?: node.Arg;
38+
source?: tg.Directory;
3939
};
4040

4141
export const build = async (...args: std.Args<Arg>) => {
42-
const {
43-
nodejs = {},
44-
source: source_,
45-
...rest
46-
} = await std.packages.applyArgs<Arg>(...args);
47-
48-
// Build the binaries provided by eslint.
49-
return node.build(
50-
{
51-
...rest,
52-
packageLock,
53-
source: source_ ?? source(),
54-
},
55-
nodejs,
56-
);
42+
const { nodejs = {}, source: source_, ...rest } =
43+
await std.packages.applyArgs<Arg>(...args);
44+
45+
// Build the binaries provided by eslint.
46+
return node.build(
47+
{
48+
...rest,
49+
packageLock,
50+
source: source_ ?? source(),
51+
},
52+
nodejs,
53+
);
5754
};
5855

5956
export default build;
6057

6158
export const test = async () => {
62-
const spec = std.assert.defaultSpec(metadata);
63-
return await std.assert.pkg(build, spec);
59+
const spec = std.assert.defaultSpec(metadata);
60+
return await std.assert.pkg(build, spec);
6461
};

0 commit comments

Comments
 (0)