| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 793a5bb commit af6b824
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,13 +10,12 @@ const { isDate } = require('util').types; | |||
| 10 | 10 | ||
| 11 | 11 | tmpdir.refresh(); | |
| 12 | 12 | ||
| 13 | - const fn = path.join(tmpdir.path, 'test-file'); | ||
| 14 | - fs.writeFileSync(fn, 'test'); | ||
| 13 | + let testIndex = 0; | ||
| 15 | 14 | ||
| 16 | - let link; | ||
| 17 | - if (!common.isWindows) { | ||
| 18 | - link = path.join(tmpdir.path, 'symbolic-link'); | ||
| 19 | - fs.symlinkSync(fn, link); | ||
| 15 | + function getFilename() { | ||
| 16 | + const filename = path.join(tmpdir.path, `test-file-${++testIndex}`); | ||
| 17 | + fs.writeFileSync(filename, 'test'); | ||
| 18 | + return filename; | ||
| 20 | 19 | } | |
| 21 | 20 | ||
| 22 | 21 | function verifyStats(bigintStats, numStats) { | |
@@ -74,34 +73,43 @@ function verifyStats(bigintStats, numStats) { | |||
| 74 | 73 | } | |
| 75 | 74 | ||
| 76 | 75 | { | |
| 77 | - const bigintStats = fs.statSync(fn, { bigint: true }); | ||
| 78 | - const numStats = fs.statSync(fn); | ||
| 76 | + const filename = getFilename(); | ||
| 77 | + const bigintStats = fs.statSync(filename, { bigint: true }); | ||
| 78 | + const numStats = fs.statSync(filename); | ||
| 79 | 79 | verifyStats(bigintStats, numStats); | |
| 80 | 80 | } | |
| 81 | 81 | ||
| 82 | 82 | if (!common.isWindows) { | |
| 83 | + const filename = getFilename(); | ||
| 84 | + const link = `${filename}-link`; | ||
| 85 | + fs.symlinkSync(filename, link); | ||
| 83 | 86 | const bigintStats = fs.lstatSync(link, { bigint: true }); | |
| 84 | 87 | const numStats = fs.lstatSync(link); | |
| 85 | 88 | verifyStats(bigintStats, numStats); | |
| 86 | 89 | } | |
| 87 | 90 | ||
| 88 | 91 | { | |
| 89 | - const fd = fs.openSync(fn, 'r'); | ||
| 92 | + const filename = getFilename(); | ||
| 93 | + const fd = fs.openSync(filename, 'r'); | ||
| 90 | 94 | const bigintStats = fs.fstatSync(fd, { bigint: true }); | |
| 91 | 95 | const numStats = fs.fstatSync(fd); | |
| 92 | 96 | verifyStats(bigintStats, numStats); | |
| 93 | 97 | fs.closeSync(fd); | |
| 94 | 98 | } | |
| 95 | 99 | ||
| 96 | 100 | { | |
| 97 | - fs.stat(fn, { bigint: true }, (err, bigintStats) => { | ||
| 98 | - fs.stat(fn, (err, numStats) => { | ||
| 101 | + const filename = getFilename(); | ||
| 102 | + fs.stat(filename, { bigint: true }, (err, bigintStats) => { | ||
| 103 | + fs.stat(filename, (err, numStats) => { | ||
| 99 | 104 | verifyStats(bigintStats, numStats); | |
| 100 | 105 | }); | |
| 101 | 106 | }); | |
| 102 | 107 | } | |
| 103 | 108 | ||
| 104 | 109 | if (!common.isWindows) { | |
| 110 | + const filename = getFilename(); | ||
| 111 | + const link = `${filename}-link`; | ||
| 112 | + fs.symlinkSync(filename, link); | ||
| 105 | 113 | fs.lstat(link, { bigint: true }, (err, bigintStats) => { | |
| 106 | 114 | fs.lstat(link, (err, numStats) => { | |
| 107 | 115 | verifyStats(bigintStats, numStats); | |
@@ -110,7 +118,8 @@ if (!common.isWindows) { | |||
| 110 | 118 | } | |
| 111 | 119 | ||
| 112 | 120 | { | |
| 113 | - const fd = fs.openSync(fn, 'r'); | ||
| 121 | + const filename = getFilename(); | ||
| 122 | + const fd = fs.openSync(filename, 'r'); | ||
| 114 | 123 | fs.fstat(fd, { bigint: true }, (err, bigintStats) => { | |
| 115 | 124 | fs.fstat(fd, (err, numStats) => { | |
| 116 | 125 | verifyStats(bigintStats, numStats); | |
@@ -120,21 +129,26 @@ if (!common.isWindows) { | |||
| 120 | 129 | } | |
| 121 | 130 | ||
| 122 | 131 | (async function() { | |
| 123 | - const bigintStats = await promiseFs.stat(fn, { bigint: true }); | ||
| 124 | - const numStats = await promiseFs.stat(fn); | ||
| 132 | + const filename = getFilename(); | ||
| 133 | + const bigintStats = await promiseFs.stat(filename, { bigint: true }); | ||
| 134 | + const numStats = await promiseFs.stat(filename); | ||
| 125 | 135 | verifyStats(bigintStats, numStats); | |
| 126 | 136 | })(); | |
| 127 | 137 | ||
| 128 | 138 | if (!common.isWindows) { | |
| 129 | 139 | (async function() { | |
| 140 | + const filename = getFilename(); | ||
| 141 | + const link = `${filename}-link`; | ||
| 142 | + fs.symlinkSync(filename, link); | ||
| 130 | 143 | const bigintStats = await promiseFs.lstat(link, { bigint: true }); | |
| 131 | 144 | const numStats = await promiseFs.lstat(link); | |
| 132 | 145 | verifyStats(bigintStats, numStats); | |
| 133 | 146 | })(); | |
| 134 | 147 | } | |
| 135 | 148 | ||
| 136 | 149 | (async function() { | |
| 137 | - const handle = await promiseFs.open(fn, 'r'); | ||
| 150 | + const filename = getFilename(); | ||
| 151 | + const handle = await promiseFs.open(filename, 'r'); | ||
| 138 | 152 | const bigintStats = await handle.stat({ bigint: true }); | |
| 139 | 153 | const numStats = await handle.stat(); | |
| 140 | 154 | verifyStats(bigintStats, numStats); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments