[Git][ghc/ghc][master] JS/base: provide implementation for mkdir (issue 22374)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Apr 25 04:16:14 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
ebd5b078 by Josh Meredith at 2023-04-25T00:15:58-04:00
JS/base: provide implementation for mkdir (issue 22374)
- - - - -
5 changed files:
- libraries/base/jsbits/base.js
- libraries/base/tests/IO/all.T
- + libraries/base/tests/IO/mkdirExists.hs
- + libraries/base/tests/IO/mkdirExists.stderr
- testsuite/tests/ghc-api/target-contents/all.T
Changes:
=====================================
libraries/base/jsbits/base.js
=====================================
@@ -889,3 +889,21 @@ function h$__hscore_free_dirent(a,o) {
function h$__hscore_d_name(a,o) {
RETURN_UBX_TUP2(h$encodeModifiedUtf8(a.name),0);
}
+
+function h$mkdir(path, path_offset, mode) {
+ if (!h$isNode()) {
+ throw "h$mkdir unsupported";
+ }
+ const d = h$decodeUtf8z(path, path_offset);
+ try {
+ h$fs.mkdirSync(d, {mode: mode});
+ } catch(e) {
+ // we can't directly set errno code, because numbers may not match
+ // e.g. e.errno is -17 for EEXIST while we would expect -20
+ // this is probably an inconsistency between nodejs using the native
+ // environment and everything else using Emscripten-provided headers.
+ h$setErrno(e);
+ return -1;
+ }
+ return 0;
+}
=====================================
libraries/base/tests/IO/all.T
=====================================
@@ -64,7 +64,7 @@ test('misc001', [extra_run_opts('misc001.hs misc001.out')], compile_and_run,
test('openFile001', normal, compile_and_run, [''])
test('openFile002', [exit_code(1), normalise_win32_io_errors], compile_and_run, [''])
-test('openFile003', [normalise_win32_io_errors, js_broken(22374)], compile_and_run, [''])
+test('openFile003', [normalise_win32_io_errors, js_broken(22362)], compile_and_run, [''])
test('openFile004', [], compile_and_run, [''])
test('openFile005', js_broken(22261), compile_and_run, [''])
test('openFile006', [], compile_and_run, [''])
@@ -152,3 +152,5 @@ test('T17510', expect_broken(17510), compile_and_run, [''])
test('bytestringread001', extra_run_opts('test.data'), compile_and_run, [''])
test('T17912', [only_ways(['threaded1']), when(opsys('mingw32'),expect_broken(1))], compile_and_run, [''])
test('T18832', only_ways(['threaded1']), compile_and_run, [''])
+
+test('mkdirExists', [exit_code(1), when(opsys('mingw32'), ignore_stderr)], compile_and_run, [''])
=====================================
libraries/base/tests/IO/mkdirExists.hs
=====================================
@@ -0,0 +1,8 @@
+module Main where
+
+import System.Directory
+
+main :: IO ()
+main = do
+ createDirectory "foo"
+ createDirectory "foo"
=====================================
libraries/base/tests/IO/mkdirExists.stderr
=====================================
@@ -0,0 +1 @@
+mkdirExists: foo: createDirectory: already exists (File exists)
=====================================
testsuite/tests/ghc-api/target-contents/all.T
=====================================
@@ -1,6 +1,6 @@
test('TargetContents',
[ extra_run_opts('"' + config.libdir + '"')
- , js_broken(22374)
+ , js_broken(22362)
]
, compile_and_run,
['-package ghc -package exceptions'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebd5b0781c6e6f4642db91353fab0f0ec04af3bc
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebd5b0781c6e6f4642db91353fab0f0ec04af3bc
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230425/f76e94de/attachment-0001.html>
More information about the ghc-commits
mailing list