Skip to content

Commit 70ec20b

Browse files
committed
.
1 parent 1dc819e commit 70ec20b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4442
-469
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- ./node_modules
2020
- run:
2121
name: test
22-
command: npm test
22+
command: npm contract-tests
2323
- store_artifacts:
2424
path: test-results.xml
2525
prefix: tests

bin/commands/cmd.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var commands_1 = require("./commands");
4+
var option_1 = require("./option");
5+
describe('commands, sanity check for command tree', function () {
6+
it('checks that commands are properly linked', function () {
7+
for (var cmdName in commands_1.COMMANDS) {
8+
if (commands_1.COMMANDS.hasOwnProperty(cmdName)) {
9+
var cmd = commands_1.COMMANDS[cmdName];
10+
expect(cmd.name()).toBe(cmdName);
11+
expect(cmd.description()).not.toBe('');
12+
if (cmdName === 'solstl') {
13+
expect(cmd.parent()).toBe('');
14+
}
15+
else {
16+
expect(commands_1.COMMANDS[cmd.parent()]).not.toBeUndefined();
17+
}
18+
for (var _i = 0, _a = cmd.subcommands(); _i < _a.length; _i++) {
19+
var subCmd = _a[_i];
20+
expect(commands_1.COMMANDS[subCmd]).not.toBeUndefined();
21+
}
22+
for (var _b = 0, _c = cmd.validOptions(); _b < _c.length; _b++) {
23+
var optn = _c[_b];
24+
expect(option_1.OPTIONS[optn]).not.toBeUndefined();
25+
}
26+
}
27+
}
28+
});
29+
});

bin/commands/cmd.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {COMMANDS} from "./commands";
2+
import {OPTIONS} from "./option";
3+
4+
describe('commands, sanity check for command tree', () => {
5+
it('checks that commands are properly linked', () => {
6+
for (const cmdName in COMMANDS) {
7+
if (COMMANDS.hasOwnProperty(cmdName)) {
8+
const cmd = COMMANDS[cmdName];
9+
expect(cmd.name()).toBe(cmdName);
10+
expect(cmd.description()).not.toBe('');
11+
if (cmdName === 'solstl') {
12+
expect(cmd.parent()).toBe('');
13+
} else {
14+
expect(COMMANDS[cmd.parent()]).not.toBeUndefined();
15+
}
16+
for (const subCmd of cmd.subcommands()) {
17+
expect(COMMANDS[subCmd]).not.toBeUndefined();
18+
}
19+
for (const optn of cmd.validOptions()) {
20+
expect(OPTIONS[optn]).not.toBeUndefined();
21+
}
22+
}
23+
}
24+
});
25+
});

