-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
test: Test surrogate pair filenames on windows #51800
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4e0eaf3
test: test surrogate pair filenames on windows
9c2b48f
lint
6c7c777
Update test/common/file-ops-with-surrogate-pairs-on-windows.js
mertcanaltin cdacdd2
Update test/common/file-ops-with-surrogate-pairs-on-windows.js
mertcanaltin 130b9ed
Update test/common/file-ops-with-surrogate-pairs-on-windows.js
mertcanaltin 7653f16
fix: test rename & repair
b097320
fix: un used os
b5b8045
Update file-operations-with-surrogate-pairs.js
mertcanaltin 3bb203f
feat: moved test file to parallel path
b75b7c0
:Merge branch 'dev-51789' of https://github.com/mertcanaltin/node int…
085c4c4
fix: used tmpdir
1f2671a
Update fs-operations-with-surrogate-pairs.js
mertcanaltin b91c291
Update fs-operations-with-surrogate-pairs.js
mertcanaltin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| 'use strict'; | ||
|
|
||
| const fs = require('node:fs'); | ||
| const path = require('path'); | ||
| const assert = require('assert/strict'); | ||
mertcanaltin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const { describe, it } = require('node:test'); | ||
|
|
||
| describe('File operations with filenames containing surrogate pairs', () => { | ||
| it('should write, read, and delete a file with surrogate pairs in the filename', () => { | ||
| // Create a temporary directory | ||
| const tempdir = fs.mkdtempSync('emoji-fruit-🍇 🍈 🍉 🍊 🍋'); | ||
| assert.strictEqual(fs.existsSync(tempdir), true); | ||
|
|
||
| const filename = '🚀🔥🛸.txt'; | ||
| const content = 'Test content'; | ||
|
|
||
| // Write content to a file | ||
| fs.writeFileSync(path.join(tempdir, filename), content); | ||
|
|
||
| // Read content from the file | ||
| const readContent = fs.readFileSync(path.join(tempdir, filename), 'utf8'); | ||
|
|
||
| // Check if the content matches | ||
| assert.strictEqual(readContent, content); | ||
|
|
||
| // Get directory contents | ||
| const dirs = fs.readdirSync(tempdir); | ||
| assert.strictEqual(dirs.length > 0, true); | ||
|
|
||
| // Check if the file is in the directory contents | ||
| let match = false; | ||
| for (let i = 0; i < dirs.length; i++) { | ||
| if (dirs[i].endsWith(filename)) { | ||
| match = true; | ||
| break; | ||
| } | ||
| } | ||
| assert.strictEqual(match, true); | ||
|
|
||
| // Delete the file | ||
| fs.unlinkSync(path.join(tempdir, filename)); | ||
| assert.strictEqual(fs.existsSync(path.join(tempdir, filename)), false); | ||
|
|
||
| // Remove the temporary directory | ||
| fs.rmdirSync(tempdir); | ||
| assert.strictEqual(fs.existsSync(tempdir), false); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.