Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
6d09ac3f
Unverified
Commit
6d09ac3f
authored
Nov 18, 2019
by
Robert Knight
Committed by
GitHub
Nov 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1474 from hypothesis/faster-partial-tests
Reduce test startup time when running a subset of tests
parents
b6ca3898
a9fe3c0a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
58 deletions
+40
-58
Makefile
Makefile
+4
-0
developing.rst
docs/developers/developing.rst
+2
-3
gulpfile.js
gulpfile.js
+12
-32
karma.config.js
src/karma.config.js
+22
-23
No files found.
Makefile
View file @
6d09ac3f
...
...
@@ -29,7 +29,11 @@ endif
.PHONY
:
servetests
servetests
:
node_modules/.uptodate
ifdef
FILTER
node_modules/.bin/gulp
test-watch
--grep
$(FILTER)
else
node_modules/.bin/gulp
test-watch
endif
.PHONY
:
lint
lint
:
node_modules/.uptodate
...
...
docs/developers/developing.rst
View file @
6d09ac3f
...
...
@@ -110,8 +110,7 @@ Hypothesis uses Karma and mocha for testing. To run all the tests once, run:
make test
You can filter the tests which are run by running ``make test FILTER=<pattern>``.
See the documentation for Mocha's
`grep <https://mochajs.org/#g---grep-pattern>`_ option.
Only test files matching ``<pattern>`` will be executed.
To run tests and automatically re-run them whenever any source files change, run:
...
...
@@ -121,7 +120,7 @@ To run tests and automatically re-run them whenever any source files change, run
This command will also serve the tests on localhost (typically `http://localhost:9876`)
so that break points can be set and the browser's console can be used for interactive
debugging.
debugging.
Code Style
...
...
gulpfile.js
View file @
6d09ac3f
...
...
@@ -36,15 +36,12 @@ let liveReloadChangedFiles = [];
function
parseCommandLine
()
{
commander
// Test configuration.
// See https://github.com/karma-runner/karma-mocha#configuration
.
option
(
'--grep [pattern]'
,
'Run only tests matching a given pattern'
)
.
option
(
'--grep [pattern]'
,
'Run only tests where filename matches a pattern'
)
.
parse
(
process
.
argv
);
if
(
commander
.
grep
)
{
gulpUtil
.
log
(
`Running tests matching pattern /
${
commander
.
grep
}
/`
);
}
return
{
grep
:
commander
.
grep
,
};
...
...
@@ -384,37 +381,20 @@ gulp.task(
)
);
function
runKarma
(
baseConfig
,
opts
,
done
)
{
// See https://github.com/karma-runner/karma-mocha#configuration
const
cliOpts
=
{
client
:
{
mocha
:
{
grep
:
taskArgs
.
grep
,
},
},
};
function
runKarma
({
singleRun
},
done
)
{
const
karma
=
require
(
'karma'
);
new
karma
.
Server
(
Object
.
assign
(
{},
{
configFile
:
path
.
resolve
(
__dirname
,
baseConfig
),
},
cliOpts
,
opts
),
{
configFile
:
path
.
resolve
(
__dirname
,
'./src/karma.config.js'
),
grep
:
taskArgs
.
grep
,
singleRun
,
},
done
).
start
();
}
gulp
.
task
(
'test'
,
function
(
callback
)
{
runKarma
(
'./src/karma.config.js'
,
{
singleRun
:
true
},
callback
);
});
gulp
.
task
(
'test-watch'
,
function
(
callback
)
{
runKarma
(
'./src/karma.config.js'
,
{},
callback
);
});
gulp
.
task
(
'test'
,
done
=>
runKarma
({
singleRun
:
true
},
done
));
gulp
.
task
(
'test-watch'
,
done
=>
runKarma
({
singleRun
:
false
},
done
));
gulp
.
task
(
'upload-sourcemaps'
,
...
...
src/karma.config.js
View file @
6d09ac3f
...
...
@@ -6,6 +6,7 @@
const
path
=
require
(
'path'
);
const
envify
=
require
(
'loose-envify/custom'
);
const
glob
=
require
(
'glob'
);
let
chromeFlags
=
[];
process
.
env
.
CHROME_BIN
=
require
(
'puppeteer'
).
executablePath
();
...
...
@@ -50,6 +51,22 @@ if (process.env.RUNNING_IN_DOCKER) {
}
module
.
exports
=
function
(
config
)
{
let
testFiles
=
[
'annotator/**/*-test.coffee'
,
'**/test/*-test.js'
,
'**/integration/*-test.js'
,
];
if
(
config
.
grep
)
{
const
allFiles
=
testFiles
.
map
(
pattern
=>
glob
.
sync
(
pattern
,
{
cwd
:
__dirname
}))
.
flat
();
testFiles
=
allFiles
.
filter
(
path
=>
path
.
match
(
config
.
grep
));
// eslint-disable-next-line no-console
console
.
log
(
`Running tests matching pattern "
${
config
.
grep
}
": `
,
testFiles
);
}
config
.
set
({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath
:
'./'
,
...
...
@@ -66,31 +83,13 @@ module.exports = function(config) {
// Empty HTML file to assist with some tests
{
pattern
:
'./annotator/test/empty.html'
,
watched
:
false
},
//
Karma watching is disabled for these files because they are
// bundled with karma-browserify which handles watching itself via
// watchify
//
Test modules.
...
testFiles
.
map
(
pattern
=>
({
pattern
,
// Unit tests
{
pattern
:
'annotator/**/*-test.coffee'
,
watched
:
false
,
included
:
true
,
served
:
true
,
},
{
pattern
:
'**/test/*-test.js'
,
// Disable watching because karma-browserify handles this.
watched
:
false
,
included
:
true
,
served
:
true
,
},
// Integration tests
{
pattern
:
'**/integration/*-test.js'
,
watched
:
false
,
included
:
true
,
served
:
true
,
},
})),
],
// list of files to exclude
...
...
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