Skip to content

Commit

Permalink
Fix tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Apr 13, 2023
1 parent 07b9034 commit 9cc39ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions tests/integration.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type RunOptions = ({
}) & {
env?: Record<string, string>
throws?: boolean
sync?: boolean
}

interface Enhancements {
Expand Down Expand Up @@ -63,7 +64,8 @@ const suite = describe({
const teafile = bin.join('tea')
const { sandbox } = this

this.run = ({env, throws, ...opts}: RunOptions) => {
this.run = ({env, throws, sync, ...opts}: RunOptions) => {
sync ??= true
env ??= {}
for (const key of ['HOME', 'CI', 'RUNNER_DEBUG', 'GITHUB_ACTIONS']) {
const value = Deno.env.get(key)
Expand All @@ -83,19 +85,23 @@ const suite = describe({
? [...opts.args]
: [...opts.cmd]

// be faster when testing locally

//TODO we typically don’t want silent, we just want ERRORS-ONLY
if ("args" in opts) {
if (!existing_tea_prefix) {
if (!existing_tea_prefix && sync) {
cmd.unshift("--sync")
}
cmd.unshift(teafile.string)
} else if (cmd[0] != 'tea') {
// we need to do an initial --sync
const proc = Deno.run({ cmd: [teafile.string, '-Ss'], cwd: sandbox.string, env, clearEnv: true })
const arg = sync ? "-Ss" : "-s"
const proc = Deno.run({ cmd: [teafile.string, arg], cwd: sandbox.string, env, clearEnv: true })
assertEquals((await proc.status()).code, 0)
proc.close()
}

console.log(cmd, env)

const proc = Deno.run({ cmd, cwd: sandbox.string, stdout, stderr, env, clearEnv: true})
try {
const status = await proc.status()
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/package.yml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ it(suite, "runtime.env tildes", async function() {
echo "$FOO"
`, force: true}).chmod(0o755)

console.log(this.sandbox, this.sandbox.isDirectory())

const out = await this.run({
args: ["foo"],
env: {
TEA_PANTRY_PATH: this.sandbox.string,
TEA_PREFIX: this.sandbox.string
}
},
sync: false
}).stdout()

assertEquals(out.trim(), FOO.replaceAll("{{home}}", Path.home().string))
Expand Down

0 comments on commit 9cc39ce

Please sign in to comment.