dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
115 stars 40 forks source link

[infra][ffigen] `test/setup.dart` failures don't fail the CI #1477

Open Levi-Lesches opened 2 weeks ago

Levi-Lesches commented 2 weeks ago

Take output from this job

Run dart test/setup.dart

Running build_test_dylib.dart in D:\a\native\native\pkgs\ffigen\test\native_test\
Building Dynamic Library for Native Tests... 
native_test.def : error LNK2001: unresolved external symbol Enum1
native_test.def : error LNK2001: unresolved external symbol Enum2
native_test.def : error LNK2001: unresolved external symbol StructWithEnums
native_test.lib : fatal error LNK[11](https://github.com/dart-lang/native/actions/runs/10461232655/job/29098801644#step:5:12)20: 3 unresolved externals

clang: error: linker command failed with exit code 1[12](https://github.com/dart-lang/native/actions/runs/10461232655/job/29098801644#step:5:13)0 (use -v to see invocation)

Success :)

Which leads to all the tests running, then the native test failing:

❌ test\native_test\native_test.dart: native_test (setUpAll) (failed)
  The file test\native_test\native_test.dll does not exist.

  You may need to run: dart run test/setup.dart

  test\test_utils.dart 43:5               verifySetupFile
  test\native_test\native_test.dart 28:7  main.<fn>.<fn>

Not a big deal imo, but it would probably be cleaner to fail early

Levi-Lesches commented 2 weeks ago

@dcharkes Seems like @fan1chun might be promoting malware, and they posted immediately as I posted the issue.

dcharkes commented 2 weeks ago

https://github.com/dart-lang/native/blob/c329cf9205428c6f056f600c61ec4e8cc120fd95/.github/workflows/ffigen.yml#L44-L45

This should be exiting with a non-zero exit code?

Levi-Lesches commented 2 weeks ago

I think I see the problem. setup.dart is clearly not failing because it reaches the :) print at the end. But that file calls another dart file to actually build, test/native_test/build_test_dylib.dart, which prints the result of clang but doesn't exit with any special code or throw any error, meaning it always exits with 0

If we add an exit line to that file, setup.dart would catch it and exit with a non-zero code as well.