77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const assert = require("assert");
|
|
const cp = require("child_process");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const extension = require("../vscode-extension/extension");
|
|
|
|
const repo = path.resolve(__dirname, "..");
|
|
const project = path.join(repo, "examples/launch-build-demo");
|
|
const source = fs.readFileSync(path.join(project, "src/build.rs"), "utf8");
|
|
const forbiddenSourceAssumptions =
|
|
/\b(?:std::fs|std::process|Command::new|git|podman|docker|localhost|127\.0\.0\.1)|\/home\/|\/Users\/|C:\\Users\\/i;
|
|
|
|
const envs = extension.discoverEnvironmentNames(project);
|
|
assert.deepStrictEqual(envs, ["linux", "windows"]);
|
|
assert.deepStrictEqual(extension.diagnoseEnvReferences(source, envs), []);
|
|
assert.doesNotMatch(
|
|
source,
|
|
forbiddenSourceAssumptions,
|
|
"flagship build source must not rely on coordinator-side filesystem, Git, shell, container, or machine-local assumptions"
|
|
);
|
|
|
|
const inspection = JSON.parse(
|
|
cp.execFileSync(
|
|
"cargo",
|
|
[
|
|
"run",
|
|
"-q",
|
|
"-p",
|
|
"disasmer-cli",
|
|
"--bin",
|
|
"disasmer",
|
|
"--",
|
|
"bundle",
|
|
"inspect",
|
|
"--project",
|
|
project,
|
|
"--json"
|
|
],
|
|
{ cwd: repo, encoding: "utf8" }
|
|
)
|
|
);
|
|
|
|
assert.strictEqual(inspection.project, project);
|
|
assert.strictEqual(
|
|
inspection.source_provider_manifest.coordinator_requires_checkout_access,
|
|
false
|
|
);
|
|
assert.strictEqual(
|
|
inspection.source_provider_manifest.transfer_policy.local_source_bytes_remain_node_local,
|
|
true
|
|
);
|
|
assert.strictEqual(
|
|
inspection.source_provider_manifest.transfer_policy.coordinator_receives_source_bytes_by_default,
|
|
false
|
|
);
|
|
assert.strictEqual(
|
|
inspection.source_provider_manifest.transfer_policy.default_full_repo_tarball,
|
|
false
|
|
);
|
|
assert.deepStrictEqual(
|
|
inspection.source_provider_manifest.transfer_policy.allowed_remote_transfer.sort(),
|
|
["ExplicitSnapshotChunks", "RequiredContent"]
|
|
);
|
|
assert.strictEqual(inspection.metadata.embeds_full_container_images, false);
|
|
assert(inspection.metadata.environments.some((env) => env.name === "linux"));
|
|
assert(inspection.metadata.environments.some((env) => env.name === "windows"));
|
|
assert(inspection.metadata.selected_inputs.some((input) => input.path === "src/build.rs"));
|
|
|
|
cp.execFileSync("cargo", ["test", "-p", "launch-build-demo"], {
|
|
cwd: repo,
|
|
stdio: "inherit"
|
|
});
|
|
|
|
console.log("Flagship demo smoke passed");
|