Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with windows 11 #19

Open
tb01923 opened this issue Apr 7, 2024 · 3 comments
Open

Issues with windows 11 #19

tb01923 opened this issue Apr 7, 2024 · 3 comments

Comments

@tb01923
Copy link

tb01923 commented Apr 7, 2024

Hello I am working on Windows 11 (my personal laptop) with ReScript 11. I am looking to learn more about ReScript and want to explore testing. This framework looks to be all i need, but it doesn't seem to be working correctly

  1. it looks like the retest cli is being squashed by windows (a terminal window pops up and closes; i don't see anything in the event log
  2. I have been runnign directly node ./node_modules/rescript-test/bin/retest.mjs
  3. that only works if I path specifically to the test file, the wildcarding isn't working, e.g.,
  4. works: node ./node_modules/rescript-test/bin/retest.mjs tests/entities/parser/test_parser.bs.js
  5. doesn't work: node ./node_modules/rescript-test/bin/retest.mjs tests/entities/parser/*.bs.js
  6. doesn't work node ./node_modules/rescript-test/bin/retest.mjs tests/entities/**/test_parser.bs.js

I am a hobbiest at this point in my career (software executive) and have some rusty skills - so I may be missing something obviuos. I have added some debugging into retest.mjs and I don't think the glob nodeback is returning or isn't returning and the promises are not properly waited upon. The script does exit which indicates that the promises are not being waited on - but the code looks cool correct...

Logging in the event that I am missing something obvious. Will update if I uncover anything else

@tb01923

This comment was marked as outdated.

@tb01923
Copy link
Author

tb01923 commented Apr 13, 2024

Stepping thorugh there is this bit of lines

 glob(globOrName, (err, files) => {
      if (err) {
              reject(err);
      } else {
        resolve(files);
      }
)

within retest.mjs

leverages this code from glob:

async function glob_(pattern, options = {}) {
    return new Glob(pattern, options).walk();
}
/* snip */
export const glob = Object.assign(glob_, {
    glob: glob_,
})

from glob/index.js

which in turn invokes: the Glob constructor:

    constructor(pattern, opts) {...}

but the opts isn't a callback like the code in restest.mjs would indicate. further the walk object on that function just returns those files...

also glob documentation https://github.com/isaacs/node-glob shows the glob function returning a promise not callbacks
const results = await glob('**', { stat: true, withFileTypes: true })

@tb01923
Copy link
Author

tb01923 commented Apr 13, 2024

Changing the code in https://github.com/bloodyowl/rescript-test/blob/main/bin/retest.mjs

from

if (globsOrNames.some((item) => item.includes("*"))) {
  globsOrNames = await Promise.all(
    globsOrNames.map(
      (globOrName) =>
        new Promise((resolve, reject) => {
          glob(globOrName, (err, files) => {
            if (err) {
              reject(err);
            } else {
              resolve(files);
            }
          });
        })
    )
  ).then((arrays) => [...new Set([].concat(...arrays))]);
}

to

if (globsOrNames.some((item) => item.includes("*"))) {
  globsOrNames = await Promise.all(
    globsOrNames.map(
      (globOrName) => glob(globOrName)
    )
  ).then((arrays) => [...new Set([].concat(...arrays))]);
}

looks to fix the issue. @bloodyowl happy to issue a PR if this approach looks reasonable

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

No branches or pull requests

1 participant