mirror of https://github.com/lukechilds/node.git
Browse Source
I was originally going to do this after the v0.11.15 release, but as that release is three weeks overdue now, I decided not to wait any longer; we don't want the delta to get too big. Conflicts: lib/net.js test/simple/simple.status PR-URL: https://github.com/iojs/io.js/pull/236 Reviewed-By: Bert Belder <bertbelder@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>v1.8.0-commit
73 changed files with 1111 additions and 302 deletions
@ -0,0 +1,103 @@ |
|||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
// copy of this software and associated documentation files (the
|
||||
|
// "Software"), to deal in the Software without restriction, including
|
||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||
|
// following conditions:
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included
|
||||
|
// in all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
||||
|
var common = require('../common'); |
||||
|
var assert = require('assert'); |
||||
|
|
||||
|
// does node think that i18n was enabled?
|
||||
|
var enablei18n = process.config.variables.v8_enable_i18n_support; |
||||
|
if (enablei18n === undefined) { |
||||
|
enablei18n = false; |
||||
|
} |
||||
|
|
||||
|
// is the Intl object present?
|
||||
|
var haveIntl = (global.Intl != undefined); |
||||
|
|
||||
|
// Returns true if no specific locale ids were configured (i.e. "all")
|
||||
|
// Else, returns true if loc is in the configured list
|
||||
|
// Else, returns false
|
||||
|
function haveLocale(loc) { |
||||
|
var locs = process.config.variables.icu_locales.split(','); |
||||
|
return locs.indexOf(loc) !== -1; |
||||
|
} |
||||
|
|
||||
|
if (!haveIntl) { |
||||
|
var erMsg = |
||||
|
'"Intl" object is NOT present but v8_enable_i18n_support is ' + |
||||
|
enablei18n; |
||||
|
assert.equal(enablei18n, false, erMsg); |
||||
|
console.log('Skipping Intl tests because Intl object not present.'); |
||||
|
|
||||
|
} else { |
||||
|
var erMsg = |
||||
|
'"Intl" object is present but v8_enable_i18n_support is ' + |
||||
|
enablei18n + |
||||
|
'. Is this test out of date?'; |
||||
|
assert.equal(enablei18n, true, erMsg); |
||||
|
|
||||
|
// Construct a new date at the beginning of Unix time
|
||||
|
var date0 = new Date(0); |
||||
|
|
||||
|
// Use the GMT time zone
|
||||
|
var GMT = 'Etc/GMT'; |
||||
|
|
||||
|
// Construct an English formatter. Should format to "Jan 70"
|
||||
|
var dtf = |
||||
|
new Intl.DateTimeFormat(['en'], |
||||
|
{timeZone: GMT, month: 'short', year: '2-digit'}); |
||||
|
|
||||
|
// If list is specified and doesn't contain 'en' then return.
|
||||
|
if (process.config.variables.icu_locales && !haveLocale('en')) { |
||||
|
console.log('Skipping detailed Intl tests because English is not listed ' + |
||||
|
'as supported.'); |
||||
|
// Smoke test. Does it format anything, or fail?
|
||||
|
console.log('Date(0) formatted to: ' + dtf.format(date0)); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// Check with toLocaleString
|
||||
|
var localeString = dtf.format(date0); |
||||
|
assert.equal(localeString, 'Jan 70'); |
||||
|
|
||||
|
// Options to request GMT
|
||||
|
var optsGMT = {timeZone: GMT}; |
||||
|
|
||||
|
// Test format
|
||||
|
localeString = date0.toLocaleString(['en'], optsGMT); |
||||
|
assert.equal(localeString, '1/1/1970, 12:00:00 AM'); |
||||
|
|
||||
|
// number format
|
||||
|
assert.equal(new Intl.NumberFormat(['en']).format(12345.67890), '12,345.679'); |
||||
|
|
||||
|
var collOpts = { sensitivity: 'base', ignorePunctuation: true }; |
||||
|
var coll = new Intl.Collator(['en'], collOpts); |
||||
|
|
||||
|
assert.equal(coll.compare('blackbird', 'black-bird'), 0, |
||||
|
'ignore punctuation failed'); |
||||
|
assert.equal(coll.compare('blackbird', 'red-bird'), -1, |
||||
|
'compare less failed'); |
||||
|
assert.equal(coll.compare('bluebird', 'blackbird'), 1, |
||||
|
'compare greater failed'); |
||||
|
assert.equal(coll.compare('Bluebird', 'bluebird'), 0, |
||||
|
'ignore case failed'); |
||||
|
assert.equal(coll.compare('\ufb03', 'ffi'), 0, |
||||
|
'ffi ligature (contraction) failed'); |
||||
|
} |
@ -0,0 +1,127 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
# Moved some utilities here from ../../configure |
||||
|
|
||||
|
import urllib |
||||
|
import hashlib |
||||
|
import sys |
||||
|
import zipfile |
||||
|
import tarfile |
||||
|
import fpformat |
||||
|
import contextlib |
||||
|
|
||||
|
def formatSize(amt): |
||||
|
"""Format a size as a string in MB""" |
||||
|
return fpformat.fix(amt / 1024000., 1) |
||||
|
|
||||
|
def spin(c): |
||||
|
"""print out an ASCII 'spinner' based on the value of counter 'c'""" |
||||
|
spin = ".:|'" |
||||
|
return (spin[c % len(spin)]) |
||||
|
|
||||
|
class ConfigOpener(urllib.FancyURLopener): |
||||
|
"""fancy opener used by retrievefile. Set a UA""" |
||||
|
# append to existing version (UA) |
||||
|
version = '%s node.js/configure' % urllib.URLopener.version |
||||
|
|
||||
|
def reporthook(count, size, total): |
||||
|
"""internal hook used by retrievefile""" |
||||
|
sys.stdout.write(' Fetch: %c %sMB total, %sMB downloaded \r' % |
||||
|
(spin(count), |
||||
|
formatSize(total), |
||||
|
formatSize(count*size))) |
||||
|
|
||||
|
def retrievefile(url, targetfile): |
||||
|
"""fetch file 'url' as 'targetfile'. Return targetfile or throw.""" |
||||
|
try: |
||||
|
sys.stdout.write(' <%s>\nConnecting...\r' % url) |
||||
|
sys.stdout.flush() |
||||
|
msg = ConfigOpener().retrieve(url, targetfile, reporthook=reporthook) |
||||
|
print '' # clear the line |
||||
|
return targetfile |
||||
|
except: |
||||
|
print ' ** Error occurred while downloading\n <%s>' % url |
||||
|
raise |
||||
|
|
||||
|
def md5sum(targetfile): |
||||
|
"""md5sum a file. Return the hex digest.""" |
||||
|
digest = hashlib.md5() |
||||
|
with open(targetfile, 'rb') as f: |
||||
|
chunk = f.read(1024) |
||||
|
while chunk != "": |
||||
|
digest.update(chunk) |
||||
|
chunk = f.read(1024) |
||||
|
return digest.hexdigest() |
||||
|
|
||||
|
def unpack(packedfile, parent_path): |
||||
|
"""Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path""" |
||||
|
if zipfile.is_zipfile(packedfile): |
||||
|
with contextlib.closing(zipfile.ZipFile(packedfile, 'r')) as icuzip: |
||||
|
print ' Extracting zipfile: %s' % packedfile |
||||
|
icuzip.extractall(parent_path) |
||||
|
return parent_path |
||||
|
elif tarfile.is_tarfile(packedfile): |
||||
|
with tarfile.TarFile.open(packedfile, 'r') as icuzip: |
||||
|
print ' Extracting tarfile: %s' % packedfile |
||||
|
icuzip.extractall(parent_path) |
||||
|
return parent_path |
||||
|
else: |
||||
|
packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc |
||||
|
raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix)) |
||||
|
|
||||
|
# List of possible "--download=" types. |
||||
|
download_types = set(['icu']) |
||||
|
|
||||
|
# Default options for --download. |
||||
|
download_default = "none" |
||||
|
|
||||
|
def help(): |
||||
|
"""This function calculates the '--help' text for '--download'.""" |
||||
|
return """Select which packages may be auto-downloaded. |
||||
|
valid values are: none, all, %s. (default is "%s").""" % (", ".join(download_types), download_default) |
||||
|
|
||||
|
def set2dict(keys, value=None): |
||||
|
"""Convert some keys (iterable) to a dict.""" |
||||
|
return dict((key, value) for (key) in keys) |
||||
|
|
||||
|
def parse(opt): |
||||
|
"""This function parses the options to --download and returns a set such as { icu: true }, etc. """ |
||||
|
if not opt: |
||||
|
opt = download_default |
||||
|
|
||||
|
theOpts = set(opt.split(',')) |
||||
|
|
||||
|
if 'all' in theOpts: |
||||
|
# all on |
||||
|
return set2dict(download_types, True) |
||||
|
elif 'none' in theOpts: |
||||
|
# all off |
||||
|
return set2dict(download_types, False) |
||||
|
|
||||
|
# OK. Now, process each of the opts. |
||||
|
theRet = set2dict(download_types, False) |
||||
|
for anOpt in opt.split(','): |
||||
|
if not anOpt or anOpt == "": |
||||
|
# ignore stray commas, etc. |
||||
|
continue |
||||
|
elif anOpt is 'all': |
||||
|
# all on |
||||
|
theRet = dict((key, True) for (key) in download_types) |
||||
|
else: |
||||
|
# turn this one on |
||||
|
if anOpt in download_types: |
||||
|
theRet[anOpt] = True |
||||
|
else: |
||||
|
# future proof: ignore unknown types |
||||
|
print 'Warning: ignoring unknown --download= type "%s"' % anOpt |
||||
|
# all done |
||||
|
return theRet |
||||
|
|
||||
|
def candownload(auto_downloads, package): |
||||
|
if not (package in auto_downloads.keys()): |
||||
|
raise Exception('Internal error: "%s" is not in the --downloads list. Check nodedownload.py' % package) |
||||
|
if auto_downloads[package]: |
||||
|
return True |
||||
|
else: |
||||
|
print """Warning: Not downloading package "%s". You could pass "--download=all" |
||||
|
(Windows: "download-all") to try auto-downloading it.""" % package |
||||
|
return False |
Loading…
Reference in new issue