diff --git a/packages/babel-cli/test/fixtures/babel/stdin --filename/stderr.txt b/packages/babel-cli/test/fixtures/babel/stdin --filename/stderr.txt index 50db27b07b..460f1fc729 100644 --- a/packages/babel-cli/test/fixtures/babel/stdin --filename/stderr.txt +++ b/packages/babel-cli/test/fixtures/babel/stdin --filename/stderr.txt @@ -1 +1 @@ -SyntaxError: test.js: Unexpected token, expected ";" (2:10) +SyntaxError: /test.js: Unexpected token, expected ";" (2:10) diff --git a/packages/babel-cli/test/index.js b/packages/babel-cli/test/index.js index c55c509dde..6879543519 100644 --- a/packages/babel-cli/test/index.js +++ b/packages/babel-cli/test/index.js @@ -46,7 +46,20 @@ const saveInFiles = function(files) { }); }; -const assertTest = function(stdout, stderr, opts) { +const replacePaths = function(str, cwd) { + let prev; + do { + prev = str; + str = str.replace(cwd, ""); + } while (str !== prev); + + return str; +}; + +const assertTest = function(stdout, stderr, opts, cwd) { + stdout = replacePaths(stdout, cwd); + stderr = replacePaths(stderr, cwd); + const expectStderr = opts.stderr.trim(); stderr = stderr.trim(); @@ -138,7 +151,7 @@ const buildTest = function(binName, testName, opts) { let err; try { - assertTest(stdout, stderr, opts); + assertTest(stdout, stderr, opts, tmpLoc); } catch (e) { err = e; } diff --git a/packages/babel-core/src/config/partial.js b/packages/babel-core/src/config/partial.js index 0aae841ffd..206f7c35de 100644 --- a/packages/babel-core/src/config/partial.js +++ b/packages/babel-core/src/config/partial.js @@ -60,9 +60,7 @@ export default function loadPrivatePartialConfig( options.cwd = context.cwd; options.root = context.root; options.filename = - typeof context.filename === "string" - ? path.relative(context.cwd, context.filename) - : undefined; + typeof context.filename === "string" ? context.filename : undefined; options.plugins = configChain.plugins.map(descriptor => createItemFromDescriptor(descriptor), diff --git a/packages/babel-core/test/config-chain.js b/packages/babel-core/test/config-chain.js index 2d4fcedfd2..dea23e0db2 100644 --- a/packages/babel-core/test/config-chain.js +++ b/packages/babel-core/test/config-chain.js @@ -936,7 +936,7 @@ describe("buildConfigChain", function() { }), ).toEqual({ ...getDefaults(), - filename: path.basename(filename), + filename: filename, cwd: path.dirname(filename), root: path.dirname(filename), comments: true, @@ -948,7 +948,7 @@ describe("buildConfigChain", function() { expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ ...getDefaults(), - filename: path.basename(filename), + filename: filename, cwd: path.dirname(filename), root: path.dirname(filename), comments: true, @@ -960,7 +960,7 @@ describe("buildConfigChain", function() { expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ ...getDefaults(), - filename: path.basename(filename), + filename: filename, cwd: path.dirname(filename), root: path.dirname(filename), comments: true, @@ -1002,7 +1002,7 @@ describe("buildConfigChain", function() { expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ ...getDefaults(), - filename: path.basename(filename), + filename: filename, cwd: path.dirname(filename), root: path.dirname(filename), comments: true, diff --git a/packages/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/basic-sample/exec.js b/packages/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/basic-sample/exec.js index 397fa2915c..e44c3e5e7e 100644 --- a/packages/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/basic-sample/exec.js +++ b/packages/babel-plugin-transform-react-jsx-source/test/fixtures/react-source/basic-sample/exec.js @@ -1,10 +1,10 @@ var actual = transform( 'var x = ', - Object.assign({}, opts, { filename: 'fake/path/mock.js' }) + Object.assign({}, opts, { filename: '/fake/path/mock.js' }) ).code; var expected = multiline([ - 'var _jsxFileName = "fake/path/mock.js";', + 'var _jsxFileName = "/fake/path/mock.js";', 'var x = { let err; try { + stdout = replacePaths(stdout); + stderr = replacePaths(stderr); + assertTest(stdout, stderr, opts); } catch (e) { err = e; @@ -76,6 +79,16 @@ const buildTest = opts => { }; }; +function replacePaths(str) { + let prev; + do { + prev = str; + str = str.replace(tmpLoc, ""); + } while (str !== prev); + + return str; +} + describe("debug output", () => { let cwd; diff --git a/packages/babel-preset-env/test/debug-fixtures/android/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/android/stdout.txt index 4ba2f99c58..232c9b7132 100644 --- a/packages/babel-preset-env/test/debug-fixtures/android/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/android/stdout.txt @@ -37,7 +37,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within { "android":"4" } es6.array.fill { "android":"4" } es6.array.find { "android":"4" } @@ -147,4 +147,4 @@ Using polyfills with `entry` option: web.timers { "android":"4" } web.immediate { "android":"4" } web.dom.iterable { "android":"4" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/builtins-no-import/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/builtins-no-import/stdout.txt index 226b17a95e..4b2d33e5c0 100644 --- a/packages/babel-preset-env/test/debug-fixtures/builtins-no-import/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/builtins-no-import/stdout.txt @@ -20,5 +20,5 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] `import '@babel/polyfill'` was not found. -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +[/src/in.js] `import '@babel/polyfill'` was not found. +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/builtins-uglify/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/builtins-uglify/stdout.txt index ba44ac0289..8cfc85dcbb 100644 --- a/packages/babel-preset-env/test/debug-fixtures/builtins-uglify/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/builtins-uglify/stdout.txt @@ -40,7 +40,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.sort { "chrome":"55" } es7.object.define-getter { "chrome":"55" } es7.object.define-setter { "chrome":"55" } @@ -53,4 +53,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"55" } web.immediate { "chrome":"55" } web.dom.iterable { "chrome":"55" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/builtins/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/builtins/stdout.txt index 3414f883c1..0bd6ac82db 100644 --- a/packages/babel-preset-env/test/debug-fixtures/builtins/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/builtins/stdout.txt @@ -39,7 +39,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within { "ie":"10" } es6.array.fill { "ie":"10" } es6.array.find { "ie":"10" } @@ -163,4 +163,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"54", "ie":"10", "node":"6" } web.immediate { "chrome":"54", "ie":"10", "node":"6" } web.dom.iterable { "chrome":"54", "ie":"10", "node":"6" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/electron/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/electron/stdout.txt index 84c274f7a3..11dbe22f3f 100644 --- a/packages/babel-preset-env/test/debug-fixtures/electron/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/electron/stdout.txt @@ -32,7 +32,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.every { "electron":"0.36" } es6.array.filter { "electron":"0.36" } es6.array.for-each { "electron":"0.36" } @@ -123,4 +123,4 @@ Using polyfills with `entry` option: web.timers { "electron":"0.36" } web.immediate { "electron":"0.36" } web.dom.iterable { "electron":"0.36" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/force-all-transforms/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/force-all-transforms/stdout.txt index c34f9554cd..3f0b73d412 100644 --- a/packages/babel-preset-env/test/debug-fixtures/force-all-transforms/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/force-all-transforms/stdout.txt @@ -37,7 +37,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.sort { "chrome":"55" } es7.object.define-getter { "chrome":"55" } es7.object.define-setter { "chrome":"55" } @@ -50,4 +50,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"55" } web.immediate { "chrome":"55" } web.dom.iterable { "chrome":"55" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/plugins-only/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/plugins-only/stdout.txt index 6dd5e4310b..5e322962df 100644 --- a/packages/babel-preset-env/test/debug-fixtures/plugins-only/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/plugins-only/stdout.txt @@ -26,4 +26,4 @@ Using plugins: transform-dotall-regex { "firefox":"52", "node":"7.4" } Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set. -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/shippedProposals-chrome60/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/shippedProposals-chrome60/stdout.txt index c9e83aecb1..01161ad6a2 100644 --- a/packages/babel-preset-env/test/debug-fixtures/shippedProposals-chrome60/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/shippedProposals-chrome60/stdout.txt @@ -16,7 +16,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.sort { "chrome":"60" } es7.object.define-getter { "chrome":"60" } es7.object.define-setter { "chrome":"60" } @@ -27,4 +27,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"60" } web.immediate { "chrome":"60" } web.dom.iterable { "chrome":"60" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/shippedProposals/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/shippedProposals/stdout.txt index e003887904..7569cbf9a1 100644 --- a/packages/babel-preset-env/test/debug-fixtures/shippedProposals/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/shippedProposals/stdout.txt @@ -36,7 +36,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within {} es6.array.every {} es6.array.fill {} @@ -181,4 +181,4 @@ Using polyfills with `entry` option: web.timers {} web.immediate {} web.dom.iterable {} -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt index 11602a00f0..6e8ed3b297 100644 --- a/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt @@ -42,7 +42,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within { "ie":"10", "safari":"7" } es6.array.fill { "ie":"10", "safari":"7" } es6.array.find { "ie":"10", "safari":"7" } @@ -167,4 +167,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.immediate { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } web.dom.iterable { "chrome":"54", "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/usage-none/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/usage-none/stdout.txt index f75a642eec..c2a22a26fb 100644 --- a/packages/babel-preset-env/test/debug-fixtures/usage-none/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/usage-none/stdout.txt @@ -38,7 +38,7 @@ Using plugins: Using polyfills with `usage` option: -[src/in.js] Based on your code and targets, none were added. +[/src/in.js] Based on your code and targets, none were added. -[src/in2.js] Based on your code and targets, none were added. -🎉 Successfully compiled 2 files with Babel. \ No newline at end of file +[/src/in2.js] Based on your code and targets, none were added. +🎉 Successfully compiled 2 files with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/usage-with-import/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/usage-with-import/stdout.txt index 9dac50af49..80bd5bcd02 100644 --- a/packages/babel-preset-env/test/debug-fixtures/usage-with-import/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/usage-with-import/stdout.txt @@ -15,5 +15,5 @@ Using plugins: Using polyfills with `usage` option: -[src/in.js] Based on your code and targets, none were added. -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +[/src/in.js] Based on your code and targets, none were added. +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/usage/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/usage/stdout.txt index 90727db353..1326a99fe5 100644 --- a/packages/babel-preset-env/test/debug-fixtures/usage/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/usage/stdout.txt @@ -38,13 +38,13 @@ Using plugins: Using polyfills with `usage` option: -[src/in.js] Added following polyfills: +[/src/in.js] Added following polyfills: es6.promise { "ie":"11" } es6.map { "firefox":"50", "ie":"11" } es6.array.iterator { "ie":"11" } web.dom.iterable { "chrome":"52", "firefox":"50", "ie":"11" } -[src/in2.js] Added following polyfills: +[/src/in2.js] Added following polyfills: regenerator-runtime { "chrome":"52", "firefox":"50", "ie":"11" } web.dom.iterable { "chrome":"52", "firefox":"50", "ie":"11" } -🎉 Successfully compiled 2 files with Babel. \ No newline at end of file +🎉 Successfully compiled 2 files with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/versions-decimals/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/versions-decimals/stdout.txt index 976f0d5000..f6d009a1aa 100644 --- a/packages/babel-preset-env/test/debug-fixtures/versions-decimals/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/versions-decimals/stdout.txt @@ -48,7 +48,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within { "ie":"10" } es6.array.every { "electron":"0.36" } es6.array.fill { "ie":"10" } @@ -193,4 +193,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } web.immediate { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } web.dom.iterable { "chrome":"54", "electron":"0.36", "ie":"10", "node":"6.1" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-env/test/debug-fixtures/versions-strings/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/versions-strings/stdout.txt index 86698e5049..0c183e66ff 100644 --- a/packages/babel-preset-env/test/debug-fixtures/versions-strings/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/versions-strings/stdout.txt @@ -39,7 +39,7 @@ Using plugins: Using polyfills with `entry` option: -[src/in.js] Replaced `@babel/polyfill` with the following polyfills: +[/src/in.js] Replaced `@babel/polyfill` with the following polyfills: es6.array.copy-within { "ie":"10" } es6.array.fill { "ie":"10" } es6.array.find { "ie":"10" } @@ -163,4 +163,4 @@ Using polyfills with `entry` option: web.timers { "chrome":"54", "ie":"10", "node":"6.10" } web.immediate { "chrome":"54", "ie":"10", "node":"6.10" } web.dom.iterable { "chrome":"54", "ie":"10", "node":"6.10" } -🎉 Successfully compiled 1 file with Babel. \ No newline at end of file +🎉 Successfully compiled 1 file with Babel. diff --git a/packages/babel-preset-react/test/fixtures/preset-options/development/exec.js b/packages/babel-preset-react/test/fixtures/preset-options/development/exec.js index 68a2881b4b..5ceb5a4a01 100644 --- a/packages/babel-preset-react/test/fixtures/preset-options/development/exec.js +++ b/packages/babel-preset-react/test/fixtures/preset-options/development/exec.js @@ -1,10 +1,10 @@ const actual = transform( '', - Object.assign({}, opts, { filename: 'fake/path/mock.js' }) + Object.assign({}, opts, { filename: '/fake/path/mock.js' }) ).code; const expected = multiline([ - 'var _jsxFileName = "fake/path/mock.js";', + 'var _jsxFileName = "/fake/path/mock.js";', 'React.createElement(Foo, {', ' bar: "baz",', ' __source: {',