Skip to content

Commit

Permalink
Fixing indents to match cl (#29827)
Browse files Browse the repository at this point in the history
* tidy indents

* add the dot
  • Loading branch information
honeybadgerdontcare authored Aug 13, 2020
1 parent eb6a4ce commit 09517c5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
8 changes: 4 additions & 4 deletions validator/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ def InstallNodeDependencies():
['npx', 'yarn', 'install'],
stdout=(open(os.devnull, 'wb') if os.environ.get('TRAVIS') else sys.stdout))
logging.info('installing AMP Validator nodejs dependencies ...')
subprocess.check_call(
['npx', 'yarn', 'install'],
cwd='js/nodejs',
stdout=(open(os.devnull, 'wb') if os.environ.get('TRAVIS') else sys.stdout))
subprocess.check_call(['npx', 'yarn', 'install'],
cwd='js/nodejs',
stdout=(open(os.devnull, 'wb')
if os.environ.get('TRAVIS') else sys.stdout))
logging.info('... done')


Expand Down
2 changes: 1 addition & 1 deletion validator/js/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This package is published and available at
https://www.npmjs.com/package/amphtml-validator.

The source code is available at
https://github.com/ampproject/amphtml/tree/master/validator/nodejs.
https://github.com/ampproject/amphtml/tree/master/validator/js/nodejs.

## Command Line Tool

Expand Down
72 changes: 43 additions & 29 deletions validator/js/nodejs/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ it('built validator rejects the empty file', function(done) {

it('accepts the minimum valid AMP file', function(done) {
// Note: This will use the validator that was built with build.py.
const mini = fs.readFileSync(
'../../testdata/feature_tests/minimum_valid_amp.html', 'utf-8').trim();
const mini =
fs.readFileSync(
'../../testdata/feature_tests/minimum_valid_amp.html', 'utf-8')
.trim();
ampValidator.getInstance(/*validatorJs*/ '../../dist/validator_minified.js')
.then(function(instance) {
const validationResult = instance.validateString(mini);
Expand All @@ -83,9 +85,11 @@ it('accepts the minimum valid AMP file', function(done) {

it('accepts the minimum valid AMP4ADS file', function(done) {
// Note: This will use the validator that was built with build.py.
const mini = fs.readFileSync(
'../../testdata/amp4ads_feature_tests/min_valid_amp4ads.html', 'utf-8')
.trim();
const mini =
fs.readFileSync(
'../../testdata/amp4ads_feature_tests/min_valid_amp4ads.html',
'utf-8')
.trim();
ampValidator.getInstance(/*validatorJs*/ '../../dist/validator_minified.js')
.then(function(instance) {
const validationResult = instance.validateString(mini, 'AMP4ADS');
Expand All @@ -112,13 +116,15 @@ function isErrorLine(line) {
it('rejects a specific file that is known to have errors', function(done) {
// Note: This will use the validator that was built with build.py.
const severalErrorsHtml =
fs.readFileSync('../../testdata/feature_tests/several_errors.html', 'utf-8')
.trim();
fs.readFileSync(
'../../testdata/feature_tests/several_errors.html', 'utf-8')
.trim();
const severalErrorsOut =
fs.readFileSync('../../testdata/feature_tests/several_errors.out', 'utf-8')
.split('\n')
.filter(isErrorLine)
.join('\n');
fs.readFileSync(
'../../testdata/feature_tests/several_errors.out', 'utf-8')
.split('\n')
.filter(isErrorLine)
.join('\n');

ampValidator.getInstance(/*validatorJs*/ '../../dist/validator_minified.js')
.then(function(instance) {
Expand Down Expand Up @@ -163,8 +169,10 @@ it('handles syntax errors in validator file', function(done) {
});

it('also works with newInstance', function() {
const mini = fs.readFileSync(
'../../testdata/feature_tests/minimum_valid_amp.html', 'utf-8').trim();
const mini =
fs.readFileSync(
'../../testdata/feature_tests/minimum_valid_amp.html', 'utf-8')
.trim();
const validatorJsContents =
fs.readFileSync('../../dist/validator_minified.js', 'utf-8');
const resultForMini =
Expand All @@ -173,8 +181,9 @@ it('also works with newInstance', function() {
expect(resultForMini.status).toBe('PASS');

const severalErrorsHtml =
fs.readFileSync('../../testdata/feature_tests/several_errors.html', 'utf-8')
.trim();
fs.readFileSync(
'../../testdata/feature_tests/several_errors.html', 'utf-8')
.trim();
const resultForSeveralErrors = ampValidator.newInstance(validatorJsContents)
.validateString(severalErrorsHtml);

Expand All @@ -183,20 +192,22 @@ it('also works with newInstance', function() {

it('emits text if --format=text is specified on command line', function(done) {
const severalErrorsOut =
fs.readFileSync('../../testdata/feature_tests/several_errors.out', 'utf-8')
.split('\n')
.filter(isErrorLine)
.splice(1) // trim 1st line
.join('\n');
fs.readFileSync(
'../../testdata/feature_tests/several_errors.out', 'utf-8')
.split('\n')
.filter(isErrorLine)
.splice(1) // trim 1st line
.join('\n');
execFile(
process.execPath,
[
'../js/nodejs/cli.js', '--format=text',
'../js/nodejs/cli.js',
'--format=text',
'--validator_js=../dist/validator_minified.js',
'feature_tests/several_errors.html',
'feature_tests/minimum_valid_amp.html',
],
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
function(error, stdout, stderr) {
expect(error).toBeDefined(); // At least one file had errors.
expect(stderr).toBe(severalErrorsOut);
Expand All @@ -209,12 +220,13 @@ it('emits json if --format=json is specified on command line', function(done) {
execFile(
process.execPath,
[
'../js/nodejs/cli.js', '--format=json',
'../js/nodejs/cli.js',
'--format=json',
'--validator_js=../dist/validator_minified.js',
'feature_tests/several_errors.html',
'feature_tests/minimum_valid_amp.html',
],
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
function(error, stdout, stderr) {
expect(error).toBeDefined(); // At least one file had errors
expect(stderr).toBe(''); // entire json results will be on stdout
Expand All @@ -240,21 +252,23 @@ it('emits json if --format=json is specified on command line', function(done) {
it('supports AMP4ADS with --html_format command line option', function(done) {
const severalErrorsOut =
fs.readFileSync(
'../../testdata/amp4ads_feature_tests/style-amp-custom.out',
'utf-8')
'../../testdata/amp4ads_feature_tests/style-amp-custom.out',
'utf-8')
.split('\n')
.filter(isErrorLine)
.splice(1) // trim 1st line
.splice(1) // trim 1st line
.join('\n');
execFile(
process.execPath,
[
'../js/nodejs/cli.js', '--format=text', '--html_format=AMP4ADS',
'../js/nodejs/cli.js',
'--format=text',
'--html_format=AMP4ADS',
'--validator_js=../dist/validator_minified.js',
'amp4ads_feature_tests/style-amp-custom.html',
'amp4ads_feature_tests/min_valid_amp4ads.html',
],
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
{'cwd': '../../testdata'}, // Run inside the testdata dir to match paths.
function(error, stdout, stderr) {
expect(error).toBeDefined(); // At least one file had errors.
expect(stderr).toBe(severalErrorsOut);
Expand Down

0 comments on commit 09517c5

Please sign in to comment.