Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 90c17df

Browse files
committed
Download test suite from new tc39 GitHub repo
Old Mercurial repo is no longer active
1 parent 9b58d0d commit 90c17df

File tree

1 file changed

+23
-138
lines changed

1 file changed

+23
-138
lines changed

tasks/update-tests.js

+23-138
Original file line numberDiff line numberDiff line change
@@ -9,175 +9,60 @@ module.exports = function(grunt) {
99
path: require('path'),
1010
vm: require('vm')
1111
},
12-
URL_BASE = 'http://hg.ecmascript.org',
12+
URL_BASE = 'https://github.com/tc39/test262/trunk',
13+
SUITE = '/test/suite/intl402',
14+
HARNESS = '/test/harness',
15+
LICENSE = '/LICENSE',
1316
DEST_TESTS_DIR = LIBS.path.resolve(__dirname, '..', 'tests', 'test262');
1417

1518

1619
grunt.registerTask('update-tests', 'refreshes the tests found in tests/test262', function() {
1720
var gruntTaskDone = this.async(),
18-
testsURL,
1921
tempDir,
2022
testsTarball,
2123
srcTestsDir;
2224

2325
LIBS.async.series([
2426
function(asyncTaskDone) {
25-
var resErr,
26-
resBody = '';
27-
grunt.log.writeln('looking for tests tarball...');
28-
/*
29-
// DEBUGGING
30-
testsURL = 'http://hg.ecmascript.org/tests/test262/archive/d067d2f0ca30.tar.gz';
31-
grunt.log.ok('tests URL: ' + testsURL);
27+
grunt.log.writeln('clearing old tests/test262...');
28+
var doomed = grunt.file.expand(DEST_TESTS_DIR + '/*');
29+
doomed.forEach(function(path) {
30+
grunt.file.delete(path);
31+
});
32+
grunt.log.ok('done');
3233
asyncTaskDone();
33-
return;
34-
*/
35-
36-
LIBS.http.get(URL_BASE + '/tests/test262/file/', function(res) {
37-
if (200 !== res.statusCode) {
38-
asyncTaskDone(new Error('failed to GET ' + URL_BASE + '/tests/test262/file/'));
39-
return;
40-
}
41-
res.on('data', function(data) {
42-
resBody += data.toString();
43-
});
44-
res.on('error', function(err) {
45-
resErr = err;
46-
});
47-
res.on('end', function() {
48-
var matches;
49-
matches = resBody.match(/<a href="(\/tests\/test262\/archive\/[^.]+.tar.gz)">gz<\/a>/);
50-
testsURL = matches[1];
51-
if (!testsURL) {
52-
asyncTaskDone(new Error('failed to find tar.gz of tests'));
53-
return;
54-
}
55-
if ('/' === testsURL[0]) {
56-
testsURL = URL_BASE + testsURL;
57-
}
58-
grunt.log.ok('tests URL: ' + testsURL);
59-
asyncTaskDone(resErr);
60-
});
61-
}).end();
6234
},
6335

6436
function(asyncTaskDone) {
65-
grunt.log.writeln('making temporary directory...');
66-
/*
67-
// DEBUGGING
68-
tempDir = '/tmp/grunt.o4xlDE3o';
69-
grunt.log.ok('temporary directory: ' + tempDir);
70-
asyncTaskDone();
71-
return;
72-
*/
37+
grunt.log.writeln('downloading latest test suite');
38+
7339
grunt.util.spawn({
74-
cmd: 'mktemp',
75-
args: ['-d', '/tmp/grunt.XXXXXXXX']
40+
cmd: 'svn',
41+
args: ['export', URL_BASE + LICENSE, DEST_TESTS_DIR + LICENSE]
7642
}, function(err, results) {
77-
tempDir = results.stdout;
78-
grunt.log.ok('temporary directory: ' + tempDir);
7943
asyncTaskDone(err);
8044
});
8145
},
8246

8347
function(asyncTaskDone) {
84-
var resErr,
85-
resBody = new Buffer(0),
86-
reportEveryBytes = 300000,
87-
reportBytes = 0;
88-
grunt.log.writeln('downloading tests tarball...');
89-
/*
90-
// DEBUGGING
91-
testsTarball = tempDir + '/d067d2f0ca30.tar.gz';
92-
grunt.log.ok('tests tarball: ' + testsTarball);
93-
asyncTaskDone();
94-
return;
95-
*/
96-
LIBS.http.get(testsURL, function(res) {
97-
if (200 !== res.statusCode) {
98-
asyncTaskDone(new Error('failed to GET ' + testsUR));
99-
return;
100-
}
101-
res.on('data', function(data) {
102-
// We need to use the Buffer class to safely handle binary
103-
// data (octet streams). Alas, it's not resizable so we
104-
// need to reallocate as we go along.
105-
var newBuffer = Buffer(resBody.length + data.length);
106-
resBody.copy(newBuffer, 0);
107-
data.copy(newBuffer, resBody.length);
108-
resBody = newBuffer;
109-
reportBytes += data.length;
110-
if (reportBytes >= reportEveryBytes) {
111-
grunt.log.ok('got ' + resBody.length + ' bytes');
112-
reportBytes = 0;
113-
}
114-
});
115-
res.on('error', function(err) {
116-
resErr = err;
117-
});
118-
res.on('end', function() {
119-
testsTarball = LIBS.path.resolve(tempDir, LIBS.path.basename(testsURL));
120-
grunt.file.write(testsTarball, resBody.toString('binary'), {encoding: 'binary'});
121-
grunt.log.ok('tests tarball: ' + testsTarball);
122-
asyncTaskDone(resErr);
123-
});
124-
}).end();
125-
},
126-
127-
function(asyncTaskDone) {
128-
grunt.log.writeln('expanding tests tarball...');
129-
/*
130-
// DEBUGGING
131-
srcTestsDir = tempDir + '/test262-d067d2f0ca30';
132-
grunt.log.ok('tests directory: ' + srcTestsDir);
133-
asyncTaskDone();
134-
return;
135-
*/
13648
grunt.util.spawn({
137-
cmd: 'tar',
138-
args: ['xfz', LIBS.path.basename(testsTarball)],
139-
opts: {
140-
cwd: tempDir
141-
}
49+
cmd: 'svn',
50+
args: ['export', URL_BASE + HARNESS, DEST_TESTS_DIR + HARNESS]
14251
}, function(err, results) {
143-
srcTestsDir = LIBS.path.resolve(tempDir, 'test262-' + LIBS.path.basename(testsTarball).split('.')[0]);
144-
grunt.log.ok('tests directory: ' + srcTestsDir);
14552
asyncTaskDone(err);
14653
});
14754
},
14855

14956
function(asyncTaskDone) {
150-
grunt.log.writeln('clearing old tests/test262...');
151-
var doomed = grunt.file.expand(DEST_TESTS_DIR + '/*');
152-
doomed.forEach(function(path) {
153-
grunt.file.delete(path);
154-
});
155-
grunt.log.ok('done');
156-
asyncTaskDone();
157-
},
57+
grunt.util.spawn({
58+
cmd: 'svn',
59+
args: ['export', URL_BASE + SUITE, DEST_TESTS_DIR + SUITE]
60+
}, function(err, results) {
61+
if (!err)
62+
grunt.log.ok('downloaded to ' + DEST_TESTS_DIR);
15863

159-
function(asyncTaskDone) {
160-
grunt.log.writeln('copying from tarball to tests/test262...');
161-
grunt.file.copy(
162-
LIBS.path.resolve(srcTestsDir, 'LICENSE'),
163-
LIBS.path.resolve(DEST_TESTS_DIR, 'LICENSE')
164-
);
165-
166-
['tools', 'test'].forEach(function(dir) {
167-
grunt.log.ok(dir);
168-
var files = grunt.file.expand(
169-
LIBS.path.resolve(srcTestsDir, dir) + '/**'
170-
);
171-
files.forEach(function(srcPath) {
172-
if (! grunt.file.isFile(srcPath)) {
173-
return;
174-
}
175-
var destPath = srcPath.replace(srcTestsDir, LIBS.path.resolve(DEST_TESTS_DIR));
176-
grunt.file.copy(srcPath, destPath);
177-
});
64+
asyncTaskDone(err);
17865
});
179-
grunt.log.ok('done');
180-
asyncTaskDone();
18166
},
18267

18368
function(asyncTaskDone) {

0 commit comments

Comments
 (0)