Skip to content

Commit

Permalink
fmt: remove the prfixed module name of the const name in same module
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Sep 9, 2024
1 parent 6528efa commit 8a72645
Show file tree
Hide file tree
Showing 280 changed files with 2,524 additions and 2,557 deletions.
8 changes: 4 additions & 4 deletions cmd/tools/modules/scripting/scripting.v
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn set_verbose(on bool) {

pub fn cprint(omessage string) {
mut message := omessage
if scripting.term_colors {
if term_colors {
message = term.cyan(message)
}
print(message)
Expand All @@ -27,7 +27,7 @@ pub fn cprint(omessage string) {

pub fn cprint_strong(omessage string) {
mut message := omessage
if scripting.term_colors {
if term_colors {
message = term.bright_green(message)
}
print(message)
Expand Down Expand Up @@ -57,7 +57,7 @@ pub fn verbose_trace_strong(label string, omessage string) {
if os.getenv('VERBOSE').len > 0 {
slabel := '${time.now().format_ss_milli()} ${label}'
mut message := omessage
if scripting.term_colors {
if term_colors {
message = term.bright_green(message)
}
cprintln('# ${slabel:-43s} : ${message}')
Expand All @@ -71,7 +71,7 @@ pub fn verbose_trace_exec_result(x os.Result) {
lines := x.output.split_into_lines()
for oline in lines {
mut line := oline
if scripting.term_colors {
if term_colors {
line = term.bright_green(line)
}
cprintln('# ${lnum:3d}: ${line}')
Expand Down
44 changes: 22 additions & 22 deletions cmd/tools/modules/testing/common.v
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
skip_files << 'examples/pendulum-simulation/parallel.v'
skip_files << 'examples/pendulum-simulation/parallel_with_iw.v'
skip_files << 'examples/pendulum-simulation/sequential.v'
if testing.github_job == 'tcc' {
if github_job == 'tcc' {
// TODO: fix these by adding declarations for the missing functions in the prebuilt tcc
skip_files << 'vlib/net/mbedtls/mbedtls_compiles_test.v'
skip_files << 'vlib/net/ssl/ssl_compiles_test.v'
}
}
if testing.runner_os != 'Linux' || testing.github_job != 'tcc' {
if runner_os != 'Linux' || github_job != 'tcc' {
if !os.exists('/usr/local/include/wkhtmltox/pdf.h') {
skip_files << 'examples/c_interop_wkhtmltopdf.v' // needs installation of wkhtmltopdf from https://github.com/wkhtmltopdf/packaging/releases
}
Expand All @@ -275,16 +275,16 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
$if !macos {
skip_files << 'examples/macos_tray/tray.v'
}
if testing.github_job == 'ubuntu-docker-musl' {
if github_job == 'ubuntu-docker-musl' {
skip_files << 'vlib/net/openssl/openssl_compiles_test.c.v'
skip_files << 'vlib/x/ttf/ttf_test.v'
}
if testing.github_job == 'tests-sanitize-memory-clang' {
if github_job == 'tests-sanitize-memory-clang' {
skip_files << 'vlib/net/openssl/openssl_compiles_test.c.v'
// Fails compilation with: `/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line`
skip_files << 'examples/sokol/sounds/simple_sin_tones.v'
}
if testing.github_job != 'misc-tooling' {
if github_job != 'misc-tooling' {
// These examples need .h files that are produced from the supplied .glsl files,
// using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
skip_files << 'examples/sokol/02_cubes_glsl/cube_glsl.v'
Expand Down Expand Up @@ -313,7 +313,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
vexe: vexe
vroot: vroot
skip_files: skip_files
fail_fast: testing.fail_fast
fail_fast: fail_fast
show_stats: '-stats' in vargs.split(' ')
show_asserts: '-show-asserts' in vargs.split(' ')
vargs: vargs
Expand Down Expand Up @@ -396,14 +396,14 @@ pub fn (mut ts TestSession) test() {
// Special case for android_outside_termux because of its
// underscores
if file.ends_with('_android_outside_termux_test.v') {
if !testing.host_os.is_target_of('android_outside_termux') {
if !host_os.is_target_of('android_outside_termux') {
remaining_files << dot_relative_file
ts.skip_files << file
continue
}
}
os_target := file.all_before_last('_test.v').all_after_last('_')
if !testing.host_os.is_target_of(os_target) {
if !host_os.is_target_of(os_target) {
remaining_files << dot_relative_file
ts.skip_files << file
continue
Expand Down Expand Up @@ -553,7 +553,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
if !ts.build_tools && abs_path in ts.skip_files {
ts.benchmark.skip()
tls_bench.skip()
if !testing.hide_skips {
if !hide_skips {
ts.append_message(.skip, tls_bench.step_message_with_label_and_duration(benchmark.b_skip,
normalised_relative_file, 0,
preparation: 1 * time.microsecond
Expand Down Expand Up @@ -597,9 +597,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
goto test_passed_system
}
}
time.sleep(testing.fail_retry_delay_ms)
time.sleep(fail_retry_delay_ms)
}
if details.flaky && !testing.fail_flaky {
if details.flaky && !fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .\ncmd: ${cmd}',
mtc)
unsafe {
Expand All @@ -616,14 +616,14 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
return pool.no_result
}
} else {
if testing.show_start {
if show_start {
ts.append_message(.info, ' starting ${relative_file} ...',
mtc)
}
ts.append_message(.compile_begin, cmd, mtc)
compile_d_cmd := time.new_stopwatch()
mut compile_r := os.Result{}
for cretry in 0 .. testing.max_compilation_retries {
for cretry in 0 .. max_compilation_retries {
compile_r = os.execute(cmd)
compile_cmd_duration = compile_d_cmd.elapsed()
// eprintln('>>>> cretry: $cretry | compile_r.exit_code: $compile_r.exit_code | compile_cmd_duration: ${compile_cmd_duration:8} | file: $normalised_relative_file')
Expand Down Expand Up @@ -670,7 +670,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
// retry running at least 1 more time, to avoid CI false positives as much as possible
details.retry++
}
failure_output.write_string(testing.separator)
failure_output.write_string(separator)
failure_output.writeln(' retry: 0 ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
failure_output.writeln(trimmed_output)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
Expand All @@ -691,13 +691,13 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
}
trimmed_output = r.output.trim_space()
failure_output.write_string(testing.separator)
failure_output.write_string(separator)
failure_output.writeln(' retry: ${retry} ; max_retry: ${details.retry} ; r.exit_code: ${r.exit_code} ; trimmed_output.len: ${trimmed_output.len}')
failure_output.writeln(trimmed_output)
time.sleep(testing.fail_retry_delay_ms)
time.sleep(fail_retry_delay_ms)
}
full_failure_output := failure_output.str().trim_space()
if details.flaky && !testing.fail_flaky {
if details.flaky && !fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .\n comp_cmd: ${cmd}\n run_cmd: ${run_cmd}',
mtc)
unsafe {
Expand All @@ -706,7 +706,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
ts.benchmark.fail()
tls_bench.fail()
cmd_duration = d_cmd.elapsed() - (testing.fail_retry_delay_ms * details.retry)
cmd_duration = d_cmd.elapsed() - (fail_retry_delay_ms * details.retry)
ts.append_message_with_duration(.fail, tls_bench.step_message_with_label_and_duration(benchmark.b_fail,
'${normalised_relative_file}\n retry: ${retry}\n comp_cmd: ${cmd}\n run_cmd: ${run_cmd}\nfailure code: ${r.exit_code}; foutput.len: ${full_failure_output.len}; failure output:\n${full_failure_output}',
cmd_duration,
Expand All @@ -720,7 +720,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
test_passed_execute:
ts.benchmark.ok()
tls_bench.ok()
if !testing.hide_oks {
if !hide_oks {
ts.append_message_with_duration(.ok, tls_bench.step_message_with_label_and_duration(benchmark.b_ok,
normalised_relative_file, cmd_duration,
preparation: compile_cmd_duration
Expand Down Expand Up @@ -769,7 +769,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
}
}
c := os.read_file(fnormalised) or { panic(err) }
start := c#[0..testing.header_bytes_to_search_for_module_main]
start := c#[0..header_bytes_to_search_for_module_main]
if start.contains('module ') && !start.contains('module main') {
skipped << fnormalised.replace(nparent_dir + '/', '')
continue next_file
Expand Down Expand Up @@ -834,7 +834,7 @@ pub fn building_any_v_binaries_failed() bool {
continue
}
bmark.ok()
if !testing.hide_oks {
if !hide_oks {
eprintln(bmark.step_message_ok('command: ${cmd}'))
}
}
Expand Down Expand Up @@ -875,7 +875,7 @@ pub fn get_test_details(file string) TestDetails {
}

pub fn find_started_process(pname string) !string {
for line in testing.all_processes {
for line in all_processes {
if line.contains(pname) {
return line
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/modules/testing/output_normal.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ pub fn (r NormalReporter) progress(index int, message string) {
// in progress mode, the last line will be rewritten many times, and does not end with \n
// the \n will be printed just once when some progress has been made.
pub fn (r NormalReporter) update_last_line(index int, message string) {
print('\r${testing.empty}\r${message}')
print('\r${empty}\r${message}')
flush_stdout()
}

pub fn (r NormalReporter) update_last_line_and_move_to_next(index int, message string) {
// the last \n is needed, so SKIP/FAIL messages
// will not get overwritten by the OK ones
eprint('\r${testing.empty}\r${message}\n')
eprint('\r${empty}\r${message}\n')
}

pub fn (r NormalReporter) message(index int, message string) {
Expand Down
8 changes: 4 additions & 4 deletions examples/eventbus/modules/some_module/some_module.v
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub fn do_work() {
println('working...')
if i == 5 {
event_metadata := &EventMetadata{'Iteration ' + i.str()}
some_module.eb.publish('event_foo', duration, event_metadata)
some_module.eb.publish('event_bar', duration, event_metadata)
eb.publish('event_foo', duration, event_metadata)
eb.publish('event_bar', duration, event_metadata)
}
}
some_module.eb.publish('event_baz', &Duration{42}, &EventMetadata{'Additional data at the end.'})
eb.publish('event_baz', &Duration{42}, &EventMetadata{'Additional data at the end.'})
}

pub fn get_subscriber() eventbus.Subscriber[string] {
return *some_module.eb.subscriber
return *eb.subscriber
}
2 changes: 1 addition & 1 deletion examples/fireworks/modules/objects/constants.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ pub mut:
const params = &UIParams{}

pub fn get_params() &UIParams {
return objects.params
return params
}
2 changes: 1 addition & 1 deletion examples/pendulum-simulation/modules/sim/anim/app.v
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn new_app(args simargs.ParallelArgs) &App {
create_window: true
window_title: 'V Pendulum Simulation'
user_data: app
bg_color: anim.bg_color
bg_color: bg_color
frame_fn: frame
init_fn: init
)
Expand Down
4 changes: 2 additions & 2 deletions examples/pendulum-simulation/modules/sim/args/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub:
pub struct ParallelArgs {
SequentialArgs
pub:
workers int = args.max_parallel_workers
workers int = max_parallel_workers
}

pub type SimArgs = ParallelArgs | SequentialArgs
Expand Down Expand Up @@ -101,7 +101,7 @@ fn parse_parallel_args(extra_workers int) !ParallelArgs {
fp.description('This is a pendulum simulation written in pure V')
fp.skip_executable()

workers := fp.int('workers', 0, args.max_parallel_workers, 'amount of workers to use on simulation. Defaults to ${args.max_parallel_workers}')
workers := fp.int('workers', 0, max_parallel_workers, 'amount of workers to use on simulation. Defaults to ${max_parallel_workers}')

// output parameters
width := fp.int('width', `w`, sim.default_width, 'width of the image output. Defaults to ${sim.default_width}')
Expand Down
12 changes: 6 additions & 6 deletions examples/pendulum-simulation/modules/sim/params.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ pub const default_gravity = 4.9
@[params]
pub struct SimParams {
pub:
rope_length f64 = sim.default_rope_length
bearing_mass f64 = sim.default_bearing_mass
magnet_spacing f64 = sim.default_magnet_spacing
magnet_height f64 = sim.default_magnet_height
magnet_strength f64 = sim.default_magnet_strength
gravity f64 = sim.default_gravity
rope_length f64 = default_rope_length
bearing_mass f64 = default_bearing_mass
magnet_spacing f64 = default_magnet_spacing
magnet_height f64 = default_magnet_height
magnet_strength f64 = default_magnet_strength
gravity f64 = default_gravity
}

pub fn sim_params(params SimParams) SimParams {
Expand Down
27 changes: 14 additions & 13 deletions examples/pendulum-simulation/modules/sim/params_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const params_test_mock_state = SimState{
const params_test_mock_tetha = 2.0 * math.pi / 3.0

pub fn test_get_rope_vector() {
result := sim.params_test_mock_params.get_rope_vector(sim.params_test_mock_state)
result := params_test_mock_params.get_rope_vector(params_test_mock_state)
expected := vector(
x: -0.016957230930171364
y: -0.02937078552673521
Expand All @@ -40,7 +40,7 @@ pub fn test_get_rope_vector() {
}

pub fn test_get_forces_sum() {
result := sim.params_test_mock_params.get_forces_sum(sim.params_test_mock_state)
result := params_test_mock_params.get_forces_sum(params_test_mock_state)
expected := vector(
x: 3.410605131648481e-12
y: 5.229594535194337e-12
Expand All @@ -50,15 +50,15 @@ pub fn test_get_forces_sum() {
}

pub fn test_get_grav_force() {
result := sim.params_test_mock_params.get_grav_force(sim.params_test_mock_state)
result := params_test_mock_params.get_grav_force(params_test_mock_state)
expected := vector(
z: -0.147
)
assert result == expected
}

pub fn test_get_magnet_position() {
result := sim.params_test_mock_params.get_magnet_position(sim.params_test_mock_tetha)
result := params_test_mock_params.get_magnet_position(params_test_mock_tetha)
expected := vector(
x: -0.02499999999999999
y: 0.04330127018922194
Expand All @@ -68,8 +68,7 @@ pub fn test_get_magnet_position() {
}

pub fn test_get_magnet_force() {
result := sim.params_test_mock_params.get_magnet_force(sim.params_test_mock_tetha,
sim.params_test_mock_state)
result := params_test_mock_params.get_magnet_force(params_test_mock_tetha, params_test_mock_state)
expected := vector(
x: -157.4572297692556
y: 1422.736432604726
Expand All @@ -79,14 +78,13 @@ pub fn test_get_magnet_force() {
}

pub fn test_get_magnet_dist() {
result := sim.params_test_mock_params.get_magnet_dist(sim.params_test_mock_tetha,
sim.params_test_mock_state)
result := params_test_mock_params.get_magnet_dist(params_test_mock_tetha, params_test_mock_state)
expected := 0.07993696666249227
assert result == expected
}

pub fn test_get_magnet1_force() {
result := sim.params_test_mock_params.get_magnet1_force(sim.params_test_mock_state)
result := params_test_mock_params.get_magnet1_force(params_test_mock_state)
expected := vector(
x: 1310.8545084099674
y: 575.0062553126633
Expand All @@ -96,7 +94,7 @@ pub fn test_get_magnet1_force() {
}

pub fn test_get_magnet2_force() {
result := sim.params_test_mock_params.get_magnet2_force(sim.params_test_mock_state)
result := params_test_mock_params.get_magnet2_force(params_test_mock_state)
expected := vector(
x: -157.4572297692556
y: 1422.736432604726
Expand All @@ -106,7 +104,7 @@ pub fn test_get_magnet2_force() {
}

pub fn test_get_magnet3_force() {
result := sim.params_test_mock_params.get_magnet3_force(sim.params_test_mock_state)
result := params_test_mock_params.get_magnet3_force(params_test_mock_state)
expected := vector(
x: -1710.46541088048
y: -2962.612996234165
Expand All @@ -116,8 +114,11 @@ pub fn test_get_magnet3_force() {
}

pub fn test_get_tension_force() {
result := sim.params_test_mock_params.get_tension_force(sim.params_test_mock_state,
vector(x: 0.0, y: 0.0, z: 0.0))
result := params_test_mock_params.get_tension_force(params_test_mock_state, vector(
x: 0.0
y: 0.0
z: 0.0
))
expected := vector(x: 0.0, y: 0.0, z: 0.0)
assert result == expected
}
Loading

0 comments on commit 8a72645

Please sign in to comment.