Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Add a bunch of missing license blocks and fix some lint warnings in v…
Browse files Browse the repository at this point in the history
…arious support files and scripts.

RELNOTES: n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=203042979
  • Loading branch information
shicks committed Jul 4, 2018
1 parent b3be3e5 commit b426509
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 44 deletions.
34 changes: 31 additions & 3 deletions browser_capabilities.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// Copyright 2018 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var sauceBrowsers = require('./sauce_browsers.json');

/**
* Returns a versioned name for the given capability object.
* @param {!Object} browserCap
* @return {string}
*/
function getBrowserName(browserCap) {
var name = browserCap.browserName == 'internet explorer' ?
'ie' :
Expand All @@ -8,6 +27,11 @@ function getBrowserName(browserCap) {
return name + version;
}

/**
* Returns the travis job name for the given capability object.
* @param {!Object} browserCap
* @return {string}
*/
function getJobName(browserCap) {
var browserName = getBrowserName(browserCap);

Expand All @@ -17,16 +41,20 @@ function getJobName(browserCap) {
process.env.TRAVIS_BRANCH;
}

/**
* Adds 'name', 'build', and 'tunnel-identifier' properties to all elements,
* based on runtime information from the environment.
* @param {!Array<!Object>} browsers
* @return {!Array<!Object>} The original array, whose objects are augmented.
*/
function getBrowserCapabilities(browsers) {
var caps = [];
for (var i = 0; i < browsers.length; i++) {
var b = browsers[i];
b['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
b['build'] = process.env.TRAVIS_BUILD_NUMBER;
b['name'] = getJobName(b);
caps.push(b);
}
return caps;
return browsers;
}

module.exports = getBrowserCapabilities(sauceBrowsers);
14 changes: 14 additions & 0 deletions protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2018 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// See https://github.com/angular/protractor/blob/master/docs/referenceConf.js
// for full protractor config reference.
var browserCapabilities = require('./browser_capabilities');
Expand Down
55 changes: 39 additions & 16 deletions protractor_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2018 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO(joeltine): Remove promise module when stable node version supports it
// natively.
var Promise = require('promise');
Expand Down Expand Up @@ -36,7 +50,9 @@ describe('Run all Closure unit tests', function() {
return tests;
};

beforeAll(function() { allTests = removeIgnoredTests(allTests); });
beforeAll(function() {
allTests = removeIgnoredTests(allTests);
});

beforeEach(function() {
// Ignores synchronization with angular loading. Since we don't use angular,
Expand All @@ -53,18 +69,19 @@ describe('Run all Closure unit tests', function() {
// executeScript runs the passed method in the "window" context of
// the current test. JSUnit exposes hooks into the test's status through
// the "G_testRunner" global object.
browser.executeScript(function() {
if (window['G_testRunner'] &&
window['G_testRunner']['isFinished']()) {
var status = {};
status['isFinished'] = true;
status['isSuccess'] = window['G_testRunner']['isSuccess']();
status['report'] = window['G_testRunner']['getReport']();
return status;
} else {
return {'isFinished': false};
}
})
browser
.executeScript(function() {
if (window['G_testRunner'] &&
window['G_testRunner']['isFinished']()) {
var status = {};
status['isFinished'] = true;
status['isSuccess'] = window['G_testRunner']['isSuccess']();
status['report'] = window['G_testRunner']['getReport']();
return status;
} else {
return {'isFinished': false};
}
})
.then(
function(status) {
if (status && status.isFinished) {
Expand All @@ -84,7 +101,9 @@ describe('Run all Closure unit tests', function() {
}
}
},
function(err) { reject(err); });
function(err) {
reject(err);
});
};

return new Promise(function(resolve, reject) {
Expand All @@ -100,7 +119,9 @@ describe('Run all Closure unit tests', function() {
var runNextTest = function(testPath) {
return browser.navigate()
.to(TEST_SERVER + '/' + testPath)
.then(function() { return waitForTestSuiteCompletion(testPath); })
.then(function() {
return waitForTestSuiteCompletion(testPath);
})
.then(function(status) {
if (!status.isSuccess) {
failureReports.push(status.report);
Expand All @@ -113,7 +134,9 @@ describe('Run all Closure unit tests', function() {
// Chains the next test to the completion of the previous through its
// promise.
var chainNextTest = function(promise, test) {
return promise.then(function() { runNextTest(test); });
return promise.then(function() {
runNextTest(test);
});
};

var testPromise = null;
Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/check_code_format.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to determine if .js files in Pull Request are properly formatted.
# Exits with non 0 exit code if formatting is needed.

Expand Down
16 changes: 15 additions & 1 deletion scripts/ci/compile_closure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Compiles pertinent Closure library files.

# TODO(joeltine): Make strictMissingRequire an error when
Expand Down Expand Up @@ -31,4 +45,4 @@ java -Xmx1G -jar ../closure-compiler-1.0-SNAPSHOT.jar \
--js='!**generate_closure_unit_tests.js' \
--js='!./doc/**.js' \
--js='!**debug_loader_integration_tests/testdata/**' \
--js_output_file=$(mktemp);
--js_output_file="$(mktemp)"
3 changes: 3 additions & 0 deletions scripts/ci/dossier_readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- Documentation licensed under CC BY 4.0 -->
<!-- License available at https://creativecommons.org/licenses/by/4.0/ -->

# Closure Generated API Docs

This is the generated documentation for the Closure Library
Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/generate_latest_docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Rebuild gh-pages branch.

Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/ie_setup.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
:: Copyright 2018 The Closure Library Authors. All Rights Reserved.
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS-IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.

:: Disable "Stop running this script?" alert dialog.
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles" ^
/v "MaxScriptStatements" /t REG_DWORD /d 0xffffffff /f
Expand Down
24 changes: 19 additions & 5 deletions scripts/ci/install_closure_deps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to install all necessary dependencies for running Closure tests,
# linting, formatting and compiling.

Expand All @@ -23,15 +37,15 @@ fetch () {
curl -o - "$dir/" |
sed -n 's+.*<a href="\('"$dir/$name"'-[-.0-9]*\.jar\)".*+\1+p' |
head -n 1)
[ -n $url ]
[ -n "$url" ]
wget -O "$jar" "$url"
}

# Install clang-format.
wget --quiet $CLANG_URL
tar xf $CLANG_TAR
mv $CLANG_BUILD clang
rm -f $CLANG_TAR
wget --quiet "$CLANG_URL"
tar xf "$CLANG_TAR"
mv "$CLANG_BUILD" clang
rm -f "$CLANG_TAR"

# Install closure compiler and linter.
fetch closure-compiler
Expand Down
16 changes: 15 additions & 1 deletion scripts/ci/lint_pull_request.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to run the Compiler's Linter on only the modified or added files in the
# current branch. Should be run from the base git directory with the PR branch
# checked out.

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CHANGED_FILES=$(git diff --name-only --diff-filter=AM master..$CURRENT_BRANCH |
CHANGED_FILES=$(git diff --name-only --diff-filter=AM master.."$CURRENT_BRANCH" |
grep -E "\.js$" |
grep -v -E "test\.js$" |
grep -v -f scripts/ci/lint_ignore.txt)
Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/push_latest_docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Deploy the gh-pages branch, adapted from
# https://github.com/google/dagger/blob/master/util/generate-latest-docs.sh
Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
#
# Copyright 2018 The Closure Library Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -x

Expand Down
Loading

0 comments on commit b426509

Please sign in to comment.