mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	casper: Add support for exporting results as XUnit XML file.
This commit is contained in:
		@@ -43,6 +43,9 @@ parser.add_argument('--remote-debug',
 | 
				
			|||||||
                    help='Whether or not to enable remote debugging on port 7777',
 | 
					                    help='Whether or not to enable remote debugging on port 7777',
 | 
				
			||||||
                    action="store_true",
 | 
					                    action="store_true",
 | 
				
			||||||
                    default=False)
 | 
					                    default=False)
 | 
				
			||||||
 | 
					parser.add_argument('--xunit-export', dest='xunit_export',
 | 
				
			||||||
 | 
					                    action="store_true",
 | 
				
			||||||
 | 
					                    default=False, help='Export the results of the test suite to an XUnit XML file,')
 | 
				
			||||||
parser.add_argument('tests', nargs=argparse.REMAINDER,
 | 
					parser.add_argument('tests', nargs=argparse.REMAINDER,
 | 
				
			||||||
                    help='Specific tests to run; by default, runs all tests')
 | 
					                    help='Specific tests to run; by default, runs all tests')
 | 
				
			||||||
options = parser.parse_args()
 | 
					options = parser.parse_args()
 | 
				
			||||||
@@ -94,6 +97,10 @@ def run_tests(files: Iterable[str], external_host: str) -> None:
 | 
				
			|||||||
    if options.verbose:
 | 
					    if options.verbose:
 | 
				
			||||||
        verbose = ["--verbose", "--log-level=debug"]
 | 
					        verbose = ["--verbose", "--log-level=debug"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xunit_export = []  # type: List[str]
 | 
				
			||||||
 | 
					    if options.xunit_export:
 | 
				
			||||||
 | 
					        xunit_export = ["--xunit=var/xunit-test-results/casper/result.xml"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with test_server_running(options.force, external_host):
 | 
					    with test_server_running(options.force, external_host):
 | 
				
			||||||
        # Important: do this next call inside the `with` block, when Django
 | 
					        # Important: do this next call inside the `with` block, when Django
 | 
				
			||||||
        #            will be pointing at the test database.
 | 
					        #            will be pointing at the test database.
 | 
				
			||||||
@@ -102,7 +109,7 @@ def run_tests(files: Iterable[str], external_host: str) -> None:
 | 
				
			|||||||
        ret = 1
 | 
					        ret = 1
 | 
				
			||||||
        for test_file in test_files:
 | 
					        for test_file in test_files:
 | 
				
			||||||
            test_name = os.path.basename(test_file)
 | 
					            test_name = os.path.basename(test_file)
 | 
				
			||||||
            cmd = ["node_modules/.bin/casperjs"] + remote_debug + verbose + ["test", test_file]
 | 
					            cmd = ["node_modules/.bin/casperjs"] + remote_debug + verbose + xunit_export + ["test", test_file]
 | 
				
			||||||
            print("\n\n===================== %s\nRunning %s\n\n" % (test_name, " ".join(map(shlex.quote, cmd))))
 | 
					            print("\n\n===================== %s\nRunning %s\n\n" % (test_name, " ".join(map(shlex.quote, cmd))))
 | 
				
			||||||
            ret = subprocess.call(cmd)
 | 
					            ret = subprocess.call(cmd)
 | 
				
			||||||
            if ret != 0:
 | 
					            if ret != 0:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ PYTHONWARNINGS=ignore ./tools/check-capitalization --no-generate
 | 
				
			|||||||
PYTHONWARNINGS=ignore ./tools/check-frontend-i18n --no-generate
 | 
					PYTHONWARNINGS=ignore ./tools/check-frontend-i18n --no-generate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run the slower Casper tests last
 | 
					# Run the slower Casper tests last
 | 
				
			||||||
./tools/test-js-with-casper
 | 
					./tools/test-js-with-casper --xunit-export
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# NB: Everything here should be in `tools/test-all`.  If there's a
 | 
					# NB: Everything here should be in `tools/test-all`.  If there's a
 | 
				
			||||||
# reason not to run it there, it should be there as a comment
 | 
					# reason not to run it there, it should be there as a comment
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,6 +59,7 @@ UPLOAD_DIR_PATH = os.path.join(VAR_DIR_PATH, 'uploads')
 | 
				
			|||||||
TEST_UPLOAD_DIR_PATH = os.path.join(VAR_DIR_PATH, 'test_uploads')
 | 
					TEST_UPLOAD_DIR_PATH = os.path.join(VAR_DIR_PATH, 'test_uploads')
 | 
				
			||||||
COVERAGE_DIR_PATH = os.path.join(VAR_DIR_PATH, 'coverage')
 | 
					COVERAGE_DIR_PATH = os.path.join(VAR_DIR_PATH, 'coverage')
 | 
				
			||||||
NODE_TEST_COVERAGE_DIR_PATH = os.path.join(VAR_DIR_PATH, 'node-coverage')
 | 
					NODE_TEST_COVERAGE_DIR_PATH = os.path.join(VAR_DIR_PATH, 'node-coverage')
 | 
				
			||||||
 | 
					XUNIT_XML_TEST_RESULTS_DIR_PATH = os.path.join(VAR_DIR_PATH, 'xunit-test-results')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
is_travis = 'TRAVIS' in os.environ
 | 
					is_travis = 'TRAVIS' in os.environ
 | 
				
			||||||
is_circleci = 'CIRCLECI' in os.environ
 | 
					is_circleci = 'CIRCLECI' in os.environ
 | 
				
			||||||
@@ -465,6 +466,8 @@ def main(options):
 | 
				
			|||||||
    os.makedirs(COVERAGE_DIR_PATH, exist_ok=True)
 | 
					    os.makedirs(COVERAGE_DIR_PATH, exist_ok=True)
 | 
				
			||||||
    # create linecoverage directory `var/node-coverage`
 | 
					    # create linecoverage directory `var/node-coverage`
 | 
				
			||||||
    os.makedirs(NODE_TEST_COVERAGE_DIR_PATH, exist_ok=True)
 | 
					    os.makedirs(NODE_TEST_COVERAGE_DIR_PATH, exist_ok=True)
 | 
				
			||||||
 | 
					    # create XUnit XML test results directory`var/xunit-test-results`
 | 
				
			||||||
 | 
					    os.makedirs(XUNIT_XML_TEST_RESULTS_DIR_PATH, exist_ok=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # The `build_emoji` script requires `emoji-datasource` package
 | 
					    # The `build_emoji` script requires `emoji-datasource` package
 | 
				
			||||||
    # which we install via npm; thus this step is after installing npm
 | 
					    # which we install via npm; thus this step is after installing npm
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user