version = 0.1 extensions = ['chomp@0.1:assert', 'chomp@0.1:npm'] default-task = 'test' [env] VAL = 'C' [env-default] DEFAULT = '${{ VAL }}H' [[task]] name = 'test' serial = true deps = ['test:clean', 'test:run'] [[task]] name = 'test:clean' display = 'status-only' stdio = 'none' validation = 'none' run = 'rm -r output' [[task]] name = 'test:run' display = 'none' deps = [':test[0-9]*'] # -- Test -- [[task]] name = 'test1' display = 'none' run = '../target/debug/chomp output/test1.txt' [[task]] name = 'test-chomp-path-arg' display = 'none' target = 'output/test1.txt' run = 'echo "Chomp Chomp" > $TARGET' template = 'assert' [task.template-options] expect-equals = 'Chomp Chomp' # -- Test -- [[task]] name = 'test2' display = 'none' target = 'output/test2.txt' run = ''' ${{ECHO}} "$VAR $ANOTHER" > $TARGET ''' template = 'assert' [task.env] VAR = 'Chomp ${{ DEFAULT }}' ECHO = 'echo' [task.env-default] ANOTHER = '${{VAR}} ${{UNKNOWN}} ${{ VAR }} ${{--INVALID--}} $NOREPLACE ${{ DEFAULT }}' [task.template-options] expect-equals = 'Chomp CH Chomp CH Chomp CH $NOREPLACE CH' # -- Test -- [[task]] name = 'test3' display = 'none' target = 'output/test3.js' deps = ['fixtures/app.js', 'install:swc'] engine = 'node' run = ''' import swc from '@swc/core'; import { readFileSync, writeFileSync } from 'fs'; import { basename } from 'path'; const input = readFileSync(process.env.DEP, 'utf8'); const { code, map } = await swc.transform(input, { filename: process.env.DEP, sourceMaps: true, jsc: { parser: { syntax: "typescript", }, transform: {}, }, }); writeFileSync(process.env.TARGET, code + '\n//# sourceMappingURL=' + basename(process.env.TARGET) + '.map'); writeFileSync(process.env.TARGET + '.map', JSON.stringify(map)); ''' template = 'assert' [task.template-options] expect-equals = '''export var p = 5; //# sourceMappingURL=test3.js.map ''' [[task]] name = 'install:swc' display = 'none' template = 'npm' [task.template-options] packages = ['@swc/core', '@swc/cli'] auto-install = true # -- Test -- [[task]] name = 'test4' display = 'none' targets = ['./output/unittest.txt'] deps = [':unittest:ok-*'] template = 'assert' [task.template-options] expect-equals = '''UNIT OK ''' [[task]] target = 'output' validation = 'targets-only' run = 'mkdir output' [[task]] name = 'unittest:#' display = 'none' stdio = 'stderr-only' deps = ['./unit/#.mjs', 'output'] run = 'node $DEP' [task.template-options] expect-equals = '''UNIT OK ''' # -- Test -- [[task]] name = 'test5' stdio = 'none' display = 'none' deps = ['./output/lib/**/*.js', 'install:rollup'] target = 'output/dist/app.js' run = 'rollup output/lib/app.js -d output/dist -m' template = 'assert' [task.template-options] expect-equals = '''var dep = "dep"; console.log(dep); var p = 5; export { p }; //# sourceMappingURL=app.js.map ''' [[task]] name = 'install:rollup' display = 'none' template = 'npm' [task.template-options] packages = ['rollup'] auto-install = true [[task]] name = 'build:swc' display = 'none' stdio = 'stderr-only' target = './output/lib/##.js' deps = ['./fixtures/src/##.ts', 'install:swc'] run = 'swc $DEP -o $TARGET --source-maps' # -- Test -- [[task]] name = 'test6' target = './output/deps.txt' deps = ['./fixtures/src/**/*.ts', 'build:swc'] run = 'echo "$DEPS" > output/deps.txt' template = 'assert' [task.template-options] expect-pattern = 'fixtures/src/app.ts:fixtures/src/dep.ts:output/lib/app.js:output/lib/dep.js' # -- Test -- [[task]] name = 'test7' validation = 'not-ok' run = ''' FAIL echo "THIS SHOULD NOT LOG" '''