Contributing to the project, especially regexes.yaml
, is both welcomed and encouraged. To do so just do the following:
-
Fork the project
-
Create a branch for your changes
-
Modify
regexes.yaml
as appropriate -
Create a text-file (e.g. ua.txt) which contains the User-Agent Strings (seperated by newline) you want to add to the testset in
./test_resources/tests.json
Please consider only real user-agents catched from your server logs for this file. -
Run
./js/bin/add.js -u ua.txt -t check.json
Check the results in
check.json
-
If you are sure that all is ok, run
./js/bin/add.js -u ua.txt
-
Run all tests with
npm test
-
Push your branch to GitHub and submit a pull request
-
Monitor the pull request to make sure the Travis build succeeds. If it fails simply make the necessary changes to your branch and push it. Travis will re-test the changes.
That's it. If you don't feel comfortable forking the project or modifying the YAML you can also submit an issue that includes the appropriate user-agent-string and the expected results of parsing.
Thanks!
The regexes.yaml
does not claim to be perfect.
If you encounter that parsing results are too coarse or even wrong you will encounter a lot of test errors while running the tests.
-
To easily change the test-set contained in
./test_resources/tests.json
do the following../js/bin/regen.js -c
-
At this stage really check that you did not miss out something.
diff test_resources/tests.js test_resources/new-tests.json
-
If you need to rerun tests and do not want to perform the full test-set, the previous tests for the bad-matching tests are stored in
./test_resources/bad-tests.json
.cp test_resources/bad-tests.json . ./js/bin/regen.js -i bad-tests.json -c
When all is as you expect re-run Step 1. and Step 2.
./js/bin/regen.js -c diff test_resources/tests.js test_resources/new-tests.json
-
All is ok now, then replace the test-set
cp test_resources/new-tests.js test_resources/tests.json
And rerun all tests
npm test
The tool ./js/bin/debuginfo.js
adds for each regex in regexes.yaml
a debug information which makes it easier together with regen.js -c
to identify the matching regular-expression for a failed test.
Rerunning the tool removes the debuginfo again.