-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test, feat: link minimum version to tests using pipes
- Loading branch information
1 parent
127bb1e
commit 5ea6756
Showing
6 changed files
with
74 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Link certain concepts to the version they have been introduced in R | ||
* | ||
* @module | ||
*/ | ||
|
||
export const MIN_VERSION_PIPE = "4.1.0" |
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,22 @@ | ||
import { RShell } from '../../src/r-bridge' | ||
import semver from 'semver/preload' | ||
import { MIN_VERSION_PIPE } from '../../src/r-bridge/lang-4.x/ast/model/versions' | ||
|
||
/** | ||
* Automatically skip a test if it does not satisfy the given version pattern (for a [semver](https://www.npmjs.com/package/semver) version). | ||
* | ||
* @param shell - The shell to use to query for the version it uses | ||
* @param versionToSatisfy - The version pattern to satisfy (e.g., `"<= 4.0.0 || 5.0.0 - 6.0.0"`) | ||
* @param test - The test to skip if the version does not satisfy the pattern | ||
*/ | ||
export const testRequiresRVersion = async(shell: RShell, versionToSatisfy: string, test: Mocha.Context): Promise<void> => { | ||
const version = await shell.usedRVersion() | ||
if (version === null || !semver.satisfies(version, versionToSatisfy)) { | ||
console.warn(`Skipping test because ${JSON.stringify(version)} does not satisfy ${JSON.stringify(versionToSatisfy)}.`) | ||
test.skip() | ||
} | ||
} | ||
|
||
export const testRequiresPipeOperator = async(shell: RShell, test: Mocha.Context): Promise<void> => { | ||
await testRequiresRVersion(shell, `>= ${MIN_VERSION_PIPE}`, test) | ||
} |
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