Skip to content

Commit 0595983

Browse files
committed
fix CI output
1 parent 44696a5 commit 0595983

File tree

6 files changed

+132
-74
lines changed

6 files changed

+132
-74
lines changed

rewatch/src/build.rs

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub fn initialize_build(
129129
path: &Path,
130130
bsc_path: &Option<PathBuf>,
131131
build_dev_deps: bool,
132+
snapshot_output: bool,
132133
) -> Result<BuildState> {
133134
let project_root = helpers::get_abs_path(path);
134135
let workspace_root = helpers::get_workspace_root(&project_root);
@@ -139,7 +140,7 @@ pub fn initialize_build(
139140
let root_config_name = packages::read_package_name(&project_root)?;
140141
let rescript_version = helpers::get_rescript_version(&bsc_path);
141142

142-
if show_progress {
143+
if !snapshot_output && show_progress {
143144
print!("{} {}Building package tree...", style("[1/7]").bold().dim(), TREE);
144145
let _ = stdout().flush();
145146
}
@@ -154,7 +155,7 @@ pub fn initialize_build(
154155
)?;
155156
let timing_package_tree_elapsed = timing_package_tree.elapsed();
156157

157-
if show_progress {
158+
if !snapshot_output && show_progress {
158159
println!(
159160
"{}{} {}Built package tree in {:.2}s",
160161
LINE_CLEAR,
@@ -172,7 +173,7 @@ pub fn initialize_build(
172173

173174
let timing_source_files = Instant::now();
174175

175-
if show_progress {
176+
if !snapshot_output && show_progress {
176177
print!(
177178
"{} {}Finding source files...",
178179
style("[2/7]").bold().dim(),
@@ -192,7 +193,7 @@ pub fn initialize_build(
192193
packages::parse_packages(&mut build_state);
193194
let timing_source_files_elapsed = timing_source_files.elapsed();
194195

195-
if show_progress {
196+
if !snapshot_output && show_progress {
196197
println!(
197198
"{}{} {}Found source files in {:.2}s",
198199
LINE_CLEAR,
@@ -214,7 +215,7 @@ pub fn initialize_build(
214215
let compile_assets_state = read_compile_state::read(&mut build_state);
215216
let timing_compile_state_elapsed = timing_compile_state.elapsed();
216217

217-
if show_progress {
218+
if !snapshot_output && show_progress {
218219
println!(
219220
"{}{} {}Read compile state {:.2}s",
220221
LINE_CLEAR,
@@ -236,15 +237,19 @@ pub fn initialize_build(
236237
let timing_cleanup_elapsed = timing_cleanup.elapsed();
237238

238239
if show_progress {
239-
println!(
240-
"{}{} {}Cleaned {}/{} {:.2}s",
241-
LINE_CLEAR,
242-
style("[4/7]").bold().dim(),
243-
SWEEP,
244-
diff_cleanup,
245-
total_cleanup,
246-
default_timing.unwrap_or(timing_cleanup_elapsed).as_secs_f64()
247-
);
240+
if snapshot_output {
241+
println!("Cleant {}/{}", diff_cleanup, total_cleanup)
242+
} else {
243+
println!(
244+
"{}{} {}Cleant {}/{} {:.2}s",
245+
LINE_CLEAR,
246+
style("[4/7]").bold().dim(),
247+
SWEEP,
248+
diff_cleanup,
249+
total_cleanup,
250+
default_timing.unwrap_or(timing_cleanup_elapsed).as_secs_f64()
251+
);
252+
}
248253
}
249254

250255
Ok(build_state)
@@ -282,10 +287,11 @@ pub fn incremental_build(
282287
only_incremental: bool,
283288
create_sourcedirs: bool,
284289
build_dev_deps: bool,
290+
snapshot_output: bool,
285291
) -> Result<(), IncrementalBuildError> {
286292
logs::initialize(&build_state.packages);
287293
let num_dirty_modules = build_state.modules.values().filter(|m| is_dirty(m)).count() as u64;
288-
let pb = if show_progress {
294+
let pb = if !snapshot_output && show_progress {
289295
ProgressBar::new(num_dirty_modules)
290296
} else {
291297
ProgressBar::hidden()
@@ -308,20 +314,25 @@ pub fn incremental_build(
308314
match result_asts {
309315
Ok(_ast) => {
310316
if show_progress {
311-
println!(
312-
"{}{} {}Parsed {} source files in {:.2}s",
313-
LINE_CLEAR,
314-
format_step(current_step, total_steps),
315-
CODE,
316-
num_dirty_modules,
317-
default_timing.unwrap_or(timing_ast_elapsed).as_secs_f64()
318-
);
319-
pb.finish();
317+
if snapshot_output {
318+
println!("Parsed {} source files", num_dirty_modules)
319+
} else {
320+
println!(
321+
"{}{} {}Parsed {} source files in {:.2}s",
322+
LINE_CLEAR,
323+
format_step(current_step, total_steps),
324+
CODE,
325+
num_dirty_modules,
326+
default_timing.unwrap_or(timing_ast_elapsed).as_secs_f64()
327+
);
328+
pb.finish();
329+
}
320330
}
321331
}
322332
Err(err) => {
323333
logs::finalize(&build_state.packages);
324-
if show_progress {
334+
335+
if !snapshot_output && show_progress {
325336
println!(
326337
"{}{} {}Error parsing source files in {:.2}s",
327338
LINE_CLEAR,
@@ -332,7 +343,7 @@ pub fn incremental_build(
332343
pb.finish();
333344
}
334345

335-
println!("Could not parse source files: {}", &err);
346+
println!("{}", &err);
336347
return Err(IncrementalBuildError::SourceFileParseError);
337348
}
338349
}
@@ -341,7 +352,7 @@ pub fn incremental_build(
341352
let timing_deps_elapsed = timing_deps.elapsed();
342353
current_step += 1;
343354

344-
if show_progress {
355+
if !snapshot_output && show_progress {
345356
println!(
346357
"{}{} {}Collected deps in {:.2}s",
347358
LINE_CLEAR,
@@ -365,7 +376,7 @@ pub fn incremental_build(
365376
};
366377

367378
let start_compiling = Instant::now();
368-
let pb = if show_progress {
379+
let pb = if !snapshot_output && show_progress {
369380
ProgressBar::new(build_state.modules.len().try_into().unwrap())
370381
} else {
371382
ProgressBar::hidden()
@@ -397,14 +408,18 @@ pub fn incremental_build(
397408
pb.finish();
398409
if !compile_errors.is_empty() {
399410
if show_progress {
400-
println!(
401-
"{}{} {}Compiled {} modules in {:.2}s",
402-
LINE_CLEAR,
403-
format_step(current_step, total_steps),
404-
CROSS,
405-
num_compiled_modules,
406-
default_timing.unwrap_or(compile_duration).as_secs_f64()
407-
);
411+
if snapshot_output {
412+
println!("Compiled {} modules", num_compiled_modules)
413+
} else {
414+
println!(
415+
"{}{} {}Compiled {} modules in {:.2}s",
416+
LINE_CLEAR,
417+
format_step(current_step, total_steps),
418+
CROSS,
419+
num_compiled_modules,
420+
default_timing.unwrap_or(compile_duration).as_secs_f64()
421+
);
422+
}
408423
}
409424
if helpers::contains_ascii_characters(&compile_warnings) {
410425
println!("{}", &compile_warnings);
@@ -415,14 +430,18 @@ pub fn incremental_build(
415430
Err(IncrementalBuildError::CompileError(None))
416431
} else {
417432
if show_progress {
418-
println!(
419-
"{}{} {}Compiled {} modules in {:.2}s",
420-
LINE_CLEAR,
421-
format_step(current_step, total_steps),
422-
SWORDS,
423-
num_compiled_modules,
424-
default_timing.unwrap_or(compile_duration).as_secs_f64()
425-
);
433+
if snapshot_output {
434+
println!("Compiled {} modules", num_compiled_modules)
435+
} else {
436+
println!(
437+
"{}{} {}Compiled {} modules in {:.2}s",
438+
LINE_CLEAR,
439+
format_step(current_step, total_steps),
440+
SWORDS,
441+
num_compiled_modules,
442+
default_timing.unwrap_or(compile_duration).as_secs_f64()
443+
);
444+
}
426445
}
427446

428447
if helpers::contains_ascii_characters(&compile_warnings) {
@@ -453,6 +472,7 @@ pub fn build(
453472
create_sourcedirs: bool,
454473
bsc_path: &Option<PathBuf>,
455474
build_dev_deps: bool,
475+
snapshot_output: bool,
456476
) -> Result<BuildState> {
457477
let default_timing: Option<std::time::Duration> = if no_timing {
458478
Some(std::time::Duration::new(0.0 as u64, 0.0 as u32))
@@ -467,6 +487,7 @@ pub fn build(
467487
path,
468488
bsc_path,
469489
build_dev_deps,
490+
snapshot_output,
470491
)
471492
.map_err(|e| anyhow!("Could not initialize build. Error: {e}"))?;
472493

@@ -478,9 +499,10 @@ pub fn build(
478499
false,
479500
create_sourcedirs,
480501
build_dev_deps,
502+
snapshot_output,
481503
) {
482504
Ok(_) => {
483-
if show_progress {
505+
if !snapshot_output && show_progress {
484506
let timing_total_elapsed = timing_total.elapsed();
485507
println!(
486508
"\n{}{}Finished Compilation in {:.2}s",

rewatch/src/build/clean.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ pub fn clean(
336336
show_progress: bool,
337337
bsc_path: &Option<PathBuf>,
338338
build_dev_deps: bool,
339+
snapshot_output: bool,
339340
) -> Result<()> {
340341
let project_root = helpers::get_abs_path(path);
341342
let workspace_root = helpers::get_workspace_root(&project_root);
@@ -356,7 +357,7 @@ pub fn clean(
356357
let rescript_version = helpers::get_rescript_version(&bsc_path);
357358

358359
let timing_clean_compiler_assets = Instant::now();
359-
if show_progress {
360+
if !snapshot_output && show_progress {
360361
print!(
361362
"{} {}Cleaning compiler assets...",
362363
style("[1/2]").bold().dim(),
@@ -366,13 +367,17 @@ pub fn clean(
366367
};
367368
packages.iter().for_each(|(_, package)| {
368369
if show_progress {
369-
print!(
370-
"{}{} {}Cleaning {}...",
371-
LINE_CLEAR,
372-
style("[1/2]").bold().dim(),
373-
SWEEP,
374-
package.name
375-
);
370+
if snapshot_output {
371+
println!("Cleaning {}", package.name)
372+
} else {
373+
print!(
374+
"{}{} {}Cleaning {}...",
375+
LINE_CLEAR,
376+
style("[1/2]").bold().dim(),
377+
SWEEP,
378+
package.name
379+
);
380+
}
376381
let _ = std::io::stdout().flush();
377382
}
378383

@@ -386,9 +391,9 @@ pub fn clean(
386391
});
387392
let timing_clean_compiler_assets_elapsed = timing_clean_compiler_assets.elapsed();
388393

389-
if show_progress {
394+
if !snapshot_output && show_progress {
390395
println!(
391-
"{}{} {}Cleaned compiler assets in {:.2}s",
396+
"{}{} {}Cleant compiler assets in {:.2}s",
392397
LINE_CLEAR,
393398
style("[1/2]").bold().dim(),
394399
SWEEP,
@@ -398,7 +403,7 @@ pub fn clean(
398403
}
399404

400405
let timing_clean_mjs = Instant::now();
401-
if show_progress {
406+
if !snapshot_output && show_progress {
402407
println!("{} {}Cleaning mjs files...", style("[2/2]").bold().dim(), SWEEP);
403408
let _ = std::io::stdout().flush();
404409
}
@@ -414,7 +419,7 @@ pub fn clean(
414419
clean_mjs_files(&build_state);
415420
let timing_clean_mjs_elapsed = timing_clean_mjs.elapsed();
416421

417-
if show_progress {
422+
if !snapshot_output && show_progress {
418423
println!(
419424
"{}{} {}Cleaned mjs files in {:.2}s",
420425
LINE_CLEAR,

rewatch/src/build/packages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ pub fn parse_packages(build_state: &mut BuildState) {
769769
};
770770
match source_files.get(&implementation_filename) {
771771
None => {
772-
log::warn!(
772+
println!(
773773
"{} No implementation file found for interface file (skipping): {}",
774774
LINE_CLEAR,
775775
file.to_string_lossy()

rewatch/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ struct Args {
4646
#[arg(short, long, default_value = "false", num_args = 0..=1)]
4747
no_timing: bool,
4848

49+
// simple output for snapshot testing
50+
#[arg(short, long, default_value = "false", num_args = 0..=1)]
51+
snapshot_output: bool,
52+
4953
/// Verbosity:
5054
/// -v -> Debug
5155
/// -vv -> Trace
@@ -129,6 +133,7 @@ fn main() -> Result<()> {
129133
show_progress,
130134
&args.bsc_path.map(PathBuf::from),
131135
args.dev,
136+
args.snapshot_output,
132137
),
133138
Command::Build => {
134139
match build::build(
@@ -139,6 +144,7 @@ fn main() -> Result<()> {
139144
args.create_sourcedirs,
140145
&args.bsc_path.map(PathBuf::from),
141146
args.dev,
147+
args.snapshot_output,
142148
) {
143149
Err(e) => {
144150
println!("{e}");
@@ -161,6 +167,7 @@ fn main() -> Result<()> {
161167
args.create_sourcedirs,
162168
args.dev,
163169
args.bsc_path,
170+
args.snapshot_output,
164171
);
165172

166173
Ok(())

0 commit comments

Comments
 (0)