Skip to content

Commit 23cfec9

Browse files
authored
test against the system’s opinion of its host (#11)
Refs denoland/node_shims#152
1 parent 9946461 commit 23cfec9

14 files changed

Lines changed: 85 additions & 47 deletions

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
strategy:
1919
matrix:
2020
os:
21-
- ubuntu-latest
2221
- macos-latest
22+
- ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v3
2525
- uses: teaxyz/setup@v0
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
path-to-lcov: cov_profile.lcov
3333
parallel: true
34-
flag-name: ${{ matrix.os }}
34+
flag-name: ${{ matrix.platform.id }}
3535

3636
upload-coverage:
3737
needs: tests
@@ -42,7 +42,15 @@ jobs:
4242
parallel-finished: true
4343

4444
dnt:
45-
runs-on: ubuntu-latest
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os:
50+
- [self-hosted, macOS, X64]
51+
- [self-hosted, linux, X64]
52+
- [self-hosted, macOS, ARM64]
53+
- [self-hosted, linux, ARM64]
4654
steps:
4755
- uses: actions/checkout@v3
4856
- uses: teaxyz/setup@v0

src/hooks/useCellar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import SemVer, * as semver from "../utils/semver.ts"
2-
import { useTestConfig } from "./useConfig.test.ts"
2+
import { useTestConfig } from "./useTestConfig.ts"
33
import install from "../prefab/install.ts"
44
import useCellar from "./useCellar.ts"
55

src/hooks/useConfig.test.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { assert, assertEquals, assertFalse, assertThrows } from "deno/testing/asserts.ts"
2-
import useConfig, { _internals } from "./useConfig.ts"
2+
import { _internals, ConfigDefault } from "./useConfig.ts"
3+
import { useTestConfig } from "./useTestConfig.ts"
4+
import Path from "../utils/Path.ts"
35

46
Deno.test("useConfig", () => {
57
let config = useTestConfig()
@@ -30,19 +32,3 @@ Deno.test("useConfig empty TEA_PANTRY_PATH is ignored", () => {
3032
assertEquals(ConfigDefault({ TEA_PANTRY_PATH: "" }).pantries, [])
3133
assertEquals(ConfigDefault({ TEA_PANTRY_PATH: " : :" }).pantries, [])
3234
})
33-
34-
import { ConfigDefault } from "./useConfig.ts"
35-
import Path from "../utils/Path.ts"
36-
37-
export function useTestConfig(env?: Record<string, string>) {
38-
env ??= {}
39-
40-
/// always prefer a new prefix
41-
env.TEA_PREFIX ??= Path.mktemp().string
42-
43-
/// reuse these unless the test overrides them to speed up testing
44-
env.TEA_CACHE_DIR ??= Path.home().join(".tea/tea.xyz/var/www").string
45-
env.TEA_PANTRY_PATH ??= Path.home().join(".tea/tea.xyz/var/pantry").string
46-
47-
return useConfig(ConfigDefault(env))
48-
}

src/hooks/useDownload.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTestConfig } from "./useConfig.test.ts"
1+
import { useTestConfig } from "./useTestConfig.ts"
22
import { assert } from "deno/testing/asserts.ts"
33
import useDownload from "./useDownload.ts"
44

src/hooks/useMoustaches.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assertEquals } from "deno/testing/asserts.ts"
2-
import { useTestConfig } from "./useConfig.test.ts"
2+
import { useTestConfig } from "./useTestConfig.ts"
33
import useMoustaches from "./useMoustaches.ts"
44
import { Package } from "../types.ts"
55
import SemVer from "../utils/semver.ts"

src/hooks/usePantry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert, assertEquals } from "deno/testing/asserts.ts"
2-
import usePantry from './usePantry.ts'
32
import { _internals } from "../utils/host.ts"
43
import { stub } from "deno/testing/mock.ts"
4+
import usePantry from "./usePantry.ts"
55

66
Deno.test("provides()", async () => {
77
const exenames = await usePantry().project("python.org").provides()

src/hooks/useShellEnv.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1+
import { useTestConfig } from "./useTestConfig.ts"
2+
import { execSync } from "node:child_process"
13
import * as semver from "../utils/semver.ts"
24
import useShellEnv from "./useShellEnv.ts"
35
import hydrate from "../prefab/hydrate.ts"
46
import resolve from "../prefab/resolve.ts"
5-
import { useTestConfig } from "./useConfig.test.ts"
67
import install from "../prefab/install.ts"
78

89
Deno.test("useShellEnv", async () => {
9-
10+
const { map, flatten } = useShellEnv()
1011
useTestConfig()
1112

1213
const rv1 = await hydrate({ project: "python.org", constraint: new semver.Range("^3.11") })
13-
const rv2 = await resolve(rv1.wet)
14+
const rv2 = await resolve(rv1.pkgs)
1415

1516
const installations = rv2.installed
1617
for (const pkg of rv2.pending) {
1718
const installed = await install(pkg)
1819
installations.push(installed)
1920
}
2021

21-
await useShellEnv().map({ installations })
22+
const env = await map({ installations })
23+
24+
// test that we installed the correct platform binaries
25+
// ※ https://github.com/teaxyz/lib/pull/11/checks
26+
execSync("python --version", { env: flatten(env) })
27+
//NOTE ^^ using execSync rather than Deno.run as the shim doesn’t behave consistently between deno and node
2228
})

src/hooks/useSync.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTestConfig } from "./useConfig.test.ts"
1+
import { useTestConfig } from "./useTestConfig.ts"
22
import { assert } from "deno/testing/asserts.ts"
33
import usePantry from "./usePantry.ts"
44
import useSync from "./useSync.ts"

src/hooks/useTestConfig.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import useConfig, { ConfigDefault } from "./useConfig.ts"
2+
import Path from "../utils/Path.ts"
3+
4+
export function useTestConfig(env?: Record<string, string>) {
5+
env ??= {}
6+
7+
/// always prefer a new prefix
8+
env.TEA_PREFIX ??= Path.mktemp().string
9+
10+
/// reuse these unless the test overrides them to speed up testing
11+
env.TEA_CACHE_DIR ??= Path.home().join(".tea/tea.xyz/var/www").string
12+
env.TEA_PANTRY_PATH ??= Path.home().join(".tea/tea.xyz/var/pantry").string
13+
14+
return useConfig(ConfigDefault(env))
15+
}

src/prefab/install.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTestConfig as useTestConfigBase } from "../hooks/useConfig.test.ts"
1+
import { useTestConfig as useTestConfigBase } from "../hooks/useTestConfig.ts"
22
import { assert, assertEquals, assertFalse } from "deno/testing/asserts.ts"
33
import install, { ConsoleLogger, Logger } from "./install.ts"
44
import { stub } from "deno/testing/mock.ts"

0 commit comments

Comments
 (0)