@@ -9,175 +9,60 @@ module.exports = function(grunt) {
9
9
path : require ( 'path' ) ,
10
10
vm : require ( 'vm' )
11
11
} ,
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' ,
13
16
DEST_TESTS_DIR = LIBS . path . resolve ( __dirname , '..' , 'tests' , 'test262' ) ;
14
17
15
18
16
19
grunt . registerTask ( 'update-tests' , 'refreshes the tests found in tests/test262' , function ( ) {
17
20
var gruntTaskDone = this . async ( ) ,
18
- testsURL ,
19
21
tempDir ,
20
22
testsTarball ,
21
23
srcTestsDir ;
22
24
23
25
LIBS . async . series ( [
24
26
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' ) ;
32
33
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 h r e f = " ( \/ t e s t s \/ t e s t 2 6 2 \/ a r c h i v e \/ [ ^ . ] + .t a r .g z ) " > g z < \/ 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 ( ) ;
62
34
} ,
63
35
64
36
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
+
73
39
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 ]
76
42
} , function ( err , results ) {
77
- tempDir = results . stdout ;
78
- grunt . log . ok ( 'temporary directory: ' + tempDir ) ;
79
43
asyncTaskDone ( err ) ;
80
44
} ) ;
81
45
} ,
82
46
83
47
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
- */
136
48
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 ]
142
51
} , function ( err , results ) {
143
- srcTestsDir = LIBS . path . resolve ( tempDir , 'test262-' + LIBS . path . basename ( testsTarball ) . split ( '.' ) [ 0 ] ) ;
144
- grunt . log . ok ( 'tests directory: ' + srcTestsDir ) ;
145
52
asyncTaskDone ( err ) ;
146
53
} ) ;
147
54
} ,
148
55
149
56
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 ) ;
158
63
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 ) ;
178
65
} ) ;
179
- grunt . log . ok ( 'done' ) ;
180
- asyncTaskDone ( ) ;
181
66
} ,
182
67
183
68
function ( asyncTaskDone ) {
0 commit comments