bin/commands/cmd_perf.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
4848
var command_1 = require("./command");
4949
var perf_1 = require("../../script/perf");
5050
var constants_1 = require("../../script/constants");
51+
var io_1 = require("../../script/utils/io");
52+
var logs_1 = require("../../script/utils/logs");
53+
var logger_1 = require("../../script/utils/logger");
5154
var PerfCommand = /** @class */ (function (_super) {
5255
__extends(PerfCommand, _super);
5356
function PerfCommand() {
5457
return _super !== null && _super.apply(this, arguments) || this;
5558
}
5659
PerfCommand.prototype.execute = function (args, options) {
5760
return __awaiter(this, void 0, void 0, function () {
58-
var optAndUnopt, extended, _i, options_1, opt, units;
61+
var optAndUnopt, extended, silent, diff, _i, options_1, opt, units;
5962
return __generator(this, function (_a) {
6063
switch (_a.label) {
6164
case 0:
@@ -69,6 +72,8 @@ var PerfCommand = /** @class */ (function (_super) {
6972
}
7073
optAndUnopt = false;
7174
extended = false;
75+
silent = false;
76+
diff = false;
7277
for (_i = 0, options_1 = options; _i < options_1.length; _i++) {
7378
opt = options_1[_i];
7479
switch (opt) {
@@ -78,12 +83,26 @@ var PerfCommand = /** @class */ (function (_super) {
7883
case 'extended':
7984
extended = true;
8085
break;
86+
case 'silent':
87+
silent = true;
88+
break;
89+
case 'diff':
90+
diff = true;
91+
break;
8192
}
8293
}
8394
units = extended ? constants_1.UNITS_EXTENDED : constants_1.UNITS;
8495
return [4 /*yield*/, perf_1.perf(units, optAndUnopt)];
8596
case 1:
8697
_a.sent();
98+
if (!silent) {
99+
logs_1.printPerfLog(io_1.latestPerfLog());
100+
}
101+
if (diff) {
102+
if (!logs_1.printLatestDiff()) {
103+
logger_1.default.info("No previous perf logs exist.");
104+
}
105+
}
87106
return [2 /*return*/];
88107
}
89108
});
@@ -96,7 +115,7 @@ var PerfCommand = /** @class */ (function (_super) {
96115
return 'Run the perf suite.';
97116
};
98117
PerfCommand.prototype.validOptions = function () {
99-
return ['optAndUnopt', 'extended'];
118+
return ['optAndUnopt', 'extended', 'silent', 'diff'];
100119
};
101120
PerfCommand.prototype.parent = function () {
102121
return 'solstl';

bin/commands/cmd_perf.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {Command} from "./command";
22
import {perf} from "../../script/perf";
33
import {UNITS, UNITS_EXTENDED} from "../../script/constants";
4+
import {latestPerfLog} from "../../script/utils/io";
5+
import {printLatestDiff, printPerfLog} from "../../script/utils/logs";
6+
import Logger from "../../script/utils/logger";
47

58
export class PerfCommand extends Command {
69

@@ -15,6 +18,8 @@ export class PerfCommand extends Command {
1518
}
1619
let optAndUnopt = false;
1720
let extended = false;
21+
let silent = false;
22+
let diff = false;
1823
for (const opt of options) {
1924
switch (opt) {
2025
case 'optAndUnopt':
@@ -23,10 +28,24 @@ export class PerfCommand extends Command {
2328
case 'extended':
2429
extended = true;
2530
break;
31+
case 'silent':
32+
silent = true;
33+
break;
34+
case 'diff':
35+
diff = true;
36+
break;
2637
}
2738
}
2839
const units = extended ? UNITS_EXTENDED : UNITS;
2940
await perf(units, optAndUnopt);
41+
if (!silent) {
42+
printPerfLog(latestPerfLog());
43+
}
44+
if (diff) {
45+
if (!printLatestDiff()) {
46+
Logger.info("No previous perf logs exist.");
47+
}
48+
}
3049
}
3150

3251
public name(): string {
@@ -38,7 +57,7 @@ export class PerfCommand extends Command {
3857
}
3958

4059
public validOptions(): string[] {
41-
return ['optAndUnopt', 'extended'];
60+
return ['optAndUnopt', 'extended', 'silent', 'diff'];
4261
}
4362

4463
public parent(): string {

bin/commands/cmd_tests.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
4848
var command_1 = require("./command");
4949
var constants_1 = require("../../script/constants");
5050
var tests_1 = require("../../script/tests");
51-
var test_logger_1 = require("../../script/utils/test_logger");
51+
var logs_1 = require("../../script/utils/logs");
52+
var io_1 = require("../../script/utils/io");
5253
var TestsCommand = /** @class */ (function (_super) {
5354
__extends(TestsCommand, _super);
5455
function TestsCommand() {
5556
return _super !== null && _super.apply(this, arguments) || this;
5657
}
5758
TestsCommand.prototype.execute = function (args, options) {
5859
return __awaiter(this, void 0, void 0, function () {
59-
var optAndUnopt, extended, _i, options_1, opt, units;
60+
var optAndUnopt, extended, silent, _i, options_1, opt, units, result;
6061
return __generator(this, function (_a) {
6162
switch (_a.label) {
6263
case 0:
@@ -70,6 +71,7 @@ var TestsCommand = /** @class */ (function (_super) {
7071
}
7172
optAndUnopt = false;
7273
extended = false;
74+
silent = false;
7375
for (_i = 0, options_1 = options; _i < options_1.length; _i++) {
7476
opt = options_1[_i];
7577
switch (opt) {
@@ -79,14 +81,20 @@ var TestsCommand = /** @class */ (function (_super) {
7981
case 'extended':
8082
extended = true;
8183
break;
82-
case 'silentTests':
83-
test_logger_1.default.setSilent(true);
84+
case 'silent':
85+
silent = true;
8486
}
8587
}
8688
units = extended ? constants_1.UNITS_EXTENDED : constants_1.UNITS;
8789
return [4 /*yield*/, tests_1.test(units, optAndUnopt)];
8890
case 1:
89-
_a.sent();
91+
result = _a.sent();
92+
if (!silent) {
93+
logs_1.printTestLog(io_1.latestTestLog());
94+
}
95+
if (!result) {
96+
throw new Error("At least one test failed.");
97+
}
9098
return [2 /*return*/];
9199
}
92100
});
@@ -99,7 +107,7 @@ var TestsCommand = /** @class */ (function (_super) {
99107
return 'Run the test suite.';
100108
};
101109
TestsCommand.prototype.validOptions = function () {
102-
return ['optAndUnopt', 'extended', 'silentTests'];
110+
return ['optAndUnopt', 'extended', 'silent'];
103111
};
104112
TestsCommand.prototype.parent = function () {
105113
return 'solstl';

bin/commands/cmd_tests.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {Command} from "./command";
22
import {UNITS, UNITS_EXTENDED} from "../../script/constants";
33
import {test} from "../../script/tests";
44
import TestLogger from "../../script/utils/test_logger";
5+
import {printTestLog} from "../../script/utils/logs";
6+
import {latestTestLog} from "../../script/utils/io";
57

68
export class TestsCommand extends Command {
79

@@ -16,6 +18,7 @@ export class TestsCommand extends Command {
1618
}
1719
let optAndUnopt = false;
1820
let extended = false;
21+
let silent = false;
1922
for (const opt of options) {
2023
switch (opt) {
2124
case 'optAndUnopt':
@@ -24,12 +27,18 @@ export class TestsCommand extends Command {
2427
case 'extended':
2528
extended = true;
2629
break;
27-
case 'silentTests':
28-
TestLogger.setSilent(true);
30+
case 'silent':
31+
silent = true;
2932
}
3033
}
3134
const units = extended ? UNITS_EXTENDED : UNITS;
32-
await test(units, optAndUnopt);
35+
const result = await test(units, optAndUnopt);
36+
if (!silent) {
37+
printTestLog(latestTestLog());
38+
}
39+
if (!result) {
40+
throw new Error(`At least one test failed.`);
41+
}
3342
}
3443

3544
public name(): string {
@@ -41,7 +50,7 @@ export class TestsCommand extends Command {
4150
}
4251

4352
public validOptions(): string[] {
44-
return ['optAndUnopt', 'extended', 'silentTests'];
53+
return ['optAndUnopt', 'extended', 'silent'];
4554
}
4655

4756
public parent(): string {

bin/commands/option.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ exports.OPTIONS = {
2323
version: new Option('version', 'V', 'Show the current version.'),
2424
optAndUnopt: new Option('optAndUnopt', 'O', 'Run the suit both with optimized and un-opttimized code.'),
2525
extended: new Option('extended', 'E', 'Include the extended tests/performance units.'),
26-
silentTests: new Option('silentTests', 'S', 'Only failed tests are reported in the console.')
26+
silent: new Option('silent', 'S', 'Do not show a detailed results from tests or perf.'),
27+
diff: new Option('diff', 'D', 'Compare perf results with the results from the previous perf (if any).')
2728
};
2829
exports.GLOBAL_OPTIONS = {
2930
debug: new Option('debug', 'D', 'Enable debug logging.')

bin/commands/option.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var option_1 = require("./option");
4+
describe('sanity check for options', function () {
5+
it('checks that options are well formed', function () {
6+
var shortFormsFound = {};
7+
var check = function (optsObj) {
8+
for (var optName in optsObj) {
9+
if (optsObj.hasOwnProperty(optName)) {
10+
var opt = optsObj[optName];
11+
expect(opt.name()).toBe(optName);
12+
expect(opt.info()).not.toBe('');
13+
var shortForm = opt.shortForm();
14+
expect(shortFormsFound[shortForm]).toBeUndefined();
15+
shortFormsFound[shortForm] = true;
16+
}
17+
}
18+
};
19+
check(option_1.OPTIONS);
20+
check(option_1.GLOBAL_OPTIONS);
21+
});
22+
});

bin/commands/option.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {GLOBAL_OPTIONS, OPTIONS} from "./option";
2+
3+
describe('sanity check for options', () => {
4+
it('checks that options are well formed', () => {
5+
const shortFormsFound = {};
6+
7+
const check = (optsObj) => {
8+
for (const optName in optsObj) {
9+
if (optsObj.hasOwnProperty(optName)) {
10+
const opt = optsObj[optName];
11+
expect(opt.name()).toBe(optName);
12+
expect(opt.info()).not.toBe('');
13+
const shortForm = opt.shortForm();
14+
expect(shortFormsFound[shortForm]).toBeUndefined();
15+
shortFormsFound[shortForm] = true;
16+
}
17+
}
18+
};
19+
20+
check(OPTIONS);
21+
check(GLOBAL_OPTIONS);
22+
});
23+
});

bin/commands/option.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const OPTIONS: { [name: string]: Option } = {
2727
version: new Option('version', 'V', 'Show the current version.'),
2828
optAndUnopt: new Option('optAndUnopt', 'O', 'Run the suit both with optimized and un-opttimized code.'),
2929
extended: new Option('extended', 'E', 'Include the extended tests/performance units.'),
30-
silentTests: new Option('silentTests', 'S', 'Only failed tests are reported in the console.')
30+
silent: new Option('silent', 'S', 'Do not show a detailed results from tests or perf.'),
31+
diff: new Option('diff', 'D', 'Compare perf results with the results from the previous perf (if any).')
3132
};
3233

3334
export const GLOBAL_OPTIONS: { [name: string]: Option } = {

0 commit comments

Comments
 (0)