-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Node.js v20 and npm v9 support alongside end-to-end tests
Create a basic end-to-end test suite (that is a suite that invokes the CLI just like users would) and use it to initiate support for Node.js v20 and v9 of the npm CLI. To ensure the support the end-to-end tests are ran continuously against all combinations of supported versions of Node.js and npm. Signed-off-by: Eric Cornelissen <[email protected]>
- Loading branch information
1 parent
ea3d538
commit 512405d
Showing
13 changed files
with
2,439 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright (C) 2024 Eric Cornelissen | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published | ||
// by the Free Software Foundation, version 3 of the License only. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import * as assert from "node:assert/strict"; | ||
import * as cp from "node:child_process"; | ||
import * as fs from "node:fs"; | ||
import * as path from "node:path"; | ||
import * as process from "node:process"; | ||
import { test } from "node:test"; | ||
import * as url from "node:url"; | ||
|
||
const root = path.resolve( | ||
path.dirname(url.fileURLToPath(new URL(import.meta.url))), | ||
"..", | ||
); | ||
|
||
test("end-to-end", async (t) => { | ||
await t.test("help", () => { | ||
const result = cli({ | ||
args: ["--help"], | ||
project: project("example"), | ||
}); | ||
|
||
assert.equal(result.exitCode, 0); | ||
assert.notEqual(result.stdout, ""); | ||
assert.equal(result.stderr, ""); | ||
}); | ||
|
||
await t.test("basic example without unexpected error", () => { | ||
const result = cli({ | ||
project: project("example"), | ||
}); | ||
|
||
assert.notEqual(result.exitCode, 2); | ||
}); | ||
|
||
await t.test("ignoring all deprecation warnings with --errors-only", () => { | ||
const result = cli({ | ||
args: ["--errors-only"], | ||
project: project("ignore-all"), | ||
}); | ||
|
||
assert.equal(result.exitCode, 0); | ||
assert.equal(result.stdout, ""); | ||
assert.equal(result.stderr, ""); | ||
}); | ||
}); | ||
|
||
function project(name) { | ||
return path.join(root, "test", "fixtures", name); | ||
} | ||
|
||
function cli({ args, project }) { | ||
// Ensure the project to test exists. | ||
assert.doesNotThrow(() => fs.accessSync(project), `${project} not found`); | ||
|
||
// Run the command. | ||
const result = cp.spawnSync( | ||
process.argv[0], | ||
[ | ||
path.join(root, "bin", "cli.js"), | ||
|
||
// Provide test-specified CLI arguments, if any. | ||
...(args || []), | ||
], | ||
{ | ||
// Run depreman in the test-specified directory. | ||
cwd: project, | ||
|
||
// Get output as text instead of a buffer. | ||
encoding: "utf-8", | ||
}, | ||
); | ||
|
||
// Ensure running the command did not fail. | ||
assert.equal(result.error, undefined); | ||
|
||
return { | ||
exitCode: result.status, | ||
stdout: result.stdout, | ||
stderr: result.stderr, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
Oops, something went wrong.