Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open source the feature tests for the AMP Validator. #997

Merged
merged 1 commit into from
Nov 30, 2015
Merged

Open source the feature tests for the AMP Validator. #997

merged 1 commit into from
Nov 30, 2015

Conversation

powdercloud
Copy link
Contributor

This is still not integrated with the rest of the AMP build, so
it's piling onto build.py for now, taking the shortest route to
open source this rather than do a lot of internal refactoring first
(to be fair even this took some refactoring ...).

validator.js: Contains the logic for the test. This uses jasmin and
assert.js, the library that comes with NodeJS. I think this library
is fairly weak but for this particular purpose it was the easiest
to use because it keeps our node dependencies inside Google smaller
and the main usage here is to compare with the output of golden files.
On a positive note, validator_test.js is run through the closure
compiler so we have that going for us. The diff in build.py makes
it fairly easy to see what's going on:

  • CompileValidatorTestMinified runs closure to build validator_test.js
    with its transitive closure of dependencies, and the actual test method
    exported.
  • GenerateValidatorTest refines this into a script with #! line for
    nodejs at the top, and a relatively trivial snippet of Javascript to
    invoke the test, with the testdata dir as argument.
  • RunValidatorTest runs the test.

The tests in testdata/feature_tests are structured so that the .html file
contains descriptive comments explaining what the test is about, and
the .out files contain the validator output for the respective test.

This is still not integrated with the rest of the AMP build, so it's
piling onto build.py for now, taking the shortest route to open source
this rather than do a lot of internal refactoring first
(to be fair even this took some refactoring ...).

validator.js: Contains the logic for the test. This uses jasmin and
assert.js, the library that comes with NodeJS. I think this library is
fairly weak but for this particular purpose it was the easiest to use
because it keeps our node dependencies inside Google smaller and the
main usage here is to compare with the output of golden files.  On a
positive note, validator_test.js is run through the closure compiler so
we have that going for us. The diff in build.py makes it fairly easy to
see what's going on:

* CompileValidatorTestMinified runs closure to build validator_test.js
  with its transitive closure of dependencies, and the actual test
  method exported.

* GenerateValidatorTest refines this into a script with #! line for
  nodejs at the top, and a relatively trivial snippet of Javascript to
  invoke the test, with the testdata dir as argument.

* RunValidatorTest runs the test.

The tests in testdata/feature_tests are structured so that the .html
file contains descriptive comments explaining what the test is about,
and the .out files contain the validator output for the respective test.
@dvoytenko dvoytenko self-assigned this Nov 24, 2015
@dvoytenko
Copy link
Contributor

LGTM

@dvoytenko
Copy link
Contributor

@powdercloud Ready to be merged?

dvoytenko added a commit that referenced this pull request Nov 30, 2015
Open source the feature tests for the AMP Validator.
@dvoytenko dvoytenko merged commit 522e5c2 into ampproject:master Nov 30, 2015
@powdercloud powdercloud deleted the feature_tests branch April 8, 2016 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants