Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
ff7a4345
Commit
ff7a4345
authored
Jul 23, 2012
by
Richard Gibson
Committed by
Dave Methvin
Jul 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Really support subproject tests in testswarm, closes gh-868
parent
94924a05
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
62 deletions
+108
-62
grunt.js
grunt.js
+1
-1
testrunner.js
test/data/testrunner.js
+107
-61
No files found.
grunt.js
View file @
ff7a4345
...
@@ -128,7 +128,7 @@ module.exports = function( grunt ) {
...
@@ -128,7 +128,7 @@ module.exports = function( grunt ) {
var
testswarm
=
require
(
"testswarm"
),
var
testswarm
=
require
(
"testswarm"
),
testUrls
=
[],
testUrls
=
[],
config
=
grunt
.
file
.
readJSON
(
configFile
).
jquery
,
config
=
grunt
.
file
.
readJSON
(
configFile
).
jquery
,
tests
=
"ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue serialize s
elector support traversing"
.
split
(
" "
);
tests
=
"ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue serialize s
upport traversing Sizzle"
.
split
(
" "
);
tests
.
forEach
(
function
(
test
)
{
tests
.
forEach
(
function
(
test
)
{
testUrls
.
push
(
config
.
testUrl
+
commit
+
"/test/index.html?module="
+
test
);
testUrls
.
push
(
config
.
testUrl
+
commit
+
"/test/index.html?module="
+
test
);
...
...
test/data/testrunner.js
View file @
ff7a4345
...
@@ -8,37 +8,80 @@ jQuery.noConflict();
...
@@ -8,37 +8,80 @@ jQuery.noConflict();
var
Sizzle
=
Sizzle
||
jQuery
.
find
;
var
Sizzle
=
Sizzle
||
jQuery
.
find
;
// Allow subprojects to test against their own fixtures
// Allow subprojects to test against their own fixtures
var
qunitModule
=
QUnit
.
module
;
var
qunitModule
=
QUnit
.
module
,
qunitTest
=
QUnit
.
test
;
function
testSubproject
(
label
,
url
,
risTests
)
{
function
testSubproject
(
label
,
url
,
risTests
)
{
module
(
"Subproject: "
+
label
);
var
sub
,
fixture
,
fixtureHTML
,
fixtureReplaced
=
false
;
// Don't let subproject tests jump the gun
QUnit
.
config
.
reorder
=
false
;
// Create module
module
(
label
);
// Duckpunch QUnit
module
=
QUnit
.
module
=
function
(
name
)
{
module
=
QUnit
.
module
=
function
(
name
)
{
return
qunitModule
.
apply
(
this
,
[
label
+
": "
+
name
].
concat
(
[].
slice
.
call
(
arguments
,
1
)
)
);
var
args
=
arguments
;
};
test
(
"Copy test fixture"
,
function
()
{
// Remember subproject-scoped module name
expect
(
3
)
;
sub
=
name
;
// Don't let subproject tests jump the gun
// Override
QUnit
.
config
.
reorder
=
false
;
args
[
0
]
=
label
;
return
qunitModule
.
apply
(
this
,
args
);
};
test
=
function
(
name
)
{
var
args
=
arguments
,
i
=
args
.
length
-
1
;
// Prepend subproject-scoped module name to test name
args
[
0
]
=
sub
+
": "
+
name
;
// Find test function and wrap to require subproject fixture
for
(
;
i
>=
0
;
i
--
)
{
if
(
jQuery
.
isFunction
(
args
[
i
]
)
)
{
args
[
i
]
=
requireFixture
(
args
[
i
]
);
break
;
}
}
return
qunitTest
.
apply
(
this
,
args
);
};
stop
();
// Load tests and fixture from subproject
// Test order matters, so we must be synchronous and throw an error on load failure
jQuery
.
ajax
(
url
,
{
jQuery
.
ajax
(
url
,
{
async
:
false
,
dataType
:
"html"
,
dataType
:
"html"
,
error
:
function
(
jqXHR
,
status
)
{
error
:
function
(
jqXHR
,
status
)
{
ok
(
false
,
"Retrieved test page: "
+
status
);
throw
new
Error
(
"Could not load: "
+
url
+
" ("
+
status
+
")"
);
},
},
success
:
function
(
data
)
{
success
:
function
(
data
,
status
,
jqXHR
)
{
var
page
,
fixture
,
fixtureHTML
,
var
page
=
jQuery
.
parseHTML
(
oldFixture
=
jQuery
(
"#qunit-fixture"
);
// replace html/head with dummy elements so they are represented in the DOM
(
data
||
""
).
replace
(
/
(
<
\/?)(?:
html|head
)\b
/g
,
"$1div"
),
ok
(
data
,
"Retrieved test page"
);
try
{
page
=
jQuery
(
jQuery
.
parseHTML
(
data
.
replace
(
/
(
<
\/?)(?:
html|head
)\b
/g
,
"$1div"
),
document
,
document
,
true
true
)
);
);
if
(
!
page
||
!
page
.
length
)
{
this
.
error
(
jqXHR
,
"no data"
);
}
page
=
jQuery
(
page
);
// Include subproject tests
page
.
filter
(
"script[src]"
).
add
(
page
.
find
(
"script[src]"
)
).
each
(
function
()
{
var
src
=
jQuery
(
this
).
attr
(
"src"
),
html
=
"<script src='"
+
url
+
src
+
"'></script>"
;
if
(
risTests
.
test
(
src
)
)
{
if
(
jQuery
.
isReady
)
{
jQuery
(
"head"
).
first
().
append
(
html
);
}
else
{
document
.
write
(
html
);
}
}
});
// Get the fixture, including content outside of #qunit-fixture
// Get the fixture, including content outside of #qunit-fixture
fixture
=
page
.
find
(
"[id='qunit-fixture']"
);
fixture
=
page
.
find
(
"[id='qunit-fixture']"
);
...
@@ -48,9 +91,20 @@ function testSubproject( label, url, risTests ) {
...
@@ -48,9 +91,20 @@ function testSubproject( label, url, risTests ) {
fixture
=
fixture
.
parent
();
fixture
=
fixture
.
parent
();
}
}
fixture
=
fixture
.
add
(
fixture
.
nextAll
()
);
fixture
=
fixture
.
add
(
fixture
.
nextAll
()
);
ok
(
fixture
.
html
(),
"Found test fixture"
);
}
});
function
requireFixture
(
fnTest
)
{
return
function
()
{
if
(
!
fixtureReplaced
)
{
// Make sure that we retrieved a fixture for the subproject
if
(
!
fixture
.
length
)
{
ok
(
false
,
"Found subproject fixture"
);
return
;
}
// Replace the current fixture, again including content outside of #qunit-fixture
// Replace the current fixture, including content outside of #qunit-fixture
var
oldFixture
=
jQuery
(
"#qunit-fixture"
);
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id^='qunit-']"
).
length
)
{
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id^='qunit-']"
).
length
)
{
oldFixture
=
oldFixture
.
parent
();
oldFixture
=
oldFixture
.
parent
();
}
}
...
@@ -60,25 +114,17 @@ function testSubproject( label, url, risTests ) {
...
@@ -60,25 +114,17 @@ function testSubproject( label, url, risTests ) {
// WARNING: UNDOCUMENTED INTERFACE
// WARNING: UNDOCUMENTED INTERFACE
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
reset
();
QUnit
.
reset
();
equal
(
jQuery
(
"#qunit-fixture"
).
html
(),
fixtureHTML
,
"Copied test fixture"
);
if
(
jQuery
(
"#qunit-fixture"
).
html
()
!==
fixtureHTML
)
{
ok
(
false
,
"Copied subproject fixture"
);
return
;
}
// Include subproject tests
fixtureReplaced
=
true
;
page
.
find
(
"script[src]"
).
add
(
page
.
filter
(
"script[src]"
)
).
filter
(
function
()
{
var
src
=
jQuery
(
this
).
attr
(
"src"
);
if
(
risTests
.
test
(
src
)
)
{
this
.
src
=
url
+
src
;
return
true
;
}
}
}).
appendTo
(
"head:first"
);
}
catch
(
x
)
{
fnTest
.
apply
(
this
,
arguments
);
ok
(
false
,
"Failed to copy test fixture: "
+
(
x
.
message
||
x
)
);
}
}
},
complete
:
function
()
{
start
();
}
}
});
});
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment