From a32cd0e80ad80439f68f435fd49e28939efbc48f Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 31 Aug 2022 17:44:34 -0400 Subject: [PATCH] more-tests (#106) --- .github/workflows/ci.yml | 5 ---- .../freedesktop.org/pkg-config/package.yml | 25 +++++++++++++------ projects/ijg.org/package.yml | 9 ++++++- scripts/test.ts | 23 +++++++++++++++-- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3af2294f..432ac5e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,6 @@ name: ci on: pull_request -# concurrency: -# #TODO group: ${{ github.ref }} -# group: only-one-due-to-versions.txt-generation-requiring-serial-ness -# cancel-in-progress: true - jobs: get-diff: runs-on: ubuntu-latest diff --git a/projects/freedesktop.org/pkg-config/package.yml b/projects/freedesktop.org/pkg-config/package.yml index cc428476..16945c4a 100644 --- a/projects/freedesktop.org/pkg-config/package.yml +++ b/projects/freedesktop.org/pkg-config/package.yml @@ -5,6 +5,13 @@ distributable: provides: - bin/pkg-config +#NOTE that macOS provides some `.pc` files in /usr/lib/pkgconfig +# we don’t explicitly include them. This should be safe since we set +# PKG_CONFIG_PATH and that is checked first. But it could lead to issues +# for users in some circumstances. +#FIXME probably we should exclude this in the pursuit of reliable, cross +# platform environments. + versions: github: freedesktop/pkg-config/tags strip: /^pkg-config-/ @@ -14,14 +21,16 @@ build: tea.xyz/gx/cc: c99 tea.xyz/gx/make: '*' script: |- - ./configure \ - --prefix="{{ prefix }}" \ - --disable-debug \ - --disable-host-tool \ - --with-internal-glib \ - --with-pc-path=/usr/lib/pkgconfig #FIXME - make --jobs {{ hw.concurrency }} - make install + ./configure $ARGS + make --jobs {{ hw.concurrency }} install + env: + ARGS: + - --prefix="{{ prefix }}" + - --disable-debug + - --disable-host-tool + - --with-internal-glib + # otherwise the defaults are based on our {{prefix}} + - --with-pc-path=/usr/lib/pkgconfig:/usr/share/pkgconfig test: script: pkg-config --version diff --git a/projects/ijg.org/package.yml b/projects/ijg.org/package.yml index 60f296af..4d178ad7 100644 --- a/projects/ijg.org/package.yml +++ b/projects/ijg.org/package.yml @@ -20,4 +20,11 @@ build: --prefix="{{ prefix }}" make --jobs {{ hw.concurrency }} install -test: true #FIXME +test: + dependencies: + curl.se: '*' + env: + FIXTURE: https://samplelib.com/lib/preview/jpeg/sample-clouds-400x300.jpg + script: | + curl $FIXTURE > test.jpeg + djpeg test.jpeg diff --git a/scripts/test.ts b/scripts/test.ts index 3a58ed57..0a2c54f1 100755 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -7,7 +7,7 @@ args: - --allow-net - --allow-run - --allow-read - - --allow-write=/opt/tea.xyz/tmp + - --allow-write - --allow-env - --import-map={{ srcroot }}/import-map.json ---*/ @@ -19,16 +19,20 @@ import { run, undent, isPlainObject } from "utils" import { validatePackageRequirement } from "utils/lvl2.ts" import useFlags from "hooks/useFlags.ts" import useCellar from "hooks/useCellar.ts" +import resolve from "prefab/resolve.ts" +import install from "prefab/install.ts" import hydrate from "prefab/hydrate.ts" +import { lvl1 as link } from "prefab/link.ts" const { debug } = useFlags() +const cellar = useCellar() //TODO install any other deps const pantry = usePantry() const pkg = await (async () => { if (Deno.args[1] == "--magic") { - const i = await useCellar().resolve(parsePackageRequirement(Deno.args[0])) + const i = await cellar.resolve(parsePackageRequirement(Deno.args[0])) return i.pkg } else { return parsePackage(Deno.args[0]) @@ -42,6 +46,8 @@ const self = { const [yml] = await pantry.getYAML(pkg) const deps: PackageRequirement[] = [self, ...await get_deps()] +await install_if_needed(deps) + const env = await useShellEnv(deps) let text = undent` @@ -98,3 +104,16 @@ async function get_deps() { } } } + +async function install_if_needed(deps: PackageRequirement[]) { + const needed: PackageRequirement[] = [] + for await (const rq of deps) { + if (await cellar.isInstalled(rq)) continue + needed.push(rq) + } + const wet = await resolve(needed) + for (const pkg of wet) { + const installation = install(pkg) + await link(installation) + } +}