Browse Source

Fix tests in windows

gh-109
Luke Page 9 years ago
parent
commit
30ecd4373a
  1. 2
      src/utils/resolveId.js
  2. 4
      test/cli/external-modules/main.js
  3. 6
      test/function/allows-external-modules-from-nested-module/main.js
  4. 2
      test/function/custom-path-resolver-async/_config.js
  5. 2
      test/function/custom-path-resolver-sync/_config.js
  6. 2
      test/function/duplicate-import-fails/_config.js
  7. 2
      test/function/duplicate-import-specifier-fails/_config.js
  8. 2
      test/function/export-not-at-top-level-fails/_config.js
  9. 2
      test/function/import-default-from-external/main.js
  10. 4
      test/function/import-named-from-external/main.js
  11. 2
      test/function/import-namespace-from-external-module-renamed/main.js
  12. 2
      test/function/import-namespace-from-external-module/main.js
  13. 2
      test/function/import-not-at-top-level-fails/_config.js
  14. 3
      test/function/imports-are-deconflicted-b/main.js
  15. 3
      test/function/imports-are-deconflicted/main.js
  16. 2
      test/function/namespace-reassign-import-fails/_config.js
  17. 2
      test/function/namespace-update-import-fails/_config.js
  18. 2
      test/function/reassign-import-fails/_config.js
  19. 2
      test/function/reassign-import-not-at-top-level-fails/_config.js
  20. 4
      test/function/shadowed-external-export/main.js
  21. 2
      test/function/update-expression-of-import-fails/_config.js
  22. 7
      test/test.js

2
src/utils/resolveId.js

