How to use fs method in pact-foundation-pact

Best JavaScript code snippet using pact-foundation-pact

cached-fs.spec.ts

Source:cached-fs.spec.ts Github

copy

Full Screen

1import chai, { expect } from 'chai';2import chaiAsPromised from 'chai-as-promised';3import sinon from 'sinon';4import { asyncBaseFsContract, syncBaseFsContract } from '@file-services/test-kit';5import { createMemoryFs } from '@file-services/memory';6import { createCachedFs } from '@file-services/cached';7chai.use(chaiAsPromised);8describe('createCachedFs', () => {9 const SAMPLE_CONTENT = 'content';10 describe('cached api', () => {11 it('caches fs.statSync existing files', async () => {12 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });13 const statSpy = sinon.spy(memFs, 'statSync');14 const fs = createCachedFs(memFs);15 const stats = fs.statSync('/file');16 const stats2 = fs.statSync('/file');17 const stats3 = fs.statSync('./file');18 const stats4 = fs.statSync('file');19 expect(statSpy.callCount).to.equal(1);20 expect(stats).to.equal(stats2);21 expect(stats).to.equal(stats3);22 expect(stats).to.equal(stats4);23 });24 it('caches fs.statSync for missing files', async () => {25 const memFs = createMemoryFs();26 const statSpy = sinon.spy(memFs, 'statSync');27 const fs = createCachedFs(memFs);28 expect(() => fs.statSync('/missing')).to.throw();29 expect(() => fs.statSync('/missing')).to.throw();30 expect(() => fs.statSync('./missing')).to.throw();31 expect(() => fs.statSync('missing')).to.throw();32 expect(statSpy.callCount).to.equal(1);33 });34 it('caches fs.stat for existing files', async () => {35 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });36 const statSpy = sinon.spy(memFs, 'stat');37 const fs = createCachedFs(memFs);38 const stats = await new Promise((res, rej) => fs.stat('/file', (e, s) => (e ? rej(e) : res(s))));39 const stats2 = await new Promise((res, rej) => fs.stat('/file', (e, s) => (e ? rej(e) : res(s))));40 const stats3 = await new Promise((res, rej) => fs.stat('./file', (e, s) => (e ? rej(e) : res(s))));41 const stats4 = await new Promise((res, rej) => fs.stat('file', (e, s) => (e ? rej(e) : res(s))));42 expect(statSpy.callCount).to.equal(1);43 expect(stats).to.equal(stats2);44 expect(stats).to.equal(stats3);45 expect(stats).to.equal(stats4);46 });47 it('caches fs.stat for missing files', async () => {48 const memFs = createMemoryFs();49 const statSpy = sinon.spy(memFs, 'stat');50 const fs = createCachedFs(memFs);51 await expect(52 new Promise((res, rej) => fs.stat('/missing', (e, s) => (e ? rej(e) : res(s))))53 ).to.eventually.be.rejectedWith();54 await expect(55 new Promise((res, rej) => fs.stat('/missing', (e, s) => (e ? rej(e) : res(s))))56 ).to.eventually.be.rejectedWith();57 await expect(58 new Promise((res, rej) => fs.stat('./missing', (e, s) => (e ? rej(e) : res(s))))59 ).to.eventually.be.rejectedWith();60 await expect(61 new Promise((res, rej) => fs.stat('missing', (e, s) => (e ? rej(e) : res(s))))62 ).to.eventually.be.rejectedWith();63 expect(statSpy.callCount).to.equal(1);64 });65 it('caches fs.promises.stat for existing files', async () => {66 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });67 const statSpy = sinon.spy(memFs.promises, 'stat');68 const fs = createCachedFs(memFs);69 const stats = await fs.promises.stat('/file');70 const stats2 = await fs.promises.stat('/file');71 const stats3 = await fs.promises.stat('./file');72 const stats4 = await fs.promises.stat('file');73 expect(statSpy.callCount).to.equal(1);74 expect(stats).to.equal(stats2);75 expect(stats).to.equal(stats3);76 expect(stats).to.equal(stats4);77 });78 it('caches fs.promises.stat for missing files', async () => {79 const memFs = createMemoryFs();80 const statSpy = sinon.spy(memFs.promises, 'stat');81 const fs = createCachedFs(memFs);82 await expect(fs.promises.stat('/missing')).to.eventually.be.rejectedWith();83 await expect(fs.promises.stat('/missing')).to.eventually.be.rejectedWith();84 await expect(fs.promises.stat('./missing')).to.eventually.be.rejectedWith();85 await expect(fs.promises.stat('missing')).to.eventually.be.rejectedWith();86 expect(statSpy.callCount).to.equal(1);87 });88 it('caches fs.realpathSync for existing files', async () => {89 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });90 const realpathSpy = sinon.spy(memFs, 'realpathSync');91 const fs = createCachedFs(memFs);92 const actualPath = fs.realpathSync('/file');93 const actualPath2 = fs.realpathSync('/file');94 const actualPath3 = fs.realpathSync('./file');95 const actualPath4 = fs.realpathSync('file');96 expect(realpathSpy.callCount).to.equal(1);97 expect(actualPath).to.equal(actualPath2);98 expect(actualPath).to.equal(actualPath3);99 expect(actualPath).to.equal(actualPath4);100 });101 it('caches fs.realpath for existing files', async () => {102 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });103 const realpathSpy = sinon.spy(memFs, 'realpath');104 const fs = createCachedFs(memFs);105 const actualPath = await new Promise((res, rej) => fs.realpath('/file', (e, p) => (e ? rej(e) : res(p))));106 const actualPath2 = await new Promise((res, rej) => fs.realpath('/file', (e, p) => (e ? rej(e) : res(p))));107 const actualPath3 = await new Promise((res, rej) => fs.realpath('./file', (e, p) => (e ? rej(e) : res(p))));108 const actualPath4 = await new Promise((res, rej) => fs.realpath('file', (e, p) => (e ? rej(e) : res(p))));109 expect(realpathSpy.callCount).to.equal(1);110 expect(actualPath).to.equal(actualPath2);111 expect(actualPath).to.equal(actualPath3);112 expect(actualPath).to.equal(actualPath4);113 });114 it('caches fs.promises.realpath for existing files', async () => {115 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });116 const realpathSpy = sinon.spy(memFs.promises, 'realpath');117 const fs = createCachedFs(memFs);118 const actualPath = await fs.promises.realpath('/file');119 const actualPath2 = await fs.promises.realpath('/file');120 const actualPath3 = await fs.promises.realpath('./file');121 const actualPath4 = await fs.promises.realpath('file');122 expect(realpathSpy.callCount).to.equal(1);123 expect(actualPath).to.equal(actualPath2);124 expect(actualPath).to.equal(actualPath3);125 expect(actualPath).to.equal(actualPath4);126 });127 it('rebinds extended api to the cached base functions', () => {128 const memFs = createMemoryFs({ file: SAMPLE_CONTENT });129 const statSpy = sinon.spy(memFs, 'statSync');130 const fs = createCachedFs(memFs);131 expect(fs.fileExistsSync('/file')).to.equal(true);132 expect(fs.fileExistsSync('/file')).to.equal(true);133 expect(fs.fileExistsSync('./file')).to.equal(true);134 expect(fs.fileExistsSync('file')).to.equal(true);135 expect(statSpy.callCount).to.equal(1);136 });137 });138 describe('cache invalidation', () => {139 it('allows invalidating cache for existing files', async () => {140 const filePath = '/file';141 const memFs = createMemoryFs({ [filePath]: SAMPLE_CONTENT });142 const statSyncSpy = sinon.spy(memFs, 'statSync');143 const statSpy = sinon.spy(memFs, 'stat');144 const promiseStatSpy = sinon.spy(memFs.promises, 'stat');145 const fs = createCachedFs(memFs);146 fs.statSync(filePath);147 await new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))));148 await fs.promises.stat(filePath);149 fs.invalidate(filePath);150 fs.statSync(filePath);151 await new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))));152 await fs.promises.stat(filePath);153 expect(statSyncSpy.callCount).to.equal(2);154 expect(statSpy.callCount).to.equal(0);155 expect(promiseStatSpy.callCount).to.equal(0);156 });157 it('allows invalidating cache for missing files', async () => {158 const filePath = '/missing';159 const memFs = createMemoryFs();160 const statSyncSpy = sinon.spy(memFs, 'statSync');161 const statSpy = sinon.spy(memFs, 'stat');162 const promiseStatSpy = sinon.spy(memFs.promises, 'stat');163 const fs = createCachedFs(memFs);164 expect(() => fs.statSync(filePath)).to.throw();165 await expect(166 new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))))167 ).to.eventually.be.rejectedWith();168 await expect(fs.promises.stat(filePath)).to.eventually.be.rejectedWith();169 fs.invalidate(filePath);170 expect(() => fs.statSync(filePath)).to.throw();171 await expect(172 new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))))173 ).to.eventually.be.rejectedWith();174 await expect(fs.promises.stat(filePath)).to.eventually.be.rejectedWith();175 expect(statSyncSpy.callCount).to.equal(2);176 expect(statSpy.callCount).to.equal(0);177 expect(promiseStatSpy.callCount).to.equal(0);178 });179 it('allows invalidating cache for all file paths', async () => {180 const filePath = '/file';181 const memFs = createMemoryFs({ [filePath]: SAMPLE_CONTENT });182 const statSpy = sinon.spy(memFs, 'statSync');183 const promiseStatSpy = sinon.spy(memFs.promises, 'stat');184 const fs = createCachedFs(memFs);185 const stats = fs.statSync(filePath);186 fs.invalidateAll();187 const stats2 = fs.promises.stat(filePath);188 expect(statSpy.callCount).to.equal(1);189 expect(promiseStatSpy.callCount).to.equal(1);190 expect(stats).to.not.equal(stats2);191 });192 it('deep invalidation should invalidate all the keys starting with the invalidation path', async () => {193 const dirPath = '/dir';194 const fileName = 'file';195 const filePath = `${dirPath}/${fileName}`;196 const memFs = createMemoryFs({ [filePath]: SAMPLE_CONTENT });197 const statSyncSpy = sinon.spy(memFs, 'statSync');198 const statSpy = sinon.spy(memFs, 'stat');199 const promiseStatSpy = sinon.spy(memFs.promises, 'stat');200 const fs = createCachedFs(memFs);201 fs.statSync(filePath);202 await new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))));203 await fs.promises.stat(filePath);204 fs.invalidate(dirPath, true);205 fs.statSync(filePath);206 await new Promise((res, rej) => fs.stat(filePath, (e, s) => (e ? rej(e) : res(s))));207 await fs.promises.stat(filePath);208 expect(statSyncSpy.callCount).to.equal(2);209 expect(statSpy.callCount).to.equal(0);210 expect(promiseStatSpy.callCount).to.equal(0);211 });212 });213 it('deep invalidation shouldnt invalidate ajdacent directories', async () => {214 const memFs = createMemoryFs({215 dir: { file: SAMPLE_CONTENT },216 dir2: { file: SAMPLE_CONTENT },217 });218 const filePath = memFs.join('dir2', 'file');219 const statSyncSpy = sinon.spy(memFs, 'statSync');220 const fs = createCachedFs(memFs);221 fs.statSync(filePath);222 // Not the dir I'm stating!223 fs.invalidate('dir', true);224 fs.statSync(filePath);225 expect(statSyncSpy.callCount).to.equal(1);226 });227 it('should invalidate the entire fs when passing slash', async () => {228 const memFs = createMemoryFs({229 dir: { file: SAMPLE_CONTENT },230 dir2: { file: SAMPLE_CONTENT },231 });232 const filePath = memFs.join('dir2', 'file');233 const statSyncSpy = sinon.spy(memFs, 'statSync');234 const fs = createCachedFs(memFs);235 fs.statSync(filePath);236 fs.invalidate('/', true);237 fs.statSync(filePath);238 expect(statSyncSpy.callCount).to.equal(2);239 });240 const testProvider = async () => {241 const fs = createCachedFs(createMemoryFs());242 fs.watchService.addGlobalListener(({ path }) => fs.invalidate(path));243 return {244 fs,245 dispose: async () => undefined,246 tempDirectoryPath: fs.cwd(),247 };248 };249 asyncBaseFsContract(testProvider);250 syncBaseFsContract(testProvider);...

Full Screen

Full Screen

run.ts

Source:run.ts Github

copy

Full Screen

1/**2 * The template from which `run.ts` is generated.3 *4 * Why autogenerate run.ts?5 * - Avoids hardcoding all test names. Now, adding a new test case is as simple as6 * dropping a new file into the repository.7 * - Avoids hardcoding all backend factory names. (Ditto.)8 *9 * Previously, the code used RequireJS modules to dynamically grep for and require10 * tests and factories. However, Browserify does not allow you to have dynamic module11 * dependencies, as it prevents bundling. Thus, I compromised with this file.12 * (It's also less hacky, as now things will be typechecked at bundle-time. :) )13 */14import async_mirror from './factories/async_mirror_factory';15import dbfs from './factories/dbfs_factory';16import emscripten from './factories/emscripten_factory';17import folderadapter from './factories/folderadapter_factory';18import html5fs from './factories/html5fs_factory';19import httpdownloadfs from './factories/httpdownloadfs_factory';20import idbfs from './factories/idbfs_factory';21import inmemory from './factories/inmemory_factory';22import isofs from './factories/isofs_factory';23import lsfs from './factories/lsfs_factory';24import mfs from './factories/mfs_factory';25import overlay from './factories/overlay_factory';26import workerfs from './factories/workerfs_factory';27import zipfs from './factories/zipfs_factory';28const bad_lookupEmscripten = require('../tests/emscripten/bad_lookup');29const filesEmscripten = require('../tests/emscripten/files');30const nopEmscripten = require('../tests/emscripten/nop');31const readdirEmscripten = require('../tests/emscripten/readdir');32const readdir_emptyEmscripten = require('../tests/emscripten/readdir_empty');33import cache_test from '../tests/fs/Dropbox/cache_test';34import listing from '../tests/fs/HTTPRequest/listing';35import nested_directories from '../tests/fs/IsoFS/nested-directories';36import mounting from '../tests/fs/MountableFileSystem/mounting';37import delete_log_test from '../tests/fs/OverlayFS/delete-log-test';38import error_test from '../tests/fs/OverlayFS/error-test';39import persist_test from '../tests/fs/OverlayFS/persist-test';40import mkdir from '../tests/fs/all/mkdir';41import mode_test from '../tests/fs/all/mode-test';42import node_fs_append_file from '../tests/fs/all/node-fs-append-file';43import node_fs_chmod from '../tests/fs/all/node-fs-chmod';44import node_fs_error_messages from '../tests/fs/all/node-fs-error-messages';45import node_fs_exists from '../tests/fs/all/node-fs-exists';46import node_fs_fsync from '../tests/fs/all/node-fs-fsync';47import node_fs_long_path from '../tests/fs/all/node-fs-long-path';48import node_fs_mkdir from '../tests/fs/all/node-fs-mkdir';49import node_fs_null_bytes from '../tests/fs/all/node-fs-null-bytes';50import node_fs_open from '../tests/fs/all/node-fs-open';51import node_fs_read_buffer from '../tests/fs/all/node-fs-read-buffer';52import node_fs_read_file_sync from '../tests/fs/all/node-fs-read-file-sync';53import node_fs_read from '../tests/fs/all/node-fs-read';54import node_fs_readfile_empty from '../tests/fs/all/node-fs-readfile-empty';55import node_fs_readfile_unlink from '../tests/fs/all/node-fs-readfile-unlink';56import node_fs_stat from '../tests/fs/all/node-fs-stat';57import node_fs_symlink_dir_junction from '../tests/fs/all/node-fs-symlink-dir-junction';58import node_fs_symlink from '../tests/fs/all/node-fs-symlink';59import node_fs_truncate from '../tests/fs/all/node-fs-truncate';60import node_fs_utimes from '../tests/fs/all/node-fs-utimes';61import node_fs_write_buffer from '../tests/fs/all/node-fs-write-buffer';62import node_fs_write_file_buffer from '../tests/fs/all/node-fs-write-file-buffer';63import node_fs_write_file_sync from '../tests/fs/all/node-fs-write-file-sync';64import node_fs_write_file from '../tests/fs/all/node-fs-write-file';65import node_fs_write_sync from '../tests/fs/all/node-fs-write-sync';66import node_fs_write from '../tests/fs/all/node-fs-write';67import open from '../tests/fs/all/open';68import read_binary_file from '../tests/fs/all/read-binary-file';69import readFile from '../tests/fs/all/readFile';70import readdir from '../tests/fs/all/readdir';71import rename_test from '../tests/fs/all/rename-test';72import rmdir from '../tests/fs/all/rmdir';73import truncate from '../tests/fs/all/truncate';74import write_file from '../tests/fs/all/write-file';75import quota_test from '../tests/fs/localStorage/quota-test';76import buffer_test from '../tests/general/buffer-test';77import check_options_test from '../tests/general/check-options-test';78import indexed_fs_test from '../tests/general/indexed-fs-test';79import node_buffer_arraybuffer from '../tests/general/node-buffer-arraybuffer';80import node_buffer_ascii from '../tests/general/node-buffer-ascii';81import node_buffer_bytelength from '../tests/general/node-buffer-bytelength';82import node_buffer_concat from '../tests/general/node-buffer-concat';83import node_buffer_indexof from '../tests/general/node-buffer-indexof';84import node_buffer_inspect from '../tests/general/node-buffer-inspect';85import node_buffer_slow from '../tests/general/node-buffer-slow';86import node_buffer from '../tests/general/node-buffer';87import node_path_makelong from '../tests/general/node-path-makelong';88import node_path_zero_length_strings from '../tests/general/node-path-zero-length-strings';89import node_path from '../tests/general/node-path';90import std_streams from '../tests/general/std-streams';91import runTests from './setup';92import BackendFactory from './BackendFactory';93// Will be replaced with arrays of hardcoded require statements for the various modules.94const backends: BackendFactory[] = [async_mirror, dbfs, emscripten, folderadapter, html5fs, httpdownloadfs, idbfs, inmemory, isofs, lsfs, mfs, overlay, workerfs, zipfs],95 tests: {96 fs: {97 [name: string]: {[name: string]: () => void};98 all: {[name: string]: () => void};99 };100 general: {[name: string]: () => void};101 emscripten: {[name: string]: (Module: any) => void};102 } = {'emscripten':{'bad_lookup.js': bad_lookupEmscripten,'files.js': filesEmscripten,'nop.js': nopEmscripten,'readdir.js': readdirEmscripten,'readdir_empty.js': readdir_emptyEmscripten},'fs':{'Dropbox':{'cache_test.ts': cache_test},'HTTPRequest':{'listing.ts': listing},'IsoFS':{'nested-directories.ts': nested_directories},'MountableFileSystem':{'mounting.ts': mounting},'OverlayFS':{'delete-log-test.ts': delete_log_test,'error-test.ts': error_test,'persist-test.ts': persist_test},'all':{'mkdir.ts': mkdir,'mode-test.ts': mode_test,'node-fs-append-file.ts': node_fs_append_file,'node-fs-chmod.ts': node_fs_chmod,'node-fs-error-messages.ts': node_fs_error_messages,'node-fs-exists.ts': node_fs_exists,'node-fs-fsync.ts': node_fs_fsync,'node-fs-long-path.ts': node_fs_long_path,'node-fs-mkdir.ts': node_fs_mkdir,'node-fs-null-bytes.ts': node_fs_null_bytes,'node-fs-open.ts': node_fs_open,'node-fs-read-buffer.ts': node_fs_read_buffer,'node-fs-read-file-sync.ts': node_fs_read_file_sync,'node-fs-read.ts': node_fs_read,'node-fs-readfile-empty.ts': node_fs_readfile_empty,'node-fs-readfile-unlink.ts': node_fs_readfile_unlink,'node-fs-stat.ts': node_fs_stat,'node-fs-symlink-dir-junction.ts': node_fs_symlink_dir_junction,'node-fs-symlink.ts': node_fs_symlink,'node-fs-truncate.ts': node_fs_truncate,'node-fs-utimes.ts': node_fs_utimes,'node-fs-write-buffer.ts': node_fs_write_buffer,'node-fs-write-file-buffer.ts': node_fs_write_file_buffer,'node-fs-write-file-sync.ts': node_fs_write_file_sync,'node-fs-write-file.ts': node_fs_write_file,'node-fs-write-sync.ts': node_fs_write_sync,'node-fs-write.ts': node_fs_write,'open.ts': open,'read-binary-file.ts': read_binary_file,'readFile.ts': readFile,'readdir.ts': readdir,'rename-test.ts': rename_test,'rmdir.ts': rmdir,'truncate.ts': truncate,'write-file.ts': write_file},'localStorage':{'quota-test.ts': quota_test}},'general':{'buffer-test.ts': buffer_test,'check-options-test.ts': check_options_test,'indexed-fs-test.ts': indexed_fs_test,'node-buffer-arraybuffer.ts': node_buffer_arraybuffer,'node-buffer-ascii.ts': node_buffer_ascii,'node-buffer-bytelength.ts': node_buffer_bytelength,'node-buffer-concat.ts': node_buffer_concat,'node-buffer-indexof.ts': node_buffer_indexof,'node-buffer-inspect.ts': node_buffer_inspect,'node-buffer-slow.ts': node_buffer_slow,'node-buffer.ts': node_buffer,'node-path-makelong.ts': node_path_makelong,'node-path-zero-length-strings.ts': node_path_zero_length_strings,'node-path.ts': node_path,'std-streams.ts': std_streams}};...

Full Screen

Full Screen

test-fs-null-bytes.js

Source:test-fs-null-bytes.js Github

copy

Full Screen

1// Copyright Joyent, Inc. and other Node contributors.2//3// Permission is hereby granted, free of charge, to any person obtaining a4// copy of this software and associated documentation files (the5// "Software"), to deal in the Software without restriction, including6// without limitation the rights to use, copy, modify, merge, publish,7// distribute, sublicense, and/or sell copies of the Software, and to permit8// persons to whom the Software is furnished to do so, subject to the9// following conditions:10//11// The above copyright notice and this permission notice shall be included12// in all copies or substantial portions of the Software.13//14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS15// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN17// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,18// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20// USE OR OTHER DEALINGS IN THE SOFTWARE.21'use strict';22const common = require('../common');23const assert = require('assert');24const fs = require('fs');25const URL = require('url').URL;26function check(async, sync) {27 const expected = /Path must be a string without null bytes/;28 const argsSync = Array.prototype.slice.call(arguments, 2);29 const argsAsync = argsSync.concat((er) => {30 assert(er && expected.test(er.message));31 assert.strictEqual(er.code, 'ENOENT');32 });33 if (sync) {34 assert.throws(() => {35 sync.apply(null, argsSync);36 }, expected);37 }38 if (async) {39 async.apply(null, argsAsync);40 }41}42check(fs.access, fs.accessSync, 'foo\u0000bar');43check(fs.access, fs.accessSync, 'foo\u0000bar', fs.F_OK);44check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar', 'abc');45check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644');46check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34);47check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar');48check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar');49check(fs.lstat, fs.lstatSync, 'foo\u0000bar');50check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755');51check(fs.open, fs.openSync, 'foo\u0000bar', 'r');52check(fs.readFile, fs.readFileSync, 'foo\u0000bar');53check(fs.readdir, fs.readdirSync, 'foo\u0000bar');54check(fs.readlink, fs.readlinkSync, 'foo\u0000bar');55check(fs.realpath, fs.realpathSync, 'foo\u0000bar');56check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar');57check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar');58check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar');59check(fs.stat, fs.statSync, 'foo\u0000bar');60check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar');61check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');62check(fs.truncate, fs.truncateSync, 'foo\u0000bar');63check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');64check(null, fs.unwatchFile, 'foo\u0000bar', common.mustNotCall());65check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);66check(null, fs.watch, 'foo\u0000bar', common.mustNotCall());67check(null, fs.watchFile, 'foo\u0000bar', common.mustNotCall());68check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar', 'abc');69const fileUrl = new URL('file:///C:/foo\u0000bar');70const fileUrl2 = new URL('file:///C:/foo%00bar');71check(fs.access, fs.accessSync, fileUrl);72check(fs.access, fs.accessSync, fileUrl, fs.F_OK);73check(fs.appendFile, fs.appendFileSync, fileUrl, 'abc');74check(fs.chmod, fs.chmodSync, fileUrl, '0644');75check(fs.chown, fs.chownSync, fileUrl, 12, 34);76check(fs.link, fs.linkSync, fileUrl, 'foobar');77check(fs.link, fs.linkSync, 'foobar', fileUrl);78check(fs.lstat, fs.lstatSync, fileUrl);79check(fs.mkdir, fs.mkdirSync, fileUrl, '0755');80check(fs.open, fs.openSync, fileUrl, 'r');81check(fs.readFile, fs.readFileSync, fileUrl);82check(fs.readdir, fs.readdirSync, fileUrl);83check(fs.readlink, fs.readlinkSync, fileUrl);84check(fs.realpath, fs.realpathSync, fileUrl);85check(fs.rename, fs.renameSync, fileUrl, 'foobar');86check(fs.rename, fs.renameSync, 'foobar', fileUrl);87check(fs.rmdir, fs.rmdirSync, fileUrl);88check(fs.stat, fs.statSync, fileUrl);89check(fs.symlink, fs.symlinkSync, fileUrl, 'foobar');90check(fs.symlink, fs.symlinkSync, 'foobar', fileUrl);91check(fs.truncate, fs.truncateSync, fileUrl);92check(fs.unlink, fs.unlinkSync, fileUrl);93check(null, fs.unwatchFile, fileUrl, assert.fail);94check(fs.utimes, fs.utimesSync, fileUrl, 0, 0);95check(null, fs.watch, fileUrl, assert.fail);96check(null, fs.watchFile, fileUrl, assert.fail);97check(fs.writeFile, fs.writeFileSync, fileUrl, 'abc');98check(fs.access, fs.accessSync, fileUrl2);99check(fs.access, fs.accessSync, fileUrl2, fs.F_OK);100check(fs.appendFile, fs.appendFileSync, fileUrl2, 'abc');101check(fs.chmod, fs.chmodSync, fileUrl2, '0644');102check(fs.chown, fs.chownSync, fileUrl2, 12, 34);103check(fs.link, fs.linkSync, fileUrl2, 'foobar');104check(fs.link, fs.linkSync, 'foobar', fileUrl2);105check(fs.lstat, fs.lstatSync, fileUrl2);106check(fs.mkdir, fs.mkdirSync, fileUrl2, '0755');107check(fs.open, fs.openSync, fileUrl2, 'r');108check(fs.readFile, fs.readFileSync, fileUrl2);109check(fs.readdir, fs.readdirSync, fileUrl2);110check(fs.readlink, fs.readlinkSync, fileUrl2);111check(fs.realpath, fs.realpathSync, fileUrl2);112check(fs.rename, fs.renameSync, fileUrl2, 'foobar');113check(fs.rename, fs.renameSync, 'foobar', fileUrl2);114check(fs.rmdir, fs.rmdirSync, fileUrl2);115check(fs.stat, fs.statSync, fileUrl2);116check(fs.symlink, fs.symlinkSync, fileUrl2, 'foobar');117check(fs.symlink, fs.symlinkSync, 'foobar', fileUrl2);118check(fs.truncate, fs.truncateSync, fileUrl2);119check(fs.unlink, fs.unlinkSync, fileUrl2);120check(null, fs.unwatchFile, fileUrl2, assert.fail);121check(fs.utimes, fs.utimesSync, fileUrl2, 0, 0);122check(null, fs.watch, fileUrl2, assert.fail);123check(null, fs.watchFile, fileUrl2, assert.fail);124check(fs.writeFile, fs.writeFileSync, fileUrl2, 'abc');125// an 'error' for exists means that it doesn't exist.126// one of many reasons why this file is the absolute worst.127fs.exists('foo\u0000bar', common.mustCall((exists) => {128 assert(!exists);129}));...

Full Screen

Full Screen

fs.js

Source:fs.js Github

copy

Full Screen

1var fs = require("fs");2var promisify = require("./_promisify.js");3var bind = function(c, f) { return f && f.bind(c); };4Object.defineProperties(module.exports, {5 F_OK: { enumerable: true, value: fs.F_OK },6 FileReadStream: { enumerable: true, value: fs.FileReadStream },7 FileWriteStream: { enumerable: true, value: fs.FileWriteStream },8 R_OK: { enumerable: true, value: fs.R_OK },9 ReadStream: { enumerable: true, value: fs.ReadStream },10 Stats: { enumerable: true, value: fs.Stats },11 W_OK: { enumerable: true, value: fs.W_OK },12 WriteStream: { enumerable: true, value: fs.WriteStream },13 X_OK: { enumerable: true, value: fs.X_OK },14 //_toUnixTimestamp: // skipping15 access: { enumerable: true, value: promisify(fs, fs.access, 1) },16 accessSync: { enumerable: true, value: bind(fs, fs.accessSync) },17 appendFile: { enumerable: true, value: promisify(fs, fs.appendFile, 2) },18 appendFileSync: { enumerable: true, value: bind(fs, fs.appendFileSync) },19 chmod: { enumerable: true, value: promisify(fs, fs.chmod, 2) },20 chmodSync: { enumerable: true, value: bind(fs, fs.chmodSync) },21 chown: { enumerable: true, value: promisify(fs, fs.chown, 3) },22 chownSync: { enumerable: true, value: bind(fs, fs.chownSync) },23 close: { enumerable: true, value: promisify(fs, fs.close, 1) },24 closeSync: { enumerable: true, value: bind(fs, fs.closeSync) },25 constants: { enumerable: true, get: function() { return fs.constants; }, set: function(v) { fs.constants = v; } },26 copyFile: { enumerable: true, value: promisify(fs, fs.copyFile, 2) },27 copyFileSync: { enumerable: true, value: bind(fs, fs.copyFileSync) },28 createReadStream: { enumerable: true, value: bind(fs, fs.createReadStream) },29 createWriteStream: { enumerable: true, value: bind(fs, fs.createWriteStream) },30 exists: { enumerable: true, value: promisify(fs, fs.exists, 1, {"noError":true}) },31 existsSync: { enumerable: true, value: bind(fs, fs.existsSync) },32 fchmod: { enumerable: true, value: promisify(fs, fs.fchmod, 2) },33 fchmodSync: { enumerable: true, value: bind(fs, fs.fchmodSync) },34 fchown: { enumerable: true, value: promisify(fs, fs.fchown, 3) },35 fchownSync: { enumerable: true, value: bind(fs, fs.fchownSync) },36 fdatasync: { enumerable: true, value: promisify(fs, fs.fdatasync, 1) },37 fdatasyncSync: { enumerable: true, value: bind(fs, fs.fdatasyncSync) },38 fstat: { enumerable: true, value: promisify(fs, fs.fstat, 1) },39 fstatSync: { enumerable: true, value: bind(fs, fs.fstatSync) },40 fsync: { enumerable: true, value: promisify(fs, fs.fsync, 1) },41 fsyncSync: { enumerable: true, value: bind(fs, fs.fsyncSync) },42 ftruncate: { enumerable: true, value: promisify(fs, fs.ftruncate, 2) },43 ftruncateSync: { enumerable: true, value: bind(fs, fs.ftruncateSync) },44 futimes: { enumerable: true, value: promisify(fs, fs.futimes, 3) },45 futimesSync: { enumerable: true, value: bind(fs, fs.futimesSync) },46 link: { enumerable: true, value: promisify(fs, fs.link, 2) },47 linkSync: { enumerable: true, value: bind(fs, fs.linkSync) },48 lstat: { enumerable: true, value: promisify(fs, fs.lstat, 1) },49 lstatSync: { enumerable: true, value: bind(fs, fs.lstatSync) },50 mkdir: { enumerable: true, value: promisify(fs, fs.mkdir, 1) },51 mkdirSync: { enumerable: true, value: bind(fs, fs.mkdirSync) },52 mkdtemp: { enumerable: true, value: promisify(fs, fs.mkdtemp, 1) },53 mkdtempSync: { enumerable: true, value: bind(fs, fs.mkdtempSync) },54 open: { enumerable: true, value: promisify(fs, fs.open, 2) },55 openSync: { enumerable: true, value: bind(fs, fs.openSync) },56 read: { enumerable: true, value: promisify(fs, fs.read, 5, {"pattern":["read","buffer"]}) },57 readFile: { enumerable: true, value: promisify(fs, fs.readFile, 1) },58 readFileSync: { enumerable: true, value: bind(fs, fs.readFileSync) },59 readSync: { enumerable: true, value: bind(fs, fs.readSync) },60 readdir: { enumerable: true, value: promisify(fs, fs.readdir, 1) },61 readdirSync: { enumerable: true, value: bind(fs, fs.readdirSync) },62 readlink: { enumerable: true, value: promisify(fs, fs.readlink, 1) },63 readlinkSync: { enumerable: true, value: bind(fs, fs.readlinkSync) },64 realpath: { enumerable: true, value: promisify(fs, fs.realpath, 1) },65 realpathSync: { enumerable: true, value: bind(fs, fs.realpathSync) },66 rename: { enumerable: true, value: promisify(fs, fs.rename, 2) },67 renameSync: { enumerable: true, value: bind(fs, fs.renameSync) },68 rmdir: { enumerable: true, value: promisify(fs, fs.rmdir, 1) },69 rmdirSync: { enumerable: true, value: bind(fs, fs.rmdirSync) },70 stat: { enumerable: true, value: promisify(fs, fs.stat, 1) },71 statSync: { enumerable: true, value: bind(fs, fs.statSync) },72 symlink: { enumerable: true, value: promisify(fs, fs.symlink, 2) },73 symlinkSync: { enumerable: true, value: bind(fs, fs.symlinkSync) },74 truncate: { enumerable: true, value: promisify(fs, fs.truncate, 2) },75 truncateSync: { enumerable: true, value: bind(fs, fs.truncateSync) },76 unlink: { enumerable: true, value: promisify(fs, fs.unlink, 1) },77 unlinkSync: { enumerable: true, value: bind(fs, fs.unlinkSync) },78 unwatchFile: { enumerable: true, value: bind(fs, fs.unwatchFile) },79 utimes: { enumerable: true, value: promisify(fs, fs.utimes, 3) },80 utimesSync: { enumerable: true, value: bind(fs, fs.utimesSync) },81 watch: { enumerable: true, value: bind(fs, fs.watch) },82 watchFile: { enumerable: true, value: bind(fs, fs.watchFile) },83 write: { enumerable: true, value: promisify(fs, fs.write, 5, {"pattern":["written","buffer"]}) },84 writeFile: { enumerable: true, value: promisify(fs, fs.writeFile, 2) },85 writeFileSync: { enumerable: true, value: bind(fs, fs.writeFileSync) },86 writeSync: { enumerable: true, value: bind(fs, fs.writeSync) },...

Full Screen

Full Screen

Q-io-tests.ts

Source:Q-io-tests.ts Github

copy

Full Screen

1/// <reference path="../q/Q.d.ts" />2/// <reference path="Q-io.d.ts" />3var fs:typeof QioFS = require('q-io/fs');4var http:typeof QioHTTP = require('q-io/http');5var bool:boolean;6var num:number;7var x:any;8var path:string;9var buffer:NodeBuffer;10var str:string;11var strArr:string[];12var source:string;13var target:string;14var type:string;15var options:any;16var strArrQ:Q.Promise<string[]>;17var voidQ:Q.Promise<void>;18var anyQ:Q.Promise<any>;19var strQ:Q.Promise<string>;20var boolQ:Q.Promise<boolean>;21var dateQ:Q.Promise<Date>;22var bufferQ:Q.Promise<NodeBuffer>;23var statsQ:Q.Promise<QioFS.Stats>;24var readQ:Q.Promise<Qio.Reader>;25var writeQ:Q.Promise<Qio.Writer>;26var headers:QioHTTP.Headers;27var reader:Qio.Reader;28var writer:Qio.Writer;29var stream:Qio.Stream;30// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -31fs.open(path, options).then((x) => {32});33//fs.open(path, options):Q.Promise<Qio.Reader>;34//fs.open(path, options):Q.Promise<Qio.Writer>;35//fs.open(path, options):Q.Promise<NodeBuffer>;36//TODO how to define the multiple return types? use any for now?37anyQ = fs.read(path, options);38//strQ = fs.read(path, options);39//fs.read(path, options):Q.Promise<NodeBuffer>;40voidQ = fs.write(path, buffer, options);41voidQ = fs.write(path, str, options);42voidQ = fs.append(path, buffer, options);43voidQ = fs.append(path, str, options);44voidQ = fs.copy(source, target);45voidQ = fs.copyTree(source, target);46strArrQ = fs.list(path);47strArrQ = fs.listTree(path, (path, x) => {48 return true;49});50strArrQ = fs.listDirectoryTree(path);51voidQ = fs.makeDirectory(path, str);52voidQ = fs.makeDirectory(path, num);53voidQ = fs.makeTree(path, str);54voidQ = fs.makeTree(path, num);55voidQ = fs.remove(path);56voidQ = fs.removeTree(path);57voidQ = fs.rename(source, target);58voidQ = fs.move(source, target);59voidQ = fs.link(source, target);60voidQ = fs.symbolicCopy(source, target, type);61voidQ = fs.symbolicLink(target, str, type);62voidQ = fs.chown(path, num, num);63voidQ = fs.chmod(path, str);64voidQ = fs.chmod(path, num);65statsQ = fs.stat(path)66statsQ = fs.statLink(path);67statsQ = fs.statFd(num);68boolQ = fs.exists(path);69boolQ = fs.isFile(path);70boolQ = fs.isDirectory(path);71boolQ = fs.isSymbolicLink(path);72dateQ = fs.lastModified(path);73dateQ = fs.lastAccessed(path);74strArr = fs.split(path);75str = fs.join(str, str);76str = fs.join(strArr);77str = fs.resolve(str, str);78str = fs.resolve(strArr);79str = fs.normal(str, str);80str = fs.normal(strArr);81str = fs.absolute(path);82strQ = fs.canonical(path);83strQ = fs.readLink(path);84bool = fs.contains(str, str);85strQ = fs.relative(source, target);86str = fs.relativeFromFile(source, target);87str = fs.relativeFromDirectory(source, target);88bool = fs.isAbsolute(path);89bool = fs.isRelative(path);90bool = fs.isRoot(path);91str = fs.root(path);92str = fs.directory(path);93str = fs.base(path, str);94str = fs.extension(path);95//this should return a q-io/fs-mock MockFS96//fs = fs.reroot(str);97x = fs.toObject(str);98// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -99var request:QioHTTP.Request;100var headers:QioHTTP.Headers;101str = request.url;102str = request.path;103str = request.scriptName;104str = request.pathInfo;105strArr = request.version;106str = request.method;107str = request.scheme;108str = request.host;109num = request.port;110str = request.remoteHost;111num = request.remotePort;112headers = request.headers;113x = request.agent;114x = request.body;115x = request.node;116str = headers['foo'];117var response:QioHTTP.Response;118var responseQ:Q.Promise<QioHTTP.Response>;119responseQ = http.request(request);120responseQ = http.request(str);121strQ = http.read(request);122strQ = http.read(str);123request = http.normalizeRequest(request);124request = http.normalizeRequest(str);125response = http.normalizeResponse(response);126num = response.status;127headers = response.headers;128reader = response.body;129response.onclose = () => {130};131x = response.node;132// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -133strQ = reader.read(str);134bufferQ = reader.read();135reader.close();136x = reader.node;137voidQ = reader.forEach((chunk:any) => {138 return anyQ;139});140writer.write(str);141writer.write(buffer);142writer.flush();143writer.close();144x = writer.node;145strQ = stream.read(str);146bufferQ = stream.read();147stream.write(str);148stream.write(buffer);149stream.flush();150stream.close();151x = stream.node;152voidQ = reader.forEach((chunk:any) => {153 return anyQ;...

Full Screen

Full Screen

node-fs-chmod.ts

Source:node-fs-chmod.ts Github

copy

Full Screen

1import fs from '../../../../src/core/node_fs';2import * as path from 'path';3import assert from '../../../harness/wrapped-assert';4import common from '../../../harness/common';5export default function() {6 var got_error = false;7 var success_count = 0;8 var mode_async: number;9 var mode_sync: number;10 var is_windows = process.platform === 'win32';11 var rootFS = fs.getRootFS();12 // BFS: This is only for writable file systems that support properties.13 if (!(rootFS.isReadOnly() || rootFS.supportsProps() === false)) {14 var openCount = 0;15 var open = function() {16 openCount++;17 return (<any>fs)._open.apply(fs, arguments);18 };19 var openSync = function() {20 openCount++;21 return (<any>fs)._openSync.apply(fs, arguments);22 };23 var close = function() {24 openCount--;25 return (<any>fs)._close.apply(fs, arguments);26 };27 var closeSync = function() {28 openCount--;29 return (<any>fs)._closeSync.apply(fs, arguments);30 };31 // Need to hijack fs.open/close to make sure that things32 // get closed once they're opened.33 (<any>fs)._open = fs.open;34 fs.open = open;35 (<any>fs)._close = fs.close;36 fs.close = close;37 if (rootFS.supportsSynch()) {38 (<any>fs)._openSync = fs.openSync;39 fs.openSync = openSync;40 (<any>fs)._closeSync = fs.closeSync;41 fs.closeSync = closeSync;42 }43 // On Windows chmod is only able to manipulate read-only bit44 if (is_windows) {45 mode_async = 0o400; // read-only46 mode_sync = 0o600; // read-write47 } else {48 mode_async = 0o777;49 mode_sync = 0o644;50 }51 var file1 = path.join(common.fixturesDir, 'a.js'),52 file2 = path.join(common.fixturesDir, 'a1.js');53 fs.chmod(file1, mode_async.toString(8), function(err) {54 if (err) {55 got_error = true;56 } else {57 if (is_windows) {58 assert.ok((fs.statSync(file1).mode & 0o777) & mode_async);59 } else {60 assert.equal(mode_async, fs.statSync(file1).mode & 0o777);61 }62 fs.chmodSync(file1, mode_sync);63 if (is_windows) {64 assert.ok((fs.statSync(file1).mode & 0o777) & mode_sync);65 } else {66 assert.equal(mode_sync, fs.statSync(file1).mode & 0o777);67 }68 success_count++;69 }70 });71 fs.open(file2, 'a', function(err, fd) {72 if (err) {73 got_error = true;74 console.log(err.stack);75 return;76 }77 fs.fchmod(fd, mode_async.toString(8), function(err) {78 if (err) {79 got_error = true;80 } else {81 if (is_windows) {82 assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async);83 } else {84 assert.equal(mode_async, fs.fstatSync(fd).mode & 0o777);85 }86 fs.fchmodSync(fd, mode_sync);87 if (is_windows) {88 assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync);89 } else {90 assert.equal(mode_sync, fs.fstatSync(fd).mode & 0o777);91 }92 success_count++;93 fs.close(fd);94 }95 });96 });97 // lchmod98 if (rootFS.supportsLinks()) {99 if (fs.lchmod) {100 var link = path.join(common.tmpDir, 'symbolic-link');101 try {102 fs.unlinkSync(link);103 } catch (er) {}104 fs.symlinkSync(file2, link);105 fs.lchmod(link, mode_async, function(err) {106 if (err) {107 got_error = true;108 } else {109 console.log(fs.lstatSync(link).mode);110 assert.equal(mode_async, fs.lstatSync(link).mode & 0o777);111 fs.lchmodSync(link, mode_sync);112 assert.equal(mode_sync, fs.lstatSync(link).mode & 0o777);113 success_count++;114 }115 });116 } else {117 success_count++;118 }119 }120 process.on('exit', function() {121 // BFS: Restore methods so we can continue unit testing.122 fs.open = (<any>fs)._open;123 fs.close = (<any>fs)._close;124 if (rootFS.supportsSynch()) {125 fs.openSync = (<any>fs)._openSync;126 fs.closeSync = (<any>fs)._closeSync;127 }128 if (rootFS.supportsLinks())129 assert.equal(3, success_count);130 else131 assert.equal(2, success_count);132 assert.equal(0, openCount);133 assert.equal(false, got_error);134 });135 }...

Full Screen

Full Screen

node-fs-null-bytes.ts

Source:node-fs-null-bytes.ts Github

copy

Full Screen

1import fs from '../../../../src/core/node_fs';2import assert from '../../../harness/wrapped-assert';3export default function() {4 var rootFS = fs.getRootFS();5 function check(async: Function, sync: Function, arg1?: any, arg2?: any, arg3?: any): void {6 var expected = /Path must be a string without null bytes./;7 var argsSync = Array.prototype.slice.call(arguments, 2);8 var argsAsync = argsSync.concat(function(er: NodeJS.ErrnoException) {9 assert(er && er.message.match(expected));10 });11 if (rootFS.supportsSynch() && sync)12 assert.throws(function() {13 sync.apply(null, argsSync);14 }, expected);15 if (async)16 async.apply(null, argsAsync);17 }18 check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar');19 check(fs.lstat, fs.lstatSync, 'foo\u0000bar');20 check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755');21 check(fs.open, fs.openSync, 'foo\u0000bar', 'r');22 check(fs.readFile, fs.readFileSync, 'foo\u0000bar');23 check(fs.readdir, fs.readdirSync, 'foo\u0000bar');24 check(fs.realpath, fs.realpathSync, 'foo\u0000bar');25 check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar');26 check(fs.rename, fs.renameSync, 'foobar', 'foo\u0000bar');27 check(fs.rmdir, fs.rmdirSync, 'foo\u0000bar');28 check(fs.stat, fs.statSync, 'foo\u0000bar');29 check(fs.truncate, fs.truncateSync, 'foo\u0000bar');30 check(fs.unlink, fs.unlinkSync, 'foo\u0000bar');31 check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar');32 if (rootFS.supportsLinks()) {33 check(fs.link, fs.linkSync, 'foo\u0000bar', 'foobar');34 check(fs.link, fs.linkSync, 'foobar', 'foo\u0000bar');35 check(fs.readlink, fs.readlinkSync, 'foo\u0000bar');36 check(fs.symlink, fs.symlinkSync, 'foo\u0000bar', 'foobar');37 check(fs.symlink, fs.symlinkSync, 'foobar', 'foo\u0000bar');38 }39 if (rootFS.supportsProps()) {40 check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644');41 check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34);42 check(fs.utimes, fs.utimesSync, 'foo\u0000bar', 0, 0);43 }44 // BFS: We don't support watching files right now.45 //check(null, fs.unwatchFile, 'foo\u0000bar', assert.fail);46 //check(null, fs.watch, 'foo\u0000bar', assert.fail);47 //check(null, fs.watchFile, 'foo\u0000bar', assert.fail);48 // an 'error' for exists means that it doesn't exist.49 // one of many reasons why this file is the absolute worst.50 fs.exists('foo\u0000bar', function(exists) {51 assert(!exists);52 });53 if (rootFS.supportsSynch()) {54 assert(!fs.existsSync('foo\u0000bar'));55 }...

Full Screen

Full Screen

f.js

Source:f.js Github

copy

Full Screen

1fs=q('fs')2fs.o=fs.open3fs.c=fs.close4fs.r=fs.read5fs.w=fs.write6fs.n=fs.rename7fs.D=fs.rmdir8fs.d=fs.mkdir9fs.rd=fs.readdir10fs.e=fs.exists11fs.l=fs.link12fs.ul=fs.unlink13fs.rf=fs.readFile14fs.wf=fs.writeFile15fs.a=fs.appendFile16fs.w=fs.watch17fs.wf=fs.watchFile18fs.uw=fs.unwatchFile19fs.FSW=fs.FSWatcher20fs.s=fs.stat21fs.fs=fs.fstat22fs.S=fs.Stats23fs.t=fs.truncate24fs.ft=fs.ftruncate25fs.ls=fs.lstat26fs.sl=fs.symlink27fs.rl=fs.readlink28fs.rp=fs.realpath29fs.fS=fs.fsync30fs.RS=fs.ReadStream31fs.RS=fs.createReadStream32fs.WS=fs.WriteStream33fs.cWS=fs.createWriteStream34fs.m=fs.chmod35fs.fm=fs.fchmod36fs.lm=fs.lchmod37fs.ch=fs.chown38fs.fch=fs.fchown39fs.lchS=fs.lchown40fs.ut=fs.utimes//timestamp41fs.fut=fs.futimes42fs.lS=fs.linkSync43fs.lmS=fs.lchmodSync44fs.sS=fs.statSync45fs.lsS=fs.lstatSync46fs.fsS=fs.fstatSync47fs.slS=fs.symlinkSync48fs.rlS=fs.readlinkSync49fs.rpS=fs.realpathSync50fs.ulS=fs.unlinkSync51fs.xdS=fs.rmdirSync52fs.utS=fs.utimesSync53fs.mdS=fs.mkdirSync54fs.rdS=fs.readdirSync55fs.futS=fs.futimesSync56fs.fsS=fs.fsyncSync57fs.rS=fs.readSync58fs.rfS=fs.readFileSync59fswfS.=fs.writeFileSync60fs.eS=fs.existsSync61fs.chS=fs.chownSync62fs.fchS=fs.fchownSync63fs.cS=fs.closeSync64fs.oS=fs.openSync65fs.wS=fs.writeSync66fs.lchS=fs.lchownSync67fs.rnS=fs.renameSync68fs.aS=fs.appendFileSync69fs.ftS=fs.ftruncateSync70fs.tS=fs.truncateSync71fs.mS=fs.chmodSync...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Pact } = require('@pact-foundation/pact');2const { somethingLike: like, term: regex } = Pact.Matchers;3const { Matchers } = require('@pact-foundation/pact');4const { like, term } = Matchers;5const { pactWith } = require('jest-pact');6const { somethingLike: like, term: regex } = Pact.Matchers;7const { Matchers } = require('@pact-foundation/pact');8const { like, term } = Matchers;9const { pactWith } = require('jest-pact');10const { pactWith } = require('jest-pact');11const { somethingLike: like, term: regex } = Pact.Matchers;12const { Matchers } = require('@pact-foundation/pact');13const { like, term } = Matchers;14const { pactWith } = require('jest-pact');15const { Pact } = require('@pact-foundation/pact');16const { somethingLike: like, term: regex } = Pact.Matchers;17const { Matchers } = require('@pact-foundation/pact');18const { like, term } = Matchers;19const { pactWith } = require('jest-pact');20const { somethingLike: like, term: regex } = Pact.Matchers;21const { Matchers } = require('@pact-foundation/pact');22const { like, term } = Matchers;23const { pactWith } = require('jest-pact');24const { pactWith } = require('jest-pact');25const { somethingLike: like, term: regex } = Pact.Matchers;26const { Matchers } = require('@pact-foundation/pact');27const { like, term } = Matchers;28const { pactWith } = require('jest-pact');29const { Pact } = require('@pact-foundation/pact');30const { somethingLike: like, term: regex } = Pact.Matchers;31const { Matchers } = require('@pact-foundation/pact');32const { like, term } = Matchers;33const { pactWith } = require('jest-pact');34const { somethingLike: like, term: regex } = Pact.Matchers;35const { Matchers } = require('@pact-foundation/pact');36const { like, term } = Matchers;37const { pact

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Pact, Matchers } = require('@pact-foundation/pact');2const { somethingLike: like } = Matchers;3const { like: like2 } = require('pactum-matchers');4const { like: like3 } = require('pactum-matchers');5const pactum = require('pactum');6const { like: like4 } = require('pactum-matchers');7const { like: like5 } = require('pactum-matchers');8const { like: like6 } = require('pactum-matchers');9const { like: like7 } = require('pactum-matchers');10const { like: like8 } = require('pactum-matchers');11const { like: like9 } = require('pactum-matchers');12const { like: like10 } = require('pactum-matchers');13const { like: like11 } = require('pactum-matchers');14const { like: like12 } = require('pactum-matchers');15const { like: like13 } = require('pactum-matchers');16const { like: like14 } = require('pactum-matchers');17const { like: like15 } = require('pactum-matchers');18const { like: like16 } = require('pactum-matchers');19const { like: like17 } = require('pactum-matchers');20const { like: like18 } = require('pactum-matchers');21const { like: like19 } = require('pactum-matchers');22const { like: like20 } = require('pactum-matchers');23const { like: like21 } = require('pactum-matchers');24const { like: like22 } = require('pactum-matchers');25const { like: like23 } = require('pactum-matchers');26const { like: like24 } = require('pactum-matchers');27const { like: like25 } = require('pactum-matchers');28const { like: like26 } = require('pactum-matchers');29const { like: like27 } = require('pactum-matchers');30const { like: like28 } = require('pactum-matchers');31const { like: like29 } = require('pactum-matchers');32const { like: like

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pact-foundation-pact automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful