llrt icon indicating copy to clipboard operation
llrt copied to clipboard

Add ci support for windows

Open ahaoboy opened this issue 1 year ago • 14 comments

Description of changes

Add ci support for windows

Checklist

  • [ ] Created unit tests in tests/unit and/or in Rust for my feature if needed
  • [ ] Ran make fix to format JS and apply Clippy auto fixes
  • [ ] Made sure my code didn't add any additional warnings: make check
  • [ ] Added relevant type info in types/ directory
  • [ ] Updated documentation if needed (API.md/README.md/Other)

ahaoboy avatar Aug 11 '24 13:08 ahaoboy

Skipped the windows test for now, because there are too many failures to fix completely in a short period of time.

https://github.com/awslabs/llrt/actions/runs/10340140048/job/28620380619


 FAIL  unit\require.test.js
  ✘ should require a file
  ReferenceError: Error resolving module 'C:wt\llrt/fixtures/hello.js' from '@llrt\test'
  at <anonymous> (bundle/js/__tests__/unit\require.test.js:1:337)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:153)
      at executePromise (@llrt\test:14:1866)
  ✔ should return same module when require multiple files (0 ms)
  ✘ should handle cyclic requires
  ReferenceError: Error resolving module 'C:wt\llrt/fixtures/a.js' from '@llrt\test'
  at <anonymous> (bundle/js/__tests__/unit\require.test.js:1:700)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
  ✘ should handle cjs requires
  ReferenceError: Error resolving module 'C:wt\llrt/fixtures/import.cjs' from '@llrt\test'
  at <anonymous> (bundle/js/__tests__/unit\require.test.js:1:840)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
  ✔ should be able to use node module with prefix `node:` with require (51 ms)


 FAIL  unit\path.test.js
  path.basename
  ✘ should return the last portion of a path
  AssertionError: expected '/foo/bar/baz.txt' to deeply equal 'baz.txt'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:153)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.dirname
  ✘ should return the directory path of a given path
  AssertionError: expected '.' to deeply equal '/foo/bar'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:764)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.extname
  ✔ should return the extension of a given path (1 ms)
  path.format
  ✘ should return a path string from an object
  AssertionError: expected '/foo/bar\baz.txt' to deeply equal '/foo/bar/baz.txt'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:1960)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.parse
  ✘ should return an object from a path string
  AssertionError: expected { root: '\', dir: '/foo/bar', …(3) } to strictly equal { root: '/', dir: '/foo/bar', …(3) }
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:1010)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:2542)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.join
  ✘ should concatenate path segments and normalize the resulting path
  AssertionError: expected '/foo\bar\baz/asdf' to deeply equal '/foo/bar/baz/asdf'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:2825)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.resolve
  ✘ should resolve a sequence of paths and return an absolute path
  AssertionError: expected 'C:/baz' to deeply equal '/foo/bar/baz'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\path.test.js:1:3167)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  path.normalize
  ✔ should normalize a path string (3 ms)
  path.isAbsolute
  ✔ should determine if a path is absolute (1 ms)

 FAIL  unit\fetch.test.js
  fetch
  ✘ should fetch a website
  Error: client error (Connect)
  at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:202)
  ✘ should fetch a website with url and options
  Error: client error (Connect)
  at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:430)
  ✘ should fetch a website with different resource options
  Error: client error (Connect)
  at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:631)
  ✘ should fetch a website in parallel
  Error: client error (Connect)
  at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:1089)
  ✘ is not allowed to fetch
  AssertionError: expected '' to deeply equal 'OK'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:1553)
  ✘ is only allowed to fetch
  AssertionError: expected '' to deeply equal 'OK'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fetch.test.js:4:2015)
  ✔ should be abortable using signals (0 ms)
  ✔ should be abortable using request signal (1 ms)


 FAIL  unit\fs.test.js
  readdir
  ✔ should read a directory (3 ms)
  ✘ should read a directory with types
  AssertionError: expected [ { name: 'config.toml', …(1) } ] to deeply equal [ { name: 'config.toml', …(1) } ]
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:427)
  ✔ should read a directory using default import (1 ms)
  ✔ should read a directory using named import (1 ms)
  ✘ should read a directory with recursive
  AssertionError: expected [ 'readdir.js', 'recursive', …(1) ] to deeply equal [ 'readdir.js', 'recursive', …(1) ]
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:956)
  readdirSync
  ✔ should read a directory synchronously (1 ms)
  ✘ should read a directory with types synchronously
  AssertionError: expected [ { name: 'config.toml', …(1) } ] to deeply equal [ { name: 'config.toml', …(1) } ]
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:1288)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
  ✔ should read a directory using default import synchronously (0 ms)
  ✔ should read a directory using named import synchronously (1 ms)
  ✘ should read a directory with recursive synchronously
  AssertionError: expected [ 'readdir.js', 'recursive', …(1) ] to deeply equal [ 'readdir.js', 'recursive', …(1) ]
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:1820)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
  readfile
  ✔ should read a file (1 ms)
  ✔ should return a string when encoding is provided as option (7 ms)
  ✔ should return a string when encoding is provided as string (24 ms)
  ✔ should return a string when encoding is provided as string with different cases (4 ms)
  readfileSync
  ✔ should read a file synchronously (1 ms)
  ✔ should return a string when encoding is provided as option synchronously (0 ms)
  ✔ should return a string when encoding is provided as string synchronously (0 ms)
  ✔ should return a string when encoding is provided as string with different cases synchronously (0 ms)
  mkdtemp
  ✔ should create a temporary directory with a given prefix (1 ms)
  mkdtempSync
  ✔ should create a temporary directory with a given prefix synchronously (0 ms)
  mkdir
  ✔ should create a directory with the given path (1 ms)
  mkdirSync
  ✘ should create a directory with the given path synchronously
  AssertionError: expected [Function] to throw error matching /[fF]ile.*exists/ but got 'Can\'t create dir "C:msys64\tmp\test/…'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at assertThrows (@llrt\test:6:34594)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at apply (native)
      at <anonymous> (@llrt\test:12:706)
      at apply (native)
      at overwritingMethodWrapper (@llrt\test:6:14387)
      at <anonymous> (@llrt\test:12:4971)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:4964)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
      at execute (@llrt\test:15:411)
  writeFile
  ✔ should write a file (1 ms)
  writeFile synchronously
  ✔ should write a file (1 ms)
  rm
  ✔ should delete file and directory (41 ms)
  ✘ should throw an error if file does not exists
  AssertionError: expected [Function] to throw error matching /[Nn]o such file or directory/ but got '系统找不到指定的文件。 (os error 2)'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at assertThrows (@llrt\test:6:34594)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at apply (native)
      at <anonymous> (@llrt\test:12:706)
      at apply (native)
      at overwritingMethodWrapper (@llrt\test:6:14387)
      at <anonymous> (@llrt\test:12:4971)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at call (native)
      at <anonymous> (@llrt\test:12:7699)
  ✔ should not throw an error if file does not exists and force is used (1 ms)
  rmSync
  ✔ should delete file and directory with rm synchronously (2 ms)
  ✘ should throw an error if file does not exists with rm synchronously
  AssertionError: expected [Function] to throw error matching /[Nn]o such file or directory/ but got 'IO Error: 系统找不到指定的文件。 (os error 2)'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at assertThrows (@llrt\test:6:34594)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at apply (native)
      at <anonymous> (@llrt\test:12:706)
      at apply (native)
      at overwritingMethodWrapper (@llrt\test:6:14387)
      at <anonymous> (@llrt\test:12:4971)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\fs.test.js:1:7175)
      at executeAsyncOrCallbackFn (@llrt\test:14:1453)
      at runTests (@llrt\test:14:1617)
  ✔ should not throw an error if file does not exists and force is used with rm synchronously (1 ms)
  access
  ✔ should access a file (0 ms)
  ✔ should throw if not proper permissions (0 ms)
  ✔ should throw if not exists (0 ms)
  ✔ should access a file using default import (0 ms)
  ✔ should access a file using named import (0 ms)
  accessSync
  ✔ should access a file synchronously (0 ms)
  ✔ should throw if not proper permissions synchronously (1 ms)
  ✔ should throw if not exists synchronously (0 ms)



 FAIL  unit\compile.test.js
  llrt compile
  ✘ can compile and run empty
  AssertionError: expected 'SIGKILL' to deeply equal undefined
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\compile.test.js:1:769)
  ✘ can compile and run console.log
  AssertionError: expected 'SIGKILL' to deeply equal undefined
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\compile.test.js:1:1045)
  ✘ can compile and run throws
  AssertionError: expected 'SIGKILL' to deeply equal undefined
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\compile.test.js:2:208)

