Skip to content

Conversation

chethanuk
Copy link

@chethanuk chethanuk commented Aug 20, 2025

Summary

  • CI expanded to Linux & Windows with OS-aware tooling, improved caching, hardened Windows installer, pre-build formatting/lint checks, and faster parallel builds; publishing remains Linux-only. Added Cargo build parallelism and workspace manifest updates.
  • Cross-platform filesystem, permissions, TTY, and Windows-target support with WASM workspace member and public re-exports. Windows path normalization and canonicalization improvements.
  • OS-aware toolchain setup ensures required targets are available on all platforms
  • Tests
    • Extensive cross-platform unit and integration tests covering functionality, edge cases, performance, and concurrency.

Tests Results:

 [test] $ cargo test --test cross_platform_tests -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.53s
     Running tests\cross_platform_tests.rs (C:\Users\Administrator\moonbit-component-generator\target\debug\deps\cross_platform_tests-666948c3be9cee4f.exe)

running 35 tests
✅ File operations (r=false, w=true, a=false) - Size: 15, Mode: 0o40File operations (r=false, w=true, a=true) - Size: 15, Mode: 0o40File operations (r=true, w=true, a=false) - Size: 15, Mode: 0o40Edge case 'nonexistent.txt' handled correctly
✅ Edge case '' handled correctly
✅ empty file - Size: 0, Dev: 32, Ino: 134001505335284105, ATime: 1755676933, MTime: 1755676933, CTime: 1755676933
✅ small file - Size: 42, Dev: 32, Ino: 134001505335284147, ATime: 1755676933, MTime: 1755676933, CTime: 1755676933File operations (r=true, w=false, a=false) - Size: 15, Mode: 0o40
test test_file_operations_cross_platform::case_4_append_mode ... ok
test test_metadata_edge_cases::case_2_empty_filename ... ok
test test_file_operations_cross_platform::case_3_read_write ... ok
✅ medium file - Size: 1024, Dev: 32, Ino: 134001505335345087, ATime: 1755676933, MTime: 1755676933, CTime: 1755676933
test test_metadata_edge_cases::case_1_nonexistent_file ... ok
test test_file_operations_cross_platform::case_2_write_only ... ✅ large file - Size: 65536, Dev: 32, Ino: 134001505335419706, ATime: 1755676933, MTime: 1755676933, CTime: 1755676933
ok
test test_metadata_file_sizes::case_1_empty_file ... ok✅ Performance test - 1000 iterations in 65.8µs (avg: 65ns per iteration)
✅ read-only file - Mode: 0o41, Size: 32, UID: 0, GID: 0, Links: 1

test test_metadata_file_sizes::case_2_small_file ... ok
✅ read-write file - Mode: 0o40, Size: 33, UID: 0, GID: 0, Links: 1
test test_file_operations_cross_platform::case_1_read_only ... ✅ full permissions - Mode: 0o40, Size: 34, UID: 0, GID: 0, Links: 1
✅ executable file - Mode: 0o40, Size: 33, UID: 0, GID: 0, Links: 1
ok
test test_metadata_file_sizes::case_3_medium_file ... ok
test test_metadata_file_sizes::case_4_large_content ... ok
test test_metadata_performance ... ok
✅ owner only permissions - Mode: 0o40, Size: 40, UID: 0, GID: 0, Links: 1
test test_metadata_permissions::case_1_read_only ... ok
test test_metadata_permissions::case_2_read_write ... ok
test test_metadata_permissions::case_4_full_permissions ... ok
test test_metadata_permissions::case_3_executable ... okWindows permissions builder test for mode 0o0: Ok(())Permissions 0o0 - Builder succeeded
Windows permissions builder test for mode 0o400: Ok(())Permissions 0o400 - Builder succeeded
✅ no write permissions - Mode: 0o41, Size: 38, UID: 0, GID: 0, Links: 1
Windows permissions builder test for mode 0o200: Ok(())Permissions 0o200 - Builder succeeded

Windows permissions builder test for mode 0o100: Ok(())
test test_metadata_permissions::case_6_owner_only ... ✅ Permissions 0o100 - Builder succeeded
okWindows permissions builder test for mode 0o40: Ok(())Permissions 0o40 - Builder succeeded

