-
Notifications
You must be signed in to change notification settings - Fork 92
Windows fixes #158
Windows fixes #158
Changes from 3 commits
5406923
5b3b510
aaa5eae
2e09a94
66f3a35
dcb1a81
eaf8483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,69 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
MANIFEST="$TEST_SRCDIR/MANIFEST" | ||
if [ -e "$MANIFEST" ]; then | ||
while read line; do | ||
declare -a PARTS=($line) | ||
if [ "${PARTS[0]}" == "build_bazel_rules_typescript/examples/some_library/library.js" ]; then | ||
readonly LIBRARY_JS=$(cat ${PARTS[1]}) | ||
elif [ "${PARTS[0]}" == "build_bazel_rules_typescript/examples/bar.js" ]; then | ||
readonly BAR_JS=$(cat ${PARTS[1]}) | ||
elif [ "${PARTS[0]}" == "build_bazel_rules_typescript/examples/foo.js" ]; then | ||
readonly FOO_JS=$(cat ${PARTS[1]}) | ||
fi | ||
done < $MANIFEST | ||
else | ||
readonly LIBRARY_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/some_library/library.js) | ||
readonly BAR_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/bar.js) | ||
readonly FOO_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/foo.js) | ||
fi | ||
|
||
# should produce named UMD modules | ||
readonly LIBRARY_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/some_library/library.js) | ||
if [[ "$LIBRARY_JS" != *"define(\"build_bazel_rules_typescript/examples/some_library/library\""* ]]; then | ||
echo "Expected library.js to declare named module, but was" | ||
echo "$A_JS" | ||
echo "$LIBRARY_JS" | ||
exit 1 | ||
fi | ||
|
||
# should produce named UMD modules | ||
if [[ "$BAR_JS" != *"define(\"build_bazel_rules_typescript/examples/bar\""* ]]; then | ||
echo "Expected bar.js to declare named module, but was" | ||
echo "$BAR_JS" | ||
exit 1 | ||
fi | ||
|
||
# should give a name to required modules | ||
readonly BAR_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/bar.js) | ||
if [[ "$BAR_JS" != *"require(\"build_bazel_rules_typescript/examples/foo\")"* ]]; then | ||
echo "Expected bar.js to require named module foo, but was" | ||
echo "$BAR_JS" | ||
exit 1 | ||
fi | ||
|
||
# should give a name to required modules from other compilation unit | ||
readonly FOO_JS=$(cat $TEST_SRCDIR/build_bazel_rules_typescript/examples/bar.js) | ||
if [[ "$FOO_JS" != *"require(\"build_bazel_rules_typescript/examples/some_library/library\")"* ]]; then | ||
if [[ "$BAR_JS" != *"require(\"build_bazel_rules_typescript/examples/some_library/library\")"* ]]; then | ||
echo "Expected bar.js to require named module library, but was" | ||
echo "$FOO_JS" | ||
echo "$BAR_JS" | ||
exit 1 | ||
fi | ||
|
||
# should give a name to required generated modules without bazel-bin | ||
if [[ "$FOO_JS" != *"require(\"build_bazel_rules_typescript/examples/generated_ts/foo\")"* ]]; then | ||
echo "Expected foo.js to require generated named module foo, but was" | ||
echo "$FOO_JS" | ||
if [[ "$BAR_JS" != *"require(\"build_bazel_rules_typescript/examples/generated_ts/foo\")"* ]]; then | ||
echo "Expected bar.js to require generated named module foo, but was" | ||
echo "$BAR_JS" | ||
exit 1 | ||
fi | ||
|
||
# should not give a module name to external modules | ||
if [[ "$FOO_JS" != *"require(\"typescript\")"* ]]; then | ||
echo "Expected foo.js to require typescript by its original name, but was" | ||
if [[ "$BAR_JS" != *"require(\"typescript\")"* ]]; then | ||
echo "Expected bar.js to require typescript by its original name, but was" | ||
echo "$BAR_JS" | ||
exit 1 | ||
fi | ||
|
||
# should produce named UMD modules | ||
if [[ "$FOO_JS" != *"define(\"build_bazel_rules_typescript/examples/foo\""* ]]; then | ||
echo "Expected foo.js to declare named module, but was" | ||
echo "$FOO_JS" | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,59 @@ | ||
// Karma configuration | ||
// GENERATED BY Bazel | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const tmp = require('tmp'); | ||
|
||
process.env.CHROME_BIN = require('puppeteer').executablePath(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in theory the just to keep in mind, that anything hard-coded will need to be revisited There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a comment to that line explaining it a bit. Karma will just look for CHROME_BIN in the environment if it is configured to use Chrome. If another browser is selected then that value is not used. |
||
|
||
let files = [ | ||
TMPL_files | ||
]; | ||
|
||
const manifestFile = path.join(process.env.TEST_SRCDIR, "MANIFEST"); | ||
if (fs.existsSync(manifestFile)) { | ||
const manifest = {}; | ||
fs.readFileSync(manifestFile, { encoding: 'utf8' }) | ||
.split('\n') | ||
.forEach((l) => { | ||
const m = l.split(' '); | ||
manifest[m[0]] = m[1]; | ||
}); | ||
const manifestKeys = Object.keys(manifest); | ||
files = files.map((f) => { | ||
if (manifestKeys.includes(f)) { | ||
return manifest[f]; | ||
} else { | ||
throw new Error(`File not found in MANIFEST: ${f}`); | ||
} | ||
}); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to support a case where there is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as comment below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add a comment here that explains this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaned up. No MANIFEST case is not needed. |
||
files = files.map((f) => f.replace('build_bazel_rules_typescript/external/', '')); | ||
} | ||
|
||
let requireFiles = [ | ||
TMPL_files | ||
].map((f) => f.replace('build_bazel_rules_typescript/external/', '')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is rules_typescript special here? Could there be other external repos in the files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is to handle the two files from
I think its correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. I took a closer look at the MANIFEST file. I think this code can be improved to get rid the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleaned this up. No |
||
|
||
var requireConfigContent = ` | ||
// A simplified version of Karma's requirejs.config.tpl.js for use with Karma under Bazel | ||
(function(){ | ||
var allFiles = ` + JSON.stringify(requireFiles) + `; | ||
var allTestFiles = []; | ||
allFiles.forEach(function (file) { | ||
if (/(spec|test)\\.js$/i.test(file)) { | ||
allTestFiles.push(file.replace(/\\.js$/, '')) | ||
} | ||
}); | ||
require(allTestFiles, window.__karma__.start); | ||
})(); | ||
`; | ||
|
||
const requireConfigFile = tmp.fileSync({keep: false, postfix: '.js', dir: process.env['TEST_TMPDIR']}); | ||
console.log('Writing require config file to ', requireConfigFile.name); | ||
fs.writeFileSync(requireConfigFile.name, requireConfigContent); | ||
files.push(requireConfigFile.name); | ||
|
||
module.exports = function(config) { | ||
if (process.env['IBAZEL_NOTIFY_CHANGES'] === 'y') { | ||
// Tell karma to only listen for ibazel messages on stdin rather than watch all the input files | ||
|
@@ -49,8 +103,8 @@ module.exports = function(config) { | |
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: 'TMPL_runfiles_path', | ||
files: [ | ||
TMPL_files | ||
] | ||
|
||
// files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stray comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah. a bit redundant. there was a comment before every other property and I didn't know what else to put. |
||
files: files, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think you need this anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean switch to git_repository from the skylark rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, this is just a fast-forward of master