123

 FAIL  unit\child_process.test.js
  child_process.spawn
  ✔ should spawn a child process (36 ms)
  ✘ should spawn in a diffrent directory
  AssertionError: expected '/c/wt/llrt/tests' to deeply equal 'C:\wt\llrt/tests'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\child_process.test.js:1:351)
  ✔ should capture output from the child process (21 ms)
  ✔ should send input to the child process (22 ms)
  ✔ should handle errors from the child process (0 ms)
  ✘ should handle child process termination
  AssertionError: expected 'SIGKILL' to deeply equal 'SIGINT'
  at AssertionError (@llrt\test:5:3869)
      at <anonymous> (@llrt\test:6:10926)
      at <anonymous> (@llrt\test:12:806)
      at apply (native)
      at methodWrapper (@llrt\test:6:13498)
      at <anonymous> (bundle/js/__tests__/unit\child_process.test.js:1:1252)
  ✔ should handle child process stdio inherit (21 ms)
  ✔ should handle child process stdio ignore (23 ms)

ahaoboy avatar Aug 11 '24 14:08 ahaoboy

Nice job!!

Sytten avatar Aug 11 '24 15:08 Sytten

Although Windows still has some bugs, it can be used to test its performance. Here, llrt and tjs are used to measure the rendering events of a command line library. Since both use qjs, the difference is not obvious.