@ -24,7 +24,7 @@ export function defaultExternalResolver ( id, importer ) {
const root = absolutePath.exec( importer )[0]; const root = absolutePath.exec( importer )[0];
let dir = dirname( importer ); let dir = dirname( importer );
while ( dir !== root ) { while ( dir !== root && dir !== "." ) {
const pkgPath = resolve( dir, 'node_modules', id, 'package.json' ); const pkgPath = resolve( dir, 'node_modules', id, 'package.json' );
let pkgJson; let pkgJson;

4
test/cli/external-modules/main.js

@ -1,5 +1,5 @@
import { relative } from 'path'; import { relative, normalize } from 'path';
import { format } from 'util'; import { format } from 'util';
assert.equal( format( 'it %s', 'works' ), 'it works' ); assert.equal( format( 'it %s', 'works' ), 'it works' );
assert.equal( relative( 'a/b/c', 'a/c/b' ), '../../c/b' ); assert.equal( relative( 'a/b/c', 'a/c/b' ), normalize('../../c/b') );

6
test/function/allows-external-modules-from-nested-module/main.js

@ -1,8 +1,8 @@
import { relative } from 'path'; import { relative, normalize } from 'path';
import foo from './foo'; import foo from './foo';
var path = 'foo/bar/baz'; var path = 'foo/bar/baz';
var path2 = 'foo/baz/bar'; var path2 = 'foo/baz/bar';
assert.equal( relative( path, path2 ), '../../baz/bar' ); assert.equal( relative( path, path2 ), normalize('../../baz/bar') );
assert.equal( foo, '../../c/b' ); assert.equal( foo, normalize('../../c/b') );

2
test/function/custom-path-resolver-async/_config.js

@ -8,7 +8,7 @@ module.exports = {
var Promise = require( 'sander' ).Promise; var Promise = require( 'sander' ).Promise;
var resolved; var resolved;
if ( importee === path.resolve( __dirname, 'main.js' ) ) return importee; if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee;
if ( importee === 'foo' ) { if ( importee === 'foo' ) {
resolved = path.resolve( __dirname, 'bar.js' ); resolved = path.resolve( __dirname, 'bar.js' );

2
test/function/custom-path-resolver-sync/_config.js

@ -5,7 +5,7 @@ module.exports = {
description: 'uses a custom path resolver (synchronous)', description: 'uses a custom path resolver (synchronous)',
options: { options: {
resolveId: function ( importee, importer ) { resolveId: function ( importee, importer ) {
if ( importee === path.resolve( __dirname, 'main.js' ) ) return importee; if ( path.normalize(importee) === path.resolve( __dirname, 'main.js' ) ) return importee;
if ( importee === 'foo' ) return path.resolve( __dirname, 'bar.js' ); if ( importee === 'foo' ) return path.resolve( __dirname, 'bar.js' );
return false; return false;

2
test/function/duplicate-import-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows duplicate imports', description: 'disallows duplicate imports',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 2, column: 9 }); assert.deepEqual( err.loc, { line: 2, column: 9 });
assert.ok( /Duplicated import/.test( err.message ) ); assert.ok( /Duplicated import/.test( err.message ) );
} }

2
test/function/duplicate-import-specifier-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows duplicate import specifiers', description: 'disallows duplicate import specifiers',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 1, column: 12 }); assert.deepEqual( err.loc, { line: 1, column: 12 });
assert.ok( /Duplicated import/.test( err.message ) ); assert.ok( /Duplicated import/.test( err.message ) );
} }

2
test/function/export-not-at-top-level-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows non-top-level exports', description: 'disallows non-top-level exports',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 2, column: 2 }); assert.deepEqual( err.loc, { line: 2, column: 2 });
assert.ok( /may only appear at the top level/.test( err.message ) ); assert.ok( /may only appear at the top level/.test( err.message ) );
} }

2
test/function/import-default-from-external/main.js

@ -4,4 +4,4 @@ import path from 'path';
var path1 = 'foo/bar/baz'; var path1 = 'foo/bar/baz';
var path2 = 'foo/baz/bar'; var path2 = 'foo/baz/bar';
assert.equal( path.relative( path1, path2 ), '../../baz/bar' ); assert.equal( path.relative( path1, path2 ), path.normalize('../../baz/bar') );

4
test/function/import-named-from-external/main.js

@ -1,6 +1,6 @@
import { relative } from 'path'; import { relative, normalize } from 'path';
var path = 'foo/bar/baz'; var path = 'foo/bar/baz';
var path2 = 'foo/baz/bar'; var path2 = 'foo/baz/bar';
assert.equal( relative( path, path2 ), '../../baz/bar' ); assert.equal( relative( path, path2 ), normalize('../../baz/bar') );

2
test/function/import-namespace-from-external-module-renamed/main.js

@ -3,4 +3,4 @@ import * as node_path from 'path';
var path1 = 'foo/bar/baz'; var path1 = 'foo/bar/baz';
var path2 = 'foo/baz/bar'; var path2 = 'foo/baz/bar';
assert.equal( node_path.relative( path1, path2 ), '../../baz/bar' ); assert.equal( node_path.relative( path1, path2 ), node_path.normalize('../../baz/bar') );

2
test/function/import-namespace-from-external-module/main.js

@ -3,4 +3,4 @@ import * as path from 'path';
var path1 = 'foo/bar/baz'; var path1 = 'foo/bar/baz';
var path2 = 'foo/baz/bar'; var path2 = 'foo/baz/bar';
assert.equal( path.relative( path1, path2 ), '../../baz/bar' ); assert.equal( path.relative( path1, path2 ), path.normalize('../../baz/bar') );

2
test/function/import-not-at-top-level-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows non-top-level imports', description: 'disallows non-top-level imports',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 2, column: 2 }); assert.deepEqual( err.loc, { line: 2, column: 2 });
assert.ok( /may only appear at the top level/.test( err.message ) ); assert.ok( /may only appear at the top level/.test( err.message ) );
} }

3
test/function/imports-are-deconflicted-b/main.js

@ -1,5 +1,6 @@
import foo from './foo'; import foo from './foo';
import bar from './bar'; import bar from './bar';
import { normalize } from 'path';
assert.equal( foo, 'foo' ); assert.equal( foo, 'foo' );
assert.equal( bar(), '../../baz/bar' ); assert.equal( bar(), normalize('../../baz/bar') );

3
test/function/imports-are-deconflicted/main.js

@ -1,5 +1,6 @@
import foo from './foo'; import foo from './foo';
import bar from './bar'; import bar from './bar';
import { normalize } from 'path';
assert.equal( foo, 'foo' ); assert.equal( foo, 'foo' );
assert.equal( bar(), '../../baz/bar' ); assert.equal( bar(), normalize('../../baz/bar') );

2
test/function/namespace-reassign-import-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows reassignments to namespace exports', description: 'disallows reassignments to namespace exports',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 3, column: 0 }); assert.deepEqual( err.loc, { line: 3, column: 0 });
assert.ok( /Illegal reassignment/.test( err.message ) ); assert.ok( /Illegal reassignment/.test( err.message ) );
} }

2
test/function/namespace-update-import-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows updates to namespace exports', description: 'disallows updates to namespace exports',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 3, column: 0 }); assert.deepEqual( err.loc, { line: 3, column: 0 });
assert.ok( /Illegal reassignment/.test( err.message ) ); assert.ok( /Illegal reassignment/.test( err.message ) );
} }

