Server IP : 127.0.0.2 / Your IP : 3.148.252.90 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/npm/node_modules/tar/test/ |
Upload File : |
// Set the umask, so that it works the same everywhere. process.umask(parseInt('22', 8)) var tap = require("tap") , tar = require("../tar.js") , fs = require("fs") , gfs = require("graceful-fs") , path = require("path") , file = path.resolve(__dirname, "fixtures/dir.tar") , target = path.resolve(__dirname, "tmp/extract-test") , index = 0 , fstream = require("fstream") , rimraf = require("rimraf") , mkdirp = require("mkdirp") , ee = 0 , expectEntries = [ { "path" : "dir/", "mode" : "750", "type" : "5", "depth" : undefined, "size" : 0, "linkpath" : "", "nlink" : undefined, "dev" : undefined, "ino" : undefined }, { "path" : "dir/sub/", "mode" : "750", "type" : "5", "depth" : undefined, "size" : 0, "linkpath" : "", "nlink" : undefined, "dev" : undefined, "ino" : undefined } ] function slow (fs, method, t1, t2) { var orig = fs[method] if (!orig) return null fs[method] = function () { var args = [].slice.call(arguments) console.error("slow", method, args[0]) var cb = args.pop() setTimeout(function () { orig.apply(fs, args.concat(function(er, data) { setTimeout(function() { cb(er, data) }, t2) })) }, t1) } } // Make sure we get the graceful-fs that fstream is using. var gfs2 try { gfs2 = require("fstream/node_modules/graceful-fs") } catch (er) {} var slowMethods = ["chown", "chmod", "utimes", "lutimes"] slowMethods.forEach(function (method) { var t1 = 500 var t2 = 0 slow(fs, method, t1, t2) slow(gfs, method, t1, t2) if (gfs2) { slow(gfs2, method, t1, t2) } }) // The extract class basically just pipes the input // to a Reader, and then to a fstream.DirWriter // So, this is as much a test of fstream.Reader and fstream.Writer // as it is of tar.Extract, but it sort of makes sense. tap.test("preclean", function (t) { rimraf.sync(target) /mkdirp.sync(target) t.pass("cleaned!") t.end() }) tap.test("extract test", function (t) { var extract = tar.Extract(target) var inp = fs.createReadStream(file) // give it a weird buffer size to try to break in odd places inp.bufferSize = 1234 inp.pipe(extract) extract.on("end", function () { rimraf.sync(target) t.equal(ee, expectEntries.length, "should see "+ee+" entries") // should get no more entries after end extract.removeAllListeners("entry") extract.on("entry", function (e) { t.fail("Should not get entries after end!") }) t.end() }) extract.on("entry", function (entry) { var found = { path: entry.path , mode: entry.props.mode.toString(8) , type: entry.props.type , depth: entry.props.depth , size: entry.props.size , linkpath: entry.props.linkpath , nlink: entry.props.nlink , dev: entry.props.dev , ino: entry.props.ino } var wanted = expectEntries[ee ++] t.equivalent(found, wanted, "tar entry " + ee + " " + wanted.path) }) })