test test_permissions_builder::case_01_no_permissions ... ok
test test_permissions_builder::case_02_owner_read ... ok
Windows permissions builder test for mode 0o20: Ok(())Permissions 0o20 - Builder succeeded
test test_metadata_permissions::case_5_no_write ... ok
Windows permissions builder test for mode 0o10: Ok(())Permissions 0o10 - Builder succeeded
test test_permissions_builder::case_03_owner_write ... ok
Windows permissions builder test for mode 0o4: Ok(())Permissions 0o4 - Builder succeeded
test test_permissions_builder::case_04_owner_execute ... ok
Windows permissions builder test for mode 0o2: Ok(())Permissions 0o2 - Builder succeeded
test test_permissions_builder::case_05_group_read ... ok
Windows permissions builder test for mode 0o1: Ok(())Permissions 0o1 - Builder succeeded
test test_permissions_builder::case_06_group_write ... ok
Windows permissions builder test for mode 0o644: Ok(())Permissions 0o644 - Builder succeeded
test test_permissions_builder::case_07_group_execute ... ok
Windows permissions builder test for mode 0o755: Ok(())Permissions 0o755 - Builder succeeded
test test_permissions_builder::case_08_other_read ... ok
Windows permissions builder test for mode 0o600: Ok(())Permissions 0o600 - Builder succeeded
test test_permissions_builder::case_10_other_execute ... Windows permissions builder test for mode 0o644: Ok(())Permissions 0o644 - Builder succeeded
ok
test test_permissions_builder::case_09_other_write ... ok
test test_permissions_builder::case_11_common_file ... ok
✅ O_DSYNC = 0x0 (0)O_NONBLOCK = 0x1000 (4096)O_SYNC = 0x0 (0)O_NOCTTY = 0x0 (0)
test test_permissions_builder::case_12_common_executable ... ok
test test_permissions_builder::case_13_restricted ... ok
test test_permissions_builder::case_14_public_read ... ok
test test_platform_constants::case_3_dsync ... ok
test test_platform_constants::case_1_nonblock ... ok
test test_platform_constants::case_4_sync ... ok
test test_platform_constants::case_2_noctty ... ok

test result: ok. 35 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s

[test] $ cargo test --test integration_tests -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.56s
     Running tests\integration_tests.rs (C:\Users\Administrator\moonbit-component-generator\target\debug\deps\integration_tests-4e1fca19c6da1c35.exe)

running 11 tests
✅ stderr (fd=2) host_isatty result: 0Nonexistent file error handling works correctly
✅ Complete metadata workflow for regular.txt - { kind: 0, dev: 32, ino: 134001505343492923, mode: 32, nlink: 1, uid: 0, gid: 0, rdev: 32, size: 20, atime: 1755676934, mtime: 1755676934, ctime: 1755676934 }
Windows restrictive permissions result: Ok(())Permission scenarios handled appropriately
test file_operations_integration::test_standard_io_descriptors::case_3_stderr ... ok
test error_handling_integration::test_nonexistent_file_handling ... ok
✅ stdout (fd=1) host_isatty result: 0Complete metadata workflow for script.sh - { kind: 0, dev: 128, ino: 134001505343492933, mode: 128, nlink: 1, uid: 0, gid: 0, rdev: 128, size: 30, atime: 1755676934, mtime: 1755676934, ctime: 1755676934 }
✅ stdin (fd=0) host_isatty result: 1
test metadata_integration_tests::test_complete_metadata_workflow::case_1_regular_file ... ok
test error_handling_integration::test_permission_scenarios ... ok
test file_operations_integration::test_standard_io_descriptors::case_2_stdout ... ok
test file_operations_integration::test_standard_io_descriptors::case_1_stdin ... ok✅ Directory metadata - Kind: 1, Mode: 0o20, Links: 1

Windows file handle: 0x154File descriptor operations work across platforms
test metadata_integration_tests::test_complete_metadata_workflow::case_2_executable_script ... ok
test metadata_integration_tests::test_directory_metadata ... ok
test file_operations_integration::test_file_descriptor_operations ... ok
✅ Concurrent metadata operations completed successfully
test performance_integration::test_concurrent_metadata_operations ... ok
✅ Performance integration - 100 files in 13.1509ms (avg: 131μs per file)
test performance_integration::test_metadata_performance_integration ... ok

test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.15s

[test] $ cargo test --test simple_test -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.53s
     Running tests\simple_test.rs (C:\Users\Administrator\moonbit-component-generator\target\debug\deps\simple_test-19f87d9f942e492a.exe)

running 2 tests
✅ Platform constants are accessible
test test_platform_constants ... ok
✅ Basic cross-platform test passed - Size: 12
test test_basic_functionality ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

[test] $ cargo test --lib -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.56s
     Running unittests src\lib.rs (C:\Users\Administrator\moonbit-component-generator\target\debug\deps\moonc_wasm-53483de0fc51b332.exe)

running 2 tests
test cross_platform::tests::test_permission_creation ... ok
test cross_platform::tests::test_cross_platform_metadata ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Cippy:
Screenshot 2025-08-20 at 3 09 40 PM

Cross Tests:
Screenshot 2025-08-20 at 3 09 28 PM

@chethanuk
Copy link
Author

@vigoo Please check if I am in right direction - Let me know if I have to change anything :)

run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- 0.6.19
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: Install moonbit (Windows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library's purpose is to embed the moonbit compiler in a way that the users don't have to install it separately (it contains a version of it compiled to WASM, executed on V8). So the CI definitely should not install the moonbit compiler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I realized it's needed for bundling the core library.

@@ -0,0 +1,4 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these moonbit module definitions added?

lazy_static = "1.5.0"
libc = "0.2.172"
log = "0.4.27"
moonc_wasm = { path = "moonc_wasm" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added with source linking and not as a real dependency because it's a crate belonging to the moonbit project, but they did not publish it to crates.io. If you add it as a dep here, we cannot publish a new version of moonbit-component-generator without first publishing moonc_wasm too, which I don't want to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants