Skip to content

Commit b66e82d

Browse files
committed
two-bucket: skip broken/unimplemented tests
1 parent a4f1a9c commit b66e82d

File tree

7 files changed

+35
-21
lines changed

7 files changed

+35
-21
lines changed

exercises/alphametics/alphametics.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('Solve the alphametics puzzle', () => {
9191
expect(solve(puzzle)).toEqual(expected);
9292
});
9393

94-
xtest('puzzle with ten letters and 199 addends', () => {
94+
test.skip('puzzle with ten letters and 199 addends', () => {
9595
const puzzle =
9696
'THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES';
9797
const expected = {

exercises/crypto-square/crypto-square.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('Crypto', () => {
3131
expect(crypto.ciphertext).toEqual('clu hlt io ');
3232
});
3333

34-
xtest.skip('54 character plaintext results in 7 chunks, the last two with trailing spaces', () => {
34+
test.skip('54 character plaintext results in 7 chunks, the last two with trailing spaces', () => {
3535
const crypto = new Crypto(
3636
'If man was meant to stay on the ground, god would have given us roots.'
3737
);

exercises/palindrome-products/palindrome-products.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('Palindromes', () => {
7979
expect(sortFactors(smallest.factors)).toEqual(expected.factors);
8080
});
8181

82-
xtest('largest palindrome from four digit factors', () => {
82+
test.skip('largest palindrome from four digit factors', () => {
8383
const palindromes = Palindromes.generate({
8484
maxFactor: 9999,
8585
minFactor: 1000,

exercises/two-bucket/two-bucket.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('TwoBucket', () => {
5959
});
6060

6161
describe('Measure using bucket one of size 2 and bucket two of size 3', () => {
62-
xtest('start with bucket one and end with bucket two', () => {
62+
test.skip('start with bucket one and end with bucket two', () => {
6363
const twoBucket = new TwoBucket(2, 3, 3, 'one');
6464
expect(twoBucket.moves()).toEqual(2);
6565
expect(twoBucket.goalBucket).toEqual('two');
@@ -72,7 +72,7 @@ describe('TwoBucket', () => {
7272
const buckTwo = 15;
7373
const starterBuck = 'one';
7474

75-
xtest('Not possible to reach the goal', () => {
75+
test.skip('Not possible to reach the goal', () => {
7676
const goal = 5;
7777
const twoBucket = new TwoBucket(buckOne, buckTwo, goal, starterBuck);
7878
expect(twoBucket.moves()).toThrow();
@@ -88,7 +88,7 @@ describe('TwoBucket', () => {
8888
});
8989

9090
describe('Goal larger than both buckets', () => {
91-
xtest('Is impossible', () => {
91+
test.skip('Is impossible', () => {
9292
const twoBucket = new TwoBucket(5, 7, 8, 'one');
9393
expect(twoBucket.moves()).toThrow();
9494
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"jest": {
2727
"modulePathIgnorePatterns": [
2828
"package.json"
29-
]
29+
],
30+
"testSequencer": "./testSequencer.js"
3031
},
3132
"scripts": {
3233
"test": "jest --no-cache ./*",

scripts/pr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ const {
1818
cleanUp,
1919
registerExitHandler,
2020
assignments,
21-
} = require("./helpers");
21+
} = require('./helpers');
2222

23-
const shell = require("shelljs");
24-
const path = require("path");
23+
const shell = require('shelljs');
24+
const path = require('path');
2525
const files = process.argv.slice(2);
2626

2727
if (files.length === 0) {
2828
shell.echo(
29-
"[Failure] No files passed in. Pass in paths to exercise directories or its file."
29+
'[Failure] No files passed in. Pass in paths to exercise directories or its file.'
3030
);
3131
shell.exit(-1);
3232
}
3333

34-
shell.echo("[Files] The files passed in are as follows:");
34+
shell.echo('[Files] The files passed in are as follows:');
3535
files.forEach((file) => {
3636
shell.echo(`[Files] ${file}`);
3737
});
@@ -44,42 +44,42 @@ const _exercises = files
4444
.filter(Boolean)
4545
.filter((exercise, index, array) => array.indexOf(exercise) === index);
4646

47-
const hasRootFile = files.some((file) => file === "package.json");
47+
const hasRootFile = files.some((file) => file === 'package.json');
4848

4949
if (hasRootFile) {
5050
shell.echo(
51-
"[Root PR] When package.json is changed, all exercises need to be checked"
51+
'[Root PR] When package.json is changed, all exercises need to be checked'
5252
);
5353
} else if (_exercises.length > 8) {
5454
shell.echo(
55-
"[Big PR] When more than 8 exercises are being checked, all of them are " +
56-
"checked as this is likely a PR affecting everything."
55+
'[Big PR] When more than 8 exercises are being checked, all of them are ' +
56+
'checked as this is likely a PR affecting everything.'
5757
);
5858
}
5959

6060
const exercises =
6161
hasRootFile || _exercises.length > 8 ? assignments : _exercises;
6262

6363
if (exercises.length === 0) {
64-
shell.echo("[Skip] None of the files are inside an exercise directory.");
64+
shell.echo('[Skip] None of the files are inside an exercise directory.');
6565
shell.exit(0);
6666
}
6767

6868
registerExitHandler();
6969

70-
shell.env["PREPARE"] = false;
71-
shell.env["CLEANUP"] = false;
70+
shell.env['PREPARE'] = false;
71+
shell.env['CLEANUP'] = false;
7272

7373
const infoStr = `Running tests for ${
7474
exercises.length === 1 ? exercises[0] : `${exercises.length} exercises\n`
7575
}`;
76-
const failureStr = "[Failure] Tests failed!";
76+
const failureStr = '[Failure] Tests failed!';
7777

7878
// Prepare exercises
7979
exercises.forEach(prepare);
8080

8181
// Run tests
82-
prepareAndRun("npx jest --bail tmp_exercises", infoStr, failureStr);
82+
prepareAndRun('npx jest --bail tmp_exercises --runInBand', infoStr, failureStr);
8383

8484
shell.echo(
8585
exercises.length === 1

testSequencer.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// testSequencer.js
2+
const Sequencer = require('@jest/test-sequencer').default;
3+
4+
class CustomSequencer extends Sequencer {
5+
sort(tests) {
6+
// Test structure information
7+
// https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21
8+
const copyTests = Array.from(tests);
9+
return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1));
10+
}
11+
}
12+
13+
module.exports = CustomSequencer;

0 commit comments

Comments
 (0)