|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +const { join, resolve } = require("path"); |
| 4 | +const { execSync, spawn } = require("child_process"); |
| 5 | + |
| 6 | +const ROOT = resolve(join(__dirname, "..", "..")); |
| 7 | +const FEATURES_FOLDER = join(ROOT, "features"); |
| 8 | +const ROOT_BIN = join(ROOT, "node_modules", ".bin"); |
| 9 | + |
| 10 | +const execOptions = { |
| 11 | + ...process, |
| 12 | + cwd: __dirname, |
| 13 | + encoding: "utf-8", |
| 14 | +}; |
| 15 | + |
| 16 | +const allTags = execSync(`grep -h ^@ ${join(FEATURES_FOLDER, "**", "*.feature")}`, execOptions).split(/[\n ]/g); |
| 17 | + |
| 18 | +console.info(`Looking for changed clients that has the legacy integration test tag: ${allTags}`); |
| 19 | + |
| 20 | +const changedPackages = execSync(`${join(ROOT_BIN, "lerna")} changed`, execOptions).split("\n"); |
| 21 | +const changedPackageTags = changedPackages |
| 22 | + .map((name) => name.replace("@aws-sdk/client-", "")) |
| 23 | + .map((name) => name.replace("-")) |
| 24 | + .map((name) => `@${name}`); |
| 25 | + |
| 26 | +const tagsToTest = changedPackageTags.filter((tag) => allTags.includes(tag)); |
| 27 | + |
| 28 | +// Cucumber requires cwd to contain the test cases. |
| 29 | +const command = `${join("node_modules", ".bin", "cucumber-js")}`; |
| 30 | +const args = ["--fail-fast", "-t", `"${tagsToTest.join(" or ")}"`]; |
| 31 | +console.info(`Running cucumber test: \n${command} ${args.join(" ")}`); |
| 32 | + |
| 33 | +const cucumber = spawn(command, args, { ...execOptions, cwd: ROOT, shell: true }); |
| 34 | +cucumber.stdout.pipe(process.stdout); |
| 35 | +cucumber.stderr.pipe(process.stderr); |
| 36 | +cucumber.on("close", (code) => { |
| 37 | + if (code === 0) process.exit(); |
| 38 | + else process.exit(code); |
| 39 | +}); |
0 commit comments