Runs a smoke test (minimum valid AMP and empty html file). Args: out_dir: output directory
(out_dir)
| 317 | |
| 318 | |
| 319 | def RunSmokeTest(out_dir): |
| 320 | """Runs a smoke test (minimum valid AMP and empty html file). |
| 321 | |
| 322 | Args: |
| 323 | out_dir: output directory |
| 324 | """ |
| 325 | logging.info('entering ...') |
| 326 | # Run cli.js on the minimum valid amp and observe that it passes. |
| 327 | p = subprocess.Popen([ |
| 328 | 'node', 'js/nodejs/cli.js', '--validator_js', |
| 329 | '%s/validator_minified.js' % out_dir, |
| 330 | 'testdata/feature_tests/minimum_valid_amp.html', '--format=text' |
| 331 | ], |
| 332 | stdout=subprocess.PIPE, |
| 333 | stderr=subprocess.PIPE) |
| 334 | (stdout, stderr) = p.communicate() |
| 335 | if (b'testdata/feature_tests/minimum_valid_amp.html: PASS\n', b'', |
| 336 | p.returncode) != (stdout, stderr, 0): |
| 337 | Die('Smoke test failed. returncode=%d stdout="%s" stderr="%s"' % |
| 338 | (p.returncode, stdout, stderr)) |
| 339 | |
| 340 | # Run cli.js on an empty file and observe that it fails. |
| 341 | p = subprocess.Popen([ |
| 342 | 'node', 'js/nodejs/cli.js', '--validator_js', |
| 343 | '%s/validator_minified.js' % out_dir, 'testdata/feature_tests/empty.html', |
| 344 | '--format=text' |
| 345 | ], |
| 346 | stdout=subprocess.PIPE, |
| 347 | stderr=subprocess.PIPE) |
| 348 | (stdout, stderr) = p.communicate() |
| 349 | if p.returncode != 1: |
| 350 | Die('smoke test failed. Expected p.returncode==1, saw: %s' % p.returncode) |
| 351 | if not stderr.startswith(b'testdata/feature_tests/empty.html:1:0 ' |
| 352 | b'The mandatory tag \'html'): |
| 353 | Die('smoke test failed; stderr was: "%s"' % stderr) |
| 354 | logging.info('... done') |
| 355 | |
| 356 | |
| 357 | def RunIndexTest(): |