2
test/function/reassign-import-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows assignments to imported bindings', description: 'disallows assignments to imported bindings',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 8, column: 0 }); assert.deepEqual( err.loc, { line: 8, column: 0 });
assert.ok( /Illegal reassignment/.test( err.message ) ); assert.ok( /Illegal reassignment/.test( err.message ) );
} }

2
test/function/reassign-import-not-at-top-level-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows assignments to imported bindings not at the top level', description: 'disallows assignments to imported bindings not at the top level',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 7, column: 2 }); assert.deepEqual( err.loc, { line: 7, column: 2 });
assert.ok( /Illegal reassignment/.test( err.message ) ); assert.ok( /Illegal reassignment/.test( err.message ) );
} }

4
test/function/shadowed-external-export/main.js

@ -1,4 +1,4 @@
import { relative } from 'path'; import { relative, normalize } from 'path';
var paths = {}; var paths = {};
function getRelativePath ( path, path2 ) { function getRelativePath ( path, path2 ) {
@ -6,5 +6,5 @@ function getRelativePath ( path, path2 ) {
return relative( path, path2 ); return relative( path, path2 );
} }
assert.equal( getRelativePath( 'foo/bar/baz', 'foo/baz/bar' ), '../../baz/bar' ); assert.equal( getRelativePath( 'foo/bar/baz', 'foo/baz/bar' ), normalize('../../baz/bar') );
assert.deepEqual( paths, { 'foo/bar/baz': true }); assert.deepEqual( paths, { 'foo/bar/baz': true });

2
test/function/update-expression-of-import-fails/_config.js

@ -4,7 +4,7 @@ var assert = require( 'assert' );
module.exports = { module.exports = {
description: 'disallows updates to imported bindings', description: 'disallows updates to imported bindings',
error: function ( err ) { error: function ( err ) {
assert.equal( err.file, path.resolve( __dirname, 'main.js' ) ); assert.equal( path.normalize(err.file), path.resolve( __dirname, 'main.js' ) );
assert.deepEqual( err.loc, { line: 3, column: 0 }); assert.deepEqual( err.loc, { line: 3, column: 0 });
assert.ok( /Illegal reassignment/.test( err.message ) ); assert.ok( /Illegal reassignment/.test( err.message ) );
} }

7
test/test.js

@ -2,6 +2,7 @@ require( 'source-map-support' ).install();
require( 'console-group' ).install(); require( 'console-group' ).install();
var path = require( 'path' ); var path = require( 'path' );
var os = require( 'os' );
var sander = require( 'sander' ); var sander = require( 'sander' );
var assert = require( 'assert' ); var assert = require( 'assert' );
var exec = require( 'child_process' ).exec; var exec = require( 'child_process' ).exec;
@ -244,9 +245,13 @@ describe( 'rollup', function () {
( config.skip ? it.skip : config.solo ? it.only : it )( dir, function ( done ) { ( config.skip ? it.skip : config.solo ? it.only : it )( dir, function ( done ) {
process.chdir( path.resolve( CLI, dir ) ); process.chdir( path.resolve( CLI, dir ) );
if (os.platform() === 'win32') {
config.command = "node " + path.resolve( __dirname, '../bin' ) + path.sep + config.command;
}
exec( config.command, { exec( config.command, {
env: { env: {
PATH: path.resolve( __dirname, '../bin' ) + ':' + process.env.PATH PATH: path.resolve( __dirname, '../bin' ) + path.delimiter + process.env.PATH
} }
}, function ( err, code, stderr ) { }, function ( err, code, stderr ) {
if ( err ) return done( err ); if ( err ) return done( err );

Loading…
Cancel
Save