Skip to content

Commit

Permalink
Always mark ran tests (#53)
Browse files Browse the repository at this point in the history
* always save pass/fail results for a test to properly detect cycles

* increment patch version
  • Loading branch information
JakeUrban authored Jul 26, 2021
1 parent cada7f9 commit 62d9e24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion @stellar/anchor-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/anchor-tests",
"version": "0.1.3",
"version": "0.1.4",
"description": "stellar-anchor-tests is a library and command line interface for testing Stellar anchors.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
17 changes: 11 additions & 6 deletions @stellar/anchor-tests/src/helpers/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ async function* runTestsRecur(
config: Config,
chain: Test[],
globalContext: { [key: string]: any },
ranTests: Record<string, TestRun>,
ranTestsPassFail: Record<string, boolean>,
): AsyncGenerator<TestRun> {
for (const test of tests) {
if (containsTest(chain, test)) {
throw new CyclicDependencyError(test);
} else if (testString(test) in ranTests) {
if (!ranTests[testString(test)].result.failure) {
} else if (testString(test) in ranTestsPassFail) {
if (ranTestsPassFail[testString(test)]) {
continue;
} else {
throw new FailedDependencyError(test);
}
}
//let skippedDependency: TestRun | undefined = undefined;
ranTestsPassFail[testString(test)] = true;
let failedDependencyError: FailedDependencyError | undefined = undefined;
let cycleError: CyclicDependencyError | undefined = undefined;
if (test.dependencies) {
Expand All @@ -170,7 +170,7 @@ async function* runTestsRecur(
config,
chain,
globalContext,
ranTests,
ranTestsPassFail,
)) {
yield testRun;
if (testRun.result.failure) {
Expand Down Expand Up @@ -203,6 +203,7 @@ async function* runTestsRecur(
return (cycleError as CyclicDependencyError).message;
},
};
ranTestsPassFail[testString(test)] = false;
yield {
test: test,
result: {
Expand All @@ -217,6 +218,7 @@ async function* runTestsRecur(
return (failedDependencyError as FailedDependencyError).message;
},
};
ranTestsPassFail[testString(test)] = false;
yield {
test: test,
result: {
Expand All @@ -230,6 +232,7 @@ async function* runTestsRecur(
test,
);
if (expectedContextFailure) {
ranTestsPassFail[testString(test)] = false;
yield {
test: test,
result: {
Expand All @@ -240,13 +243,13 @@ async function* runTestsRecur(
continue;
}
const testRun = await runTest(test, config);
ranTests[testString(test)] = testRun;
if (!testRun.result.failure) {
const providedContextFailure = updateWithProvidedContext(
globalContext,
test,
);
if (providedContextFailure) {
ranTestsPassFail[testString(test)] = false;
yield {
test: test,
result: {
Expand All @@ -256,6 +259,8 @@ async function* runTestsRecur(
};
continue;
}
} else {
ranTestsPassFail[testString(test)] = false;
}
yield testRun;
}
Expand Down

0 comments on commit 62d9e24

Please sign in to comment.