Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync the branch feature/modular/lro/v3 to main #2473

Merged
merged 25 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
"runtimeArgs": [
"node",
"./test/commands/gen-cadl-ranch.js",
"--tag=rlc",
"--debug"
"--tag=modular"
],
"runtimeExecutable": "npx",
"skipFiles": ["<node_internals>/**"],
Expand Down
16 changes: 14 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions packages/autorest.typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "6.0.22",
"scripts": {
"build": "tsc -p . && npm run copyFiles",
"build:test:browser": "tsc -p tsconfig.browser-test.json && webpack --config webpack.config.test.js",
"build:test:browser:rlc": "tsc -p tsconfig.browser-test.json && ts-node test/commands/prepare-deps.ts --browser && webpack --config webpack.config.test.js --env mode=rlc",
"build:test:browser": "tsc -p tsconfig.browser-test.json && ts-node test/commands/prepare-deps.ts --removal && webpack --config webpack.config.test.js --env mode=hlc",
"check:tree": "ts-node ./test/commands/check-clean-tree.ts",
"pack": "npm pack 2>&1",
"clean": "rimraf --glob test-browser test/**/node_modules",
Expand All @@ -12,7 +13,7 @@
"test:node": "npm run unit-test && npm run start-test-server:v2 & npm run integration-test:alone & npm run rlc-integration-test:alone & npm run test-version-tolerance & npm run stop-test-server",
"test:node:alone": "npm run unit-test && npm run integration-test:alone && npm run rlc-integration-test:alone && npm run test-version-tolerance",
"test:browser": "npm run start-test-server:v2 & npm run integration-test:browser & npm run rlc-integration-test:browser & npm run test-version-tolerance & npm run stop-test-server",
"test:browser:alone": "npm run integration-test:browser && npm run rlc-integration-test:browser && npm run test-version-tolerance",
"test:browser:alone": "npm run integration-test:browser && npm run rlc-integration-test:browser && npm run test-version-tolerance",
"rlc-test:node": "npm run unit-test && npm run start-test-server:v2 & npm run rlc-integration-test:alone && npm run stop-test-server",
"rlc-test:browser": "npm run start-test-server:v2 & npm run rlc-integration-test:browser && npm run stop-test-server",
"unit-test": "mocha -r ts-node/register \"./test/unit/**/*spec.ts\"",
Expand All @@ -23,9 +24,9 @@
"integration-test:alone": "mocha -r ts-node/register --timeout 2000 \"./test/integration/**/!(sampleTest).spec.ts\"",
"rlc-integration-test": "npm run start-test-server:v2 & npm run rlc-generate-and-test && npm run stop-test-server",
"rlc-integration-test:new": "npm-run-all start-test-server rlc-generate-and-test rlc-integration-test:alone stop-test-server",
"rlc-integration-test:browser": "npm run build:test:browser && karma start karma.conf.js",
"rlc-integration-test:browser": "npm run build:test:browser:rlc && karma start karma.conf.js",
"rlc-generate-and-test": "npm-run-all -s build rlc-generate-swaggers rlc-integration-test:alone rlc-integration-test:browser",
"rlc-integration-test:alone": "mocha -r ts-node/register --timeout 2000 \"./test/rlcIntegration/**/!(sampleTest).spec.ts\"",
"rlc-integration-test:alone": "ts-node test/commands/prepare-deps.ts && mocha -r ts-node/register --timeout 2000 \"./test/rlcIntegration/!(sampleTest).spec.ts\"",
"start-test-server": "ts-node test/commands/start-server.ts",
"start-test-server:v2": "autorest-testserver run --appendCoverage",
"stop-test-server": "autorest-testserver stop",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function transformPaths(model: CodeModel): Paths {
lroDetails: {
isLongRunning: isLongRunningOperation(operation)
},
isPageable: isPagingOperation(operation)
isPaging: isPagingOperation(operation)
}
};

Expand Down
10 changes: 10 additions & 0 deletions packages/autorest.typescript/test/commands/browser.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"browser": {
"./utils/stream-helpers.js": "./utils/stream-helpers.browser.js",
"./utils/fileSystem.js": "./utils/fileSystem.browser.js",
"./utils/path.js": "./utils/path.browser.js"
},
"dependencies": {
"@azure/core-lro": "3.0.0-beta.1"
}
}
85 changes: 85 additions & 0 deletions packages/autorest.typescript/test/commands/prepare-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { spawn } from "child_process";
import { existsSync } from "fs";
import { join } from "path";

async function main() {
const isBrowserTest = process.argv.includes("--browser");
const isRemoval = process.argv.includes("--removal");
if (isBrowserTest) {
await copyPackageJson();
await installDependencies(join(`${__dirname}`, "..", "..", "test-browser"));
} else if (isRemoval) {
await removeFiles([
join(`${__dirname}`, "..", "..", "test-browser", "package.json"),
join(`${__dirname}`, "..", "..", "test-browser", "node_modules")
]);
} else {
await installDependencies(
join(`${__dirname}`, "..", "..", "test", "rlcIntegration")
);
}
}

async function removeFiles(files: string[]) {
const existing = files.filter((file) => existsSync(file));
if (existing.length === 0) {
console.log("No dependencies to remove");
return;
}
runCommand("rm", ["-rf", ...existing]);
console.log("Removed dependencies for hlc browser tests", existing);
}

async function copyPackageJson() {
const srcPath = join(
`${__dirname}`,
"..",
"..",
"test",
"commands",
"browser.package.json"
);
const destPath = join(
`${__dirname}`,
"..",
"..",
"test-browser",
"package.json"
);
await runCommand("cp", [srcPath, destPath]);
}

async function installDependencies(path: string) {
await runCommand(
`npm${/^win/.test(process.platform) ? ".cmd" : ""}`,
["install"],
path
);
console.log("Installed dependencies for rlc browser tests", path);
}

async function runCommand(command: string, args: string[] = [], cwd = ".") {
return new Promise((resolve, reject) => {
const process = spawn(command, args, { cwd, shell: true });

let stdout = "";
let stderr = "";

process.stdout.on("data", (data) => (stdout += data.toString()));
process.stderr.on("data", (data) => (stderr += data.toString()));

process.on("close", () => {
resolve(stdout ?? stderr);
});

process.on("error", (error: any) => {
console.log(stdout, stderr, error);
reject(new Error(error));
});
});
}

main().catch((error) => {
console.error(error);
process.exit(-1);
});
2 changes: 1 addition & 1 deletion packages/autorest.typescript/test/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ export async function runAutorest(
console.error(error);
throw error;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1290,4 +1290,4 @@ const run = async () => {
run().catch(error => {
console.error(error);
process.exit(-1000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@azure/core-rest-pipeline": "^1.5.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.6.2",
"@azure/core-lro": "^2.5.4",
"@azure/abort-controller": "^1.0.0",
"@azure/core-lro": "3.0.0-beta.1",
"@azure/abort-controller": "^2.0.0",
"@azure/core-paging": "^1.5.0"
},
"devDependencies": {
Expand Down
Loading
Loading