Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 08164fc

Browse files
authored
Merge pull request #4340 from dongmingh/3887
Add support of truffle test --migrate-none and event message
2 parents fb27278 + d3eaac1 commit 08164fc

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

packages/core/lib/commands/test/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const command = {
4848
help: {
4949
usage:
5050
`truffle test [<test_file>] [--compile-all[-debug]] [--compile-none] ` +
51+
`[--migrate-none] ` +
5152
`[--network <name>]${OS.EOL} ` +
5253
`[--verbose-rpc] [--show-events] [--debug] ` +
5354
`[--debug-global <identifier>] [--bail|-b]${OS.EOL} ` +
@@ -75,6 +76,10 @@ const command = {
7576
"Compile all contracts and do so in debug mode for extra revert info. May " +
7677
"cause errors on large\n contracts."
7778
},
79+
{
80+
option: "--migrate-none",
81+
description: "Do not migrate any contracts before running the tests."
82+
},
7883
{
7984
option: "--verbose-rpc",
8085
description:

packages/core/lib/testing/Test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ const Test = {
106106

107107
const runner = new TestRunner(config);
108108

109-
await this.performInitialDeploy(config, testResolver);
109+
if (config.migrateNone || config['migrate-none']) {
110+
if (config.events) {
111+
config.events.emit("migrate:skipped");
112+
}
113+
} else {
114+
await this.performInitialDeploy(config, testResolver);
115+
}
110116

111117
const sourcePaths = []
112118
.concat(

packages/events/defaultSubscribers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
compile: require("./compile"),
3+
migrate: require("./migrate"),
34
init: require("./init"),
45
obtain: require("./obtain"),
56
unbox: require("./unbox"),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
initialization: function () {
3+
this.logger = console;
4+
},
5+
handlers: {
6+
"migrate:skipped": [
7+
function () {
8+
if (this.quiet) return;
9+
this.logger.log(
10+
`> Migration skipped because --migrate-none option was passed.`
11+
);
12+
}
13+
]
14+
}
15+
};

0 commit comments

Comments
 (0)