1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: use rand.ulid() for the worker file name (make v test-fmt more robust)

This commit is contained in:
Delyan Angelov 2020-10-18 13:46:30 +03:00
parent 2f149e6984
commit 941f138934

View File

@ -5,6 +5,7 @@ module main
import os import os
import os.cmdline import os.cmdline
import rand
import v.ast import v.ast
import v.pref import v.pref
import v.fmt import v.fmt
@ -166,7 +167,8 @@ fn (foptions &FormatOptions) format_file(file string) {
// checker.check(file_ast) // checker.check(file_ast)
formatted_content := fmt.fmt(file_ast, table, foptions.is_debug) formatted_content := fmt.fmt(file_ast, table, foptions.is_debug)
file_name := os.file_name(file) file_name := os.file_name(file)
vfmt_output_path := os.join_path(os.temp_dir(), 'vfmt_' + file_name) ulid := rand.ulid()
vfmt_output_path := os.join_path(os.temp_dir(), 'vfmt_${ulid}_$file_name')
os.write_file(vfmt_output_path, formatted_content) os.write_file(vfmt_output_path, formatted_content)
if foptions.is_verbose { if foptions.is_verbose {
eprintln('fmt.fmt worked and $formatted_content.len bytes were written to $vfmt_output_path .') eprintln('fmt.fmt worked and $formatted_content.len bytes were written to $vfmt_output_path .')