https://ahaoboy.github.io/r-tui-bench/

ahaoboy avatar Aug 11 '24 15:08 ahaoboy

Ha yeah I see some of the errors, mostly filesystem and process related. I think the llrt_modules is pretty universal but the code seems to need to some help

Sytten avatar Aug 11 '24 17:08 Sytten

Although Windows still has some bugs, it can be used to test its performance. Here, llrt and tjs are used to measure the rendering events of a command line library. Since both use qjs, the difference is not obvious.

https://ahaoboy.github.io/r-tui-bench/

This is awesome and very interesting. I suspect the increased (relative) performance in tis comes from tjs Uses QuickJS-ng and Bellards QuickJS. However these two repos will eventually converge and we'll see more activity and openness from this amazing project.

richarddavison avatar Aug 11 '24 20:08 richarddavison

Ha yeah I see some of the errors, mostly filesystem and process related. I think the llrt_modules is pretty universal but the code seems to need to some help

Yes, there are a lot of tests that fail, mostly platform-specific path handling, file, and even some network library errors.

ahaoboy avatar Aug 12 '24 02:08 ahaoboy

It seems to work correctly ~ image

ahaoboy avatar Aug 12 '24 02:08 ahaoboy

Hi @ahaoboy , very nice work!!

By the way, does make release-all work without any errors at all on your local laptop now? You have added a windows condition to the Makefile this time and I am wondering if it is affected.

nabetti1720 avatar Aug 12 '24 02:08 nabetti1720

By the way, does make release-all work without any errors at all on your local laptop now? You have added a windows condition to the Makefile this time and I am wondering if it is affected.

It doesn't work on windows, because windows cannot compiled to linux. It is best to use cross for multi-platform compilation.

ahaoboy avatar Aug 12 '24 02:08 ahaoboy

By the way, does make release-all work without any errors at all on your local laptop now? You have added a windows condition to the Makefile this time and I am wondering if it is affected.

It doesn't work on windows, because windows cannot compiled to linux. It is best to use cross for multi-platform compilation.

I see. I don't know the result because I can't try it yet, but on the other hand, would it work on linux or macos? Even if it works, I feel that I have already lost the motivation to keep make release-all as long as I can already generate artifacts for each architecture on GitHub.

nabetti1720 avatar Aug 12 '24 03:08 nabetti1720

There is a random socket test error

https://github.com/awslabs/llrt/actions/runs/10348831471/job/28641947417?pr=536

https://github.com/awslabs/llrt/actions/runs/10352573355/job/28653525847

ahaoboy avatar Aug 12 '24 09:08 ahaoboy

There is a random socket test error

https://github.com/awslabs/llrt/actions/runs/10348831471/job/28641947417?pr=536

https://github.com/awslabs/llrt/actions/runs/10352573355/job/28653525847

This feels like a race condition. Happens for other builds as well. I suspect we prematurely close the connection before the client receives response in a test. It’s a bit hard to reproduce as it only happens in CI.

richarddavison avatar Aug 13 '24 05:08 richarddavison

This feels like a race condition. Happens for other builds as well. I suspect we prematurely close the connection before the client receives response in a test. It’s a bit hard to reproduce as it only happens in CI.

This error will directly cause the program to exit, so it is not certain which test case failed.

ahaoboy avatar Aug 13 '24 08:08 ahaoboy

This feels like a race condition. Happens for other builds as well. I suspect we prematurely close the connection before the client receives response in a test. It’s a bit hard to reproduce as it only happens in CI.

This error will directly cause the program to exit, so it is not certain which test case failed.

Yes, thats why I’m refactoring the test runner to expose a server that spawns child processes to execute each test. That way we’ll know what test fails and can hide console output etc.

richarddavison avatar Aug 16 '24 06:08 richarddavison

@ahaoboy please rebase

richarddavison avatar Aug 20 '24 11:08 richarddavison