Skip to content

Commit

Permalink
[Azure Monitor OpenTelemetry Exporter] Remove execa in tests (Azure#2…
Browse files Browse the repository at this point in the history
…2323)

* Remove execa in tests

* format
  • Loading branch information
hectorhdzg authored Jun 22, 2022
1 parent d40a82e commit 92696d3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 47 deletions.
3 changes: 1 addition & 2 deletions sdk/monitor/monitor-opentelemetry-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"integration-test:node": "npm run functional-test",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"report": "nyc report --reporter=json",
"test-opentelemetry-versions": "node test-opentelemetry-versions.mjs 2>&1",
"test-opentelemetry-versions": "node test-opentelemetry-versions.js 2>&1",
"prepare": "npm run build",
"pack": "npm pack 2>&1"
},
Expand Down Expand Up @@ -94,7 +94,6 @@
"dotenv": "^8.2.0",
"eslint": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"execa": "^6.0.0",
"mocha": "^7.1.1",
"nock": "^12.0.3",
"nyc": "^15.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const packageJson = require("./package.json");
const { exec } = require("child_process");

const versions = ["latest"];

const packages = [
...Object.keys(packageJson.dependencies).filter((packg) => packg.startsWith("@opentelemetry")),
...Object.keys(packageJson.devDependencies).filter((packg) => packg.startsWith("@opentelemetry")),
];

function runProcess(cmd, callback) {
var command = exec(cmd, (err, stdout, stderr) => {
if (err) {
console.log(`err: ${err}`);
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
command.on("exit", function () {
callback();
});
}

(async () => {
try {
console.log("Running opentelemetry version test against", versions);
for (const version of versions) {
// Note: this moves devDeps to dependencies, but it does not matter for these tests
const packagesToInstall = packages.map((packg) => `${packg}@${version}`).join(" ");
console.log(`Installing ${packagesToInstall}`);
runProcess(
`npm install --no-save --prefix ./test-opentelemetry-versions ${packagesToInstall}`,
() => {
console.log(`Compiling on version: ${version}`);
runProcess(`npm run build`, () => {
console.log(`Running tests on version: ${version}`);
runProcess(`npm run test`, () => {
process.exit(0);
});
});
}
);
}
} catch (error) {
console.log("Opentelemetry version test failed!");
console.log(error);
process.exit(1);
}
})();

This file was deleted.

0 comments on commit 92696d3

Please sign in to comment.