Skip to content

Fixes for build and tests - #11274

Closed
mukunda- wants to merge 5 commits into
typeorm:masterfrom
mukunda-:fix-build-test
Closed

mukunda- wants to merge 5 commits into
typeorm:masterfrom
mukunda-:fix-build-test

Conversation

@mukunda-

@mukunda- mukunda- commented Feb 4, 2025

Copy link
Copy Markdown
Contributor

Description of change

While trying to build and test #11271, I ran into a handful of issues. This PR contains a list of commits to get the build process working on Windows, as well as some other fixes in the tests.

See the commit details for each one for additional info. Brief summary:

  • fix multi-database-basic-functionality: This test was corrupting the process.platform setting for later tests. Also incorrect test logic. Broken test case for filepathToName #11272
  • fix rimraf usage: The current rimraf package has some breaking changes and requires an option to be specified to work with globs. Otherwise the build fails.
  • port number missing for issues test 4753: This test was missing the port number in the configuration block, causing a fail if using nonstandard ports for mysql.
  • windows support for issue 8975 test: This test was failing on Windows as it relied on a Unix shebang/executing JS scripts directly.
  • fix issue 9230 test for western timezones: This test was not working if you have a western timezone (which would subtract 1 from the day).

Only one of these fixes has a corresponding issue opened.

Fixes #11272

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change N/A - no functionality changes
  • The new commits follow conventions explained in CONTRIBUTING.md

This test was not written properly, causing persistent changes to the process.platform which was breaking other tests. It was also not testing "darwin" properly.

Change the code to properly restore the process.platform when it's finished, as well as testing "darwin". Remove the filepath comparison when testing non-Windows behavior, where the filepath is used as-is.

Also update required rimraf usage for globs.

Closes: typeorm#11272
The build was not working with the current rimraf package. Newer usage requires setting the `glob` option to use globs in the file path, otherwise you get an error with glob patterns.

Update rimraf calls to have the glob option set.
If the test ormconfig uses a port other than the default 3306 for mysql/mariadb, this test won't work. Apply the correct port from the connectionOptions.
This test was setting the executable flag on the cli.js file and then running it. That doesn't work on Windows.

Improve cross-platform build support. Change the cliPath to use `node`. Remove the `chmod` code as that is not necessary if calling node directly.

Change fs.rmdir to fs.rm (other is deprecated).
This test was failing if your timezone was west of UTC.

Add the current timezone offset to the date being checked.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 72.366% (-0.003%) from 72.369%
when pulling ac023fa on mukunda-:fix-build-test
into 79960e1 on typeorm:master.

@OSA413

OSA413 commented Feb 5, 2025 •

Copy link
Copy Markdown
Collaborator

possible duplicate of #11257

upd: looks like you are fixing several issues at once, I think we should either accumulate the changes in this PR or split this PR into multiple PRs, I'll look at the related issues and and review this PR.

@OSA413

OSA413 commented Feb 5, 2025

Copy link
Copy Markdown
Collaborator

I think that the approach for multi-database-basic-functionality fix should be that we don't overwrite the process.platform at all. I'll call other maintainers to judge us.

Everything else looks fine.

@mukunda-

mukunda- commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. Admittedly I didn't do a very thorough search for duplicates of these fixes. I'm a bit of a foreigner to this area and I'm fine with any conventions in place to merge/split fixes (not sure if a merge commit is used or not either).

I agree that touching process.platform is a bit iffy - the only upside is that it will increase test coverage

@alumni alumni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some of these were already fixed, would be great to update the branch and see what's left.

}

await Promise.all([chmodCli(), copyPackageJson()])
await Promise.all([copyPackageJson()])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

await copyPackageJson() is enough, no need to wrap it in Promise.all.

@OSA413

OSA413 commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

Yeah, looks like most of the fixes were introduced by other PRs.

@pkuczynski

Copy link
Copy Markdown
Member

@mukunda- do you want to continue this, or someone else should take over?

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mukunda- thanks for opening this PR.
I'm closing this for now because it's stale and has conflicts, feel free to create a new PR with your improvements. 💪

@gioboa gioboa closed this Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Broken test case for filepathToName

6 participants