Skip to content

Commit dbbdaf5

Browse files
committed
feat: exit(1) on failed checks, improve watch feature
1 parent 7c572ce commit dbbdaf5

File tree

5 files changed

+48
-33
lines changed

5 files changed

+48
-33
lines changed

deno/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ export class Chain {
111111
}
112112

113113
mineBlock(transactions: Array<Tx>): Block {
114-
let result = (Deno as any).core.opSync("mine_block", {
114+
let result = JSON.parse((Deno as any).core.opSync("mine_block", {
115115
sessionId: this.sessionId,
116116
transactions: transactions,
117-
});
117+
}));
118118
this.blockHeight = result.block_height;
119119
let block: Block = {
120120
height: result.block_height,
@@ -124,10 +124,10 @@ export class Chain {
124124
}
125125

126126
mineEmptyBlock(count: number): EmptyBlock {
127-
let result = (Deno as any).core.opSync("mine_empty_blocks", {
127+
let result = JSON.parse((Deno as any).core.opSync("mine_empty_blocks", {
128128
sessionId: this.sessionId,
129129
count: count,
130-
});
130+
}));
131131
this.blockHeight = result.block_height;
132132
let emptyBlock: EmptyBlock = {
133133
session_id: result.session_id,
@@ -150,13 +150,13 @@ export class Chain {
150150
args: Array<any>,
151151
sender: string,
152152
): ReadOnlyFn {
153-
let result = (Deno as any).core.opSync("call_read_only_fn", {
153+
let result = JSON.parse((Deno as any).core.opSync("call_read_only_fn", {
154154
sessionId: this.sessionId,
155155
contract: contract,
156156
method: method,
157157
args: args,
158158
sender: sender,
159-
});
159+
}));
160160
let readOnlyFn: ReadOnlyFn = {
161161
session_id: result.session_id,
162162
result: result.result,
@@ -166,9 +166,9 @@ export class Chain {
166166
}
167167

168168
getAssetsMaps(): AssetsMaps {
169-
let result = (Deno as any).core.opSync("get_assets_maps", {
169+
let result = JSON.parse((Deno as any).core.opSync("get_assets_maps", {
170170
sessionId: this.sessionId,
171-
});
171+
}));
172172
let assetsMaps: AssetsMaps = {
173173
session_id: result.session_id,
174174
assets: result.assets

src/console/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ pub fn load_session(start_repl: bool, env: String) -> Result<repl::SessionSettin
8989
terminal.start();
9090
} else {
9191
let mut session = repl::Session::new(settings.clone());
92-
session.check()?;
92+
match session.check() {
93+
Err(message) => {
94+
println!("Error: {}", message);
95+
std::process::exit(1);
96+
}
97+
_ => {}
98+
};
9399
}
94100
Ok(settings)
95101
}

src/test/deno.rs

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
165165
include.clone()
166166
};
167167

168-
let doc_modules = vec![];
169168
let allow_none = true;
170169
let no_run = false;
171170
let concurrent_jobs = 2;
@@ -191,9 +190,9 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
191190
let doc_modules_result = test_runner::collect_test_module_specifiers(
192191
include.clone(),
193192
&cwd,
194-
fs_util::is_supported_ext,
193+
is_supported_ext,
195194
);
196-
195+
197196
let test_modules_result = test_runner::collect_test_module_specifiers(
198197
include.clone(),
199198
&cwd,
@@ -207,6 +206,8 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
207206
let program_state = program_state.clone();
208207
let files_changed = changed.is_some();
209208
async move {
209+
let doc_modules = doc_modules_result?;
210+
210211
let test_modules = test_modules_result?;
211212

212213
let mut paths_to_watch = paths_to_watch_clone;
@@ -284,9 +285,13 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
284285
for path in changed.iter().filter_map(|path| {
285286
deno_core::resolve_url_or_path(&path.to_string_lossy()).ok()
286287
}) {
287-
if modules.contains(&&path) {
288-
modules_to_reload.push(specifier);
289-
break;
288+
if path.path().ends_with(".clar") {
289+
modules_to_reload.push(specifier.clone());
290+
} else {
291+
if modules.contains(&&path) {
292+
modules_to_reload.push(specifier);
293+
break;
294+
}
290295
}
291296
}
292297
}
@@ -295,23 +300,17 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
295300
Ok((paths_to_watch, modules_to_reload))
296301
}
297302
.map(move |result| {
298-
if files_changed
299-
&& matches!(result, Ok((_, ref modules)) if modules.is_empty())
300-
{
301-
ResolutionResult::Ignore
302-
} else {
303-
match result {
304-
Ok((paths_to_watch, modules_to_reload)) => {
305-
ResolutionResult::Restart {
306-
paths_to_watch,
307-
result: Ok(modules_to_reload),
308-
}
309-
}
310-
Err(e) => ResolutionResult::Restart {
303+
match result {
304+
Ok((paths_to_watch, modules_to_reload)) => {
305+
ResolutionResult::Restart {
311306
paths_to_watch,
312-
result: Err(e),
313-
},
307+
result: Ok(modules_to_reload),
308+
}
314309
}
310+
Err(e) => ResolutionResult::Restart {
311+
paths_to_watch,
312+
result: Err(e),
313+
},
315314
}
316315
})
317316
};
@@ -338,6 +337,8 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
338337
)
339338
.await?;
340339
} else {
340+
let doc_modules = vec![];
341+
341342
let test_modules = test_runner::collect_test_module_specifiers(
342343
include.clone(),
343344
&cwd,
@@ -386,6 +387,14 @@ pub async fn do_run_tests(include: Vec<String>, include_coverage: bool, watch: b
386387
Ok(true)
387388
}
388389

390+
pub fn is_supported_ext(path: &Path) -> bool {
391+
if let Some(ext) = fs_util::get_extension(path) {
392+
matches!(ext.as_str(), "ts" | "js" | "clar")
393+
} else {
394+
false
395+
}
396+
}
397+
389398
#[allow(clippy::too_many_arguments)]
390399
pub async fn run_tests(
391400
program_state: Arc<ProgramState>,

vendor/deno/cli/ops/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn op_apply_source_map(
3030
state: &mut OpState,
3131
args: Value,
3232
_: (),
33-
) -> Result<Value, AnyError> {
33+
) -> Result<String, AnyError> {
3434
let args: ApplySourceMap = serde_json::from_value(args)?;
3535

3636
let mut mappings_map: CachedMaps = HashMap::new();
@@ -49,7 +49,7 @@ fn op_apply_source_map(
4949
"fileName": orig_file_name,
5050
"lineNumber": orig_line_number as u32,
5151
"columnNumber": orig_column_number as u32,
52-
}))
52+
}).to_string())
5353
}
5454

5555
fn op_format_diagnostic(

vendor/deno/runtime/js/40_error_stack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
function opApplySourceMap(location) {
12-
const res = core.opSync("op_apply_source_map", location);
12+
const res = JSON.parse(core.opSync("op_apply_source_map", location));
1313
return {
1414
fileName: res.fileName,
1515
lineNumber: res.lineNumber,

0 commit comments

Comments
 (0)