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

fix(tests): fix tests run fail in the Chinese directory #3586

Merged
merged 1 commit into from
May 29, 2021

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented May 29, 2021

Description

in #3582

when vite's workspace contains Chinese directory,vite tests run fails in Windows

it is caused by the slash component vite use to convert Windows backslash paths to slash paths

e.g the path foo/bar in Unix will be slashed to be foo\\bar in Windows

however,while the directory containes Chinese charactor,the slash will return the original path, which will not be converted according to the source code.

export default function slash(path) {
	const isExtendedLengthPath = /^\\\\\?\\/.test(path);
	const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex

        // hit this statement and return the original path
	if (isExtendedLengthPath || hasNonAscii) {
		return path;
	}

	return path.replace(/\\/g, '/');
}

by the way, I found out that vite implements its own slash function in the utils file,but the test cases are still use the slash component,This is what caused the test cases run fail

···
export function slash(p: string): string {
return p.replace(/\/g, '/')
}
···

Close #3582

What is the purpose of this pull request?

  • Bug fix

@antfu antfu merged commit 3cab2c2 into vitejs:main May 29, 2021
ygj6 added a commit to ygj6/vite that referenced this pull request Jun 1, 2021
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.

vite tests will run fail in the Chinese directory
3 participants