Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
f01b114c
Commit
f01b114c
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
get frontend unit tests running under phantomjs - issue #635
parent
76b07770
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.travis.yml
+7
-1
7 additions, 1 deletion
.travis.yml
package.json
+1
-1
1 addition, 1 deletion
package.json
scripts/test
+41
-0
41 additions, 0 deletions
scripts/test
scripts/test_backend
+12
-16
12 additions, 16 deletions
scripts/test_backend
scripts/test_frontend
+52
-0
52 additions, 0 deletions
scripts/test_frontend
with
113 additions
and
18 deletions
.travis.yml
+
7
−
1
View file @
f01b114c
before_script
:
-
"
export
DISPLAY=:99.0"
-
"
sh
-e
/etc/init.d/xvfb
start"
language
:
node_js
before_install
:
...
...
@@ -11,7 +15,9 @@ notifications:
irc
:
"
irc.mozilla.org#identity"
env
:
-
MYSQL_USER=root
-
WHAT_TESTS=front MYSQL_USER=root
-
WHAT_TESTS=back NODE_ENV=test_mysql MYSQL_USER=root
-
WHAT_TESTS=back NODE_ENV=test_json
mysql
:
adapter
:
mysql2
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
1
View file @
f01b114c
...
...
@@ -41,7 +41,7 @@
},
"scripts"
:
{
"postinstall"
:
"./scripts/generate_ephemeral_keys.sh"
,
"test"
:
"./scripts/
run_all_tests.sh
"
,
"test"
:
"./scripts/
test
"
,
"start"
:
"./scripts/run_locally.js"
},
"engines"
:
{
...
...
This diff is collapsed.
Click to expand it.
scripts/test
0 → 100755
+
41
−
0
View file @
f01b114c
#!/usr/bin/env node
// a script to RUN TESTS. You can specify WHAT TESTS to run by
// populating an environment variable 'WHAT_TESTS'. Values include:
// * 'front' - frontend unit tests
// * 'back' - backend unit tests
// * 'all' - of it
const
spawn
=
require
(
'
child_process
'
).
spawn
,
path
=
require
(
'
path
'
);
// WHAT TESTS are we running?
var
whatTests
=
[];
if
(
process
.
env
[
'
WHAT_TESTS
'
])
{
whatTests
.
push
(
process
.
env
[
'
WHAT_TESTS
'
]);
if
(
whatTests
[
0
]
==
'
all
'
)
whatTests
=
[
'
front
'
,
'
back
'
];
}
else
{
whatTests
=
[
'
back
'
];
}
var
ec
=
0
;
function
run
()
{
if
(
!
whatTests
.
length
)
process
.
exit
(
ec
);
var
script
=
{
front
:
'
test_frontend
'
,
back
:
'
test_backend
'
}[
whatTests
.
shift
()];
console
.
log
(
script
);
var
kid
=
spawn
(
path
.
join
(
__dirname
,
script
));
kid
.
stdout
.
on
(
'
data
'
,
function
(
d
)
{
process
.
stdout
.
write
(
d
);
});
kid
.
stderr
.
on
(
'
data
'
,
function
(
d
)
{
process
.
stderr
.
write
(
d
);
});
kid
.
on
(
'
exit
'
,
function
(
code
)
{
if
(
code
)
process
.
exit
(
code
);
run
();
});
}
run
();
This diff is collapsed.
Click to expand it.
scripts/
run_all_tests.sh
→
scripts/
test_backend
+
12
−
16
View file @
f01b114c
...
...
@@ -17,19 +17,15 @@ fi
# vows hates absolute paths. sheesh.
cd
$BASEDIR
for
env
in
test_mysql test_json
;
do
export
NODE_ENV
=
$env
$SCRIPT_DIR
/test_db_connectivity.js
if
[
$?
=
0
]
;
then
echo
"Testing with NODE_ENV=
$env
"
for
file
in
tests/
*
.js
;
do
echo
$file
vows
$file
if
[[
$?
!=
0
]]
;
then
exit
1
fi
done
else
echo
"CANNOT TEST '
$env
' ENVIRONMENT: can't connect to the database"
fi
done
$SCRIPT_DIR
/test_db_connectivity.js
if
[
$?
=
0
]
;
then
for
file
in
tests/
*
.js
;
do
echo
$file
vows
$file
if
[[
$?
!=
0
]]
;
then
exit
1
fi
done
else
echo
"CANNOT TEST '
$env
' ENVIRONMENT: can't connect to the database"
fi
This diff is collapsed.
Click to expand it.
scripts/test_frontend
0 → 100755
+
52
−
0
View file @
f01b114c
#!/usr/bin/env node
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require
(
'
../tests/lib/test_env.js
'
);
const
assert
=
require
(
'
assert
'
),
vows
=
require
(
'
vows
'
),
start_stop
=
require
(
'
../tests/lib/start-stop.js
'
),
spawn
=
require
(
'
child_process
'
).
spawn
,
path
=
require
(
'
path
'
);
var
suite
=
vows
.
describe
(
'
frontend-tests
'
);
// disable vows (often flakey?) async error behavior
suite
.
options
.
error
=
false
;
start_stop
.
addStartupBatches
(
suite
);
suite
.
addBatch
({
"
frontend unit tests
"
:
{
topic
:
function
()
{
// what phantom.js binary?
var
bin
=
'
phantomjs
'
;
try
{
var
maybe
=
'
/usr/local/bin/phantomjs
'
;
if
(
!
fs
.
statSync
(
maybe
).
isFile
())
throw
"
meh
"
;
bin
=
maybe
;
}
catch
(
e
)
{};
var
kid
=
spawn
(
bin
,
[
path
.
join
(
__dirname
,
'
..
'
,
'
resources
'
,
'
static
'
,
'
test
'
,
'
phantomrunner.js
'
),
'
http://127.0.0.1:10002/test
'
]);
kid
.
stdout
.
on
(
'
data
'
,
function
(
d
)
{
process
.
stdout
.
write
(
d
);
});
kid
.
stderr
.
on
(
'
data
'
,
function
(
d
)
{
process
.
stderr
.
write
(
d
);
});
kid
.
on
(
'
exit
'
,
this
.
callback
);
},
"
pass!
"
:
function
(
code
)
{
assert
.
strictEqual
(
code
,
0
);
}
}
});
start_stop
.
addShutdownBatches
(
suite
);
// run or export the suite.
if
(
process
.
argv
[
1
]
===
__filename
)
suite
.
run
({},
function
(
r
)
{
process
.
exit
(
r
.
honored
==
r
.
total
?
0
:
1
);
});
else
suite
.
export
(
module
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment