[Git][ghc/ghc][wip/js-mkdir] JS/base: provide implementation for mkdir (issue 22374)
Josh Meredith (@JoshMeredith)
gitlab at gitlab.haskell.org
Fri Apr 21 11:09:04 UTC 2023
Josh Meredith pushed to branch wip/js-mkdir at Glasgow Haskell Compiler / GHC
Commits:
6591f4f1 by Josh Meredith at 2023-04-21T11:08:51+00:00
JS/base: provide implementation for mkdir (issue 22374)
- - - - -
4 changed files:
- libraries/base/jsbits/base.js
- libraries/base/tests/IO/all.T
- + libraries/base/tests/IO/mkdirExists.hs
- 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),grep_errmsg(r'already exists')], 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"
=====================================
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/6591f4f1119be2d4569c314ad460351fa6af8ab5
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6591f4f1119be2d4569c314ad460351fa6af8ab5
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/20230421/9b5e65f5/attachment-0001.html>
More information about the ghc-commits
mailing list