C. Scott Ananian has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/401565 )
Change subject: WIP: skeleton of language converter test, based on the round-trip tester. ...................................................................... WIP: skeleton of language converter test, based on the round-trip tester. Change-Id: I72f3cc0fe15bac1fa65b3407f553f291697c5c4a --- A bin/langconv-test.js 1 file changed, 89 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/65/401565/1 diff --git a/bin/langconv-test.js b/bin/langconv-test.js new file mode 100755 index 0000000..12123b1 --- /dev/null +++ b/bin/langconv-test.js @@ -0,0 +1,89 @@ +#!/usr/bin/env node + +'use strict'; + +require('../core-upgrade.js'); + +var yargs = require('yargs'); + +var Promise = require('../lib/utils/promise.js'); +var Util = require('../lib/utils/Util.js').Util; + +var jsonFormat = function(error, prefix, title, results, profile) { + return { error: error }; +}; +var plainFormat = function(error, prefix, title, results, profile) { + return { error: error }; +}; +var xmlFormat = function(error, prefix, title, results, profile) { + return { error: error }; +}; + +var runTest = Promise.async(function *runTest(title, options, formatter) { + return { output: '', exitCode: 0 }; +}); + +if (require.main === module) { + var standardOpts = { + domain: { + description: 'Which wiki to use; e.g. "en.wikipedia.org" for' + + ' English wikipedia', + boolean: false, + default: '', // Add a default when `prefix` is removed. + }, + parsoidURL: { + description: 'The URL for the Parsoid API', + boolean: false, + default: '', + }, + apiURL: { + description: 'http path to remote API,' + + ' e.g. http://en.wikipedia.org/w/api.php', + boolean: false, + default: '', + }, + }; + + Promise.async(function *() { + var opts = yargs.usage( + 'Usage: $0 [options] <page-title>\n' + + 'The page title should be the "true title",' + + 'i.e., without any url encoding which might be necessary if it appeared in wikitext.' + + '\n\n', standardOpts + ).strict(); + + var argv = opts.argv; + if (!argv._.length) { + return opts.showHelp(); + } + var title = String(argv._[0]); + if (!argv.parsoidURL) { + // Start our own Parsoid server + var serviceWrapper = require('../tests/serviceWrapper.js'); + var serverOpts = { + logging: { level: 'info' }, + }; + if (argv.apiURL) { + serverOpts.mockURL = argv.apiURL; + argv.domain = 'customwiki'; + } else { + serverOpts.skipMock = true; + } + var ret = yield serviceWrapper.runServices(serverOpts); + argv.parsoidURL = ret.parsoidURL; + } + var formatter = Util.booleanOption(argv.xml) ? + xmlFormat : plainFormat; + var r = yield runTest(title, argv, formatter); + console.log(r.output); + if (argv.check) { + process.exit(r.exitCode); + } + })().done(); +} else if (typeof module === 'object') { + module.exports.runTest = runTest; + + module.exports.jsonFormat = jsonFormat; + module.exports.plainFormat = plainFormat; + module.exports.xmlFormat = xmlFormat; +} -- To view, visit https://gerrit.wikimedia.org/r/401565 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I72f3cc0fe15bac1fa65b3407f553f291697c5c4a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits