add more pkg tests (#102)

* more-tests pt.1

* useCellar() is overkill here.

Co-authored-by: Jacob Heider <jacob@tea.xyz>
This commit is contained in:
Max Howell 2022-08-31 15:39:16 -04:00
parent 39ee1d6721
commit c12d64828e
4 changed files with 14 additions and 7 deletions

View file

@ -48,7 +48,7 @@ knowledge. Please keep it tidy.
| Project | Version |
|-------------|---------|
| deno.land | ^1.18 |
| deno.land | ^1.23 |
| tea.xyz | ^0 |
## Build All

5
scripts/README.md Normal file
View file

@ -0,0 +1,5 @@
# build all
```sh
scripts/ls.ts | xargs scripts/sort.ts | xargs scripts/build.ts
```

View file

@ -19,6 +19,7 @@ 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 hydrate from "prefab/hydrate.ts"
const { debug } = useFlags()
@ -39,7 +40,7 @@ const self = {
constraint: new semver.Range(pkg.version.toString())
}
const [yml] = await pantry.getYAML(pkg)
const deps: PackageRequirement[] = [self, ...get_deps()]
const deps: PackageRequirement[] = [self, ...await get_deps()]
const env = await useShellEnv(deps)
@ -83,11 +84,11 @@ try {
if (!debug) tmp.rm({ recursive: true })
}
function get_deps() {
async function get_deps() {
const rv: PackageRequirement[] = []
attempt(yml.dependencies)
attempt(yml.test.dependencies)
return rv
return await hydrate(rv)
function attempt(obj: PlainObject) {
if (isPlainObject(obj))

View file

@ -14,7 +14,6 @@ args:
import { S3 } from "s3"
import { PackageRequirement, Path } from "types"
import useCache from "hooks/useCache.ts"
import useCellar from "hooks/useCellar.ts"
import { Package, parsePackageRequirement, SemVer, semver } from "types"
import useFlags from "hooks/useFlags.ts"
@ -29,7 +28,6 @@ const s3 = new S3({
})
const bucket = s3.getBucket(Deno.env.get("AWS_S3")!)
const cellar = useCellar()
const encode = (() => { const e = new TextEncoder(); return e.encode.bind(e) })()
@ -59,7 +57,10 @@ if (bottles.size !== checksums.size || ![...bottles].every(b => checksums.has(`$
}
for (const rq of bottles) {
const {pkg} = await cellar.resolve(rq)
// Packages should be a fixed version, so this should be fine:
const version = semver.parse(rq.constraint.raw)
if (!version) { throw new Error(`Incomplete package version: ${rq.constraint.raw}`)}
const pkg = { project: rq.project, version }
const key = useCache().s3Key(pkg)
const bottle = useCache().bottle(pkg)
const checksum = new Path(`${bottle.string}.sha256sum`)