@@ -22,105 +22,143 @@ function run(cmd, args, opts = {}) {
2222}
2323
2424describe ( 'end-to-end' , function ( ) {
25- this . timeout ( 5 * 60 * 1000 ) ;
25+ this . timeout ( 10 * 60 * 1000 ) ;
2626
27+ let oldEnv ;
2728 let rootDir = process . cwd ( ) ;
2829 let emberPath = path . join ( rootDir , 'node_modules' , '.bin' , 'ember' ) ;
30+ let { name : packageTmpDir } = tmp . dirSync ( ) ;
2931
3032 function ember ( ...args ) {
3133 return listenForPrompts ( run ( emberPath , args , {
3234 stdio : [ 'pipe' , 'pipe' , process . stderr ] ,
3335 } ) ) ;
3436 }
3537
36- before ( function ( ) {
37- this . timeout ( 10 * 60 * 1000 ) ;
38-
39- let { name : tmpDir } = tmp . dirSync ( ) ;
38+ before ( ( ) => {
39+ // If we're running via a yarn script like `yarn test`, then we'll have
40+ // a whole bunch of npm_* environment variables set by yarn that can mess
41+ // things up, so let's scrub them.
42+ oldEnv = Object . assign ( { } , process . env ) ;
43+ Object . keys ( process . env ) . forEach ( ( key ) => {
44+ if ( key . startsWith ( 'npm_' ) ) {
45+ delete process . env [ key ] ;
46+ }
47+ } ) ;
4048
41- return run ( 'yarn' , [ 'pack' , '--filename' , path . join ( tmpDir , 'ember-electron.tgz' ) ] ) . then ( ( ) => {
42- process . chdir ( tmpDir ) ;
49+ //
50+ // Pack up current ember-electron directory so it can be installed in new
51+ // ember projects.
52+ //
53+ return run ( 'yarn' , [ 'pack' , '--filename' , path . join ( packageTmpDir , 'ember-electron.tgz' ) ] ) . then ( ( ) => {
54+ process . chdir ( packageTmpDir ) ;
4355
44- // yarn won't install from a gzipped tarball, and try as I might I can't
45- // get node-tar or tar.gz to untar the tarballs created by yarn or npm
4656 return run ( 'tar' , [ '-xzf' , 'ember-electron.tgz' ] ) ;
4757 } ) . then ( ( ) => {
4858 // Prevent yarn caching from screwing us
4959 let packageJson = readJsonSync ( path . join ( 'package' , 'package.json' ) ) ;
50- packageJson . version = `packageJson.version-${ new Date ( ) . getTime ( ) } ` ;
60+ packageJson . version = `${ packageJson . version } -${ new Date ( ) . getTime ( ) } ` ;
5161 writeJsonSync ( path . join ( 'package' , 'package.json' ) , packageJson ) ;
52-
53- return ember ( 'new' , 'ee-test-app' , '--yarn' ) ;
54- } ) . then ( ( ) => {
55- process . chdir ( 'ee-test-app' ) ;
56-
57- return ember ( 'install' , `ember-electron@file:${ tmpDir } /package` ) ;
58- } ) . then ( ( ) => {
59- // yarn has some kind of bug that causes it to hoist the wrong version of
60- // npmlog during one of the operations performed by the ember-electron
61- // blueprint, which causes things to explode. Running yarn upgrade
62- // corrects the situation.
63- return run ( 'yarn' , [ 'upgrade' ] ) ;
6462 } ) ;
6563 } ) ;
6664
6765 after ( ( ) => {
68- process . chdir ( rootDir ) ;
66+ process . env = oldEnv ;
6967 } ) ;
7068
7169 afterEach ( ( ) => {
7270 removeSync ( 'electron-out' ) ;
7371 } ) ;
7472
75- it ( 'tests' , ( ) => {
76- return expect ( ember ( 'electron:test' ) ) . to . eventually . be . fulfilled ;
77- } ) ;
73+ describe ( 'with yarn' , function ( ) {
74+ before ( function ( ) {
75+ let { name : tmpDir } = tmp . dirSync ( ) ;
76+ process . chdir ( tmpDir ) ;
77+
78+ return ember ( 'new' , 'ee-test-app' , '--yarn' ) . then ( ( ) => {
79+ process . chdir ( 'ee-test-app' ) ;
7880
79- it ( 'builds' , ( ) => {
80- return ember ( 'electron:build' ) . then ( ( ) => {
81- expect ( existsSync ( path . join ( 'electron-out' , 'ember' ) ) ) . to . be . ok ;
81+ return ember ( 'install' , `ember-electron@${ path . join ( packageTmpDir , 'package' ) } ` ) ;
82+ } ) ;
8283 } ) ;
83- } ) ;
8484
85- it ( 'assembles' , ( ) => {
86- return ember ( 'electron:assemble' ) . then ( ( ) => {
87- expect ( existsSync ( path . join ( 'electron-out' , 'project' ) ) ) . to . be . ok ;
85+ after ( ( ) => {
86+ process . chdir ( rootDir ) ;
8887 } ) ;
88+
89+ runTests ( ) ;
8990 } ) ;
9091
91- it ( 'packages' , ( ) => {
92- return ember ( 'electron:package' ) . then ( ( ) => {
93- expect ( existsSync ( path . join ( 'electron-out' , `ee-test-app-${ process . platform } -${ process . arch } ` ) ) ) . to . be . ok ;
92+ describe ( 'with npm' , function ( ) {
93+ before ( function ( ) {
94+ let { name : tmpDir } = tmp . dirSync ( ) ;
95+ process . chdir ( tmpDir ) ;
96+
97+ return ember ( 'new' , 'ee-test-app' ) . then ( ( ) => {
98+ process . chdir ( 'ee-test-app' ) ;
99+
100+ return ember ( 'install' , `ember-electron@${ path . join ( packageTmpDir , 'package' ) } ` ) ;
101+ } ) ;
94102 } ) ;
95- } ) ;
96103
97- it ( 'makes' , ( ) => {
98- // Only build zip target so we don't fail from missing platform dependencies
99- // (e.g. rpmbuild)
100- return ember ( 'electron:make' , '--targets' , 'zip' ) . then ( ( ) => {
101- expect ( existsSync ( path . join ( 'electron-out' , 'make' ) ) ) . to . be . ok ;
104+ after ( ( ) => {
105+ process . chdir ( rootDir ) ;
102106 } ) ;
107+
108+ runTests ( ) ;
103109 } ) ;
104110
105- it ( 'extra checks pass' , ( ) => {
106- let fixturePath = path . resolve ( __dirname , '..' , 'fixtures' , 'ember-test' ) ;
107-
108- // Append our extra test content to the end of test-main.js
109- let testMainPath = path . join ( 'ember-electron' , 'test-main.js' ) ;
110- let extraContentPath = path . join ( fixturePath , 'test-main-extra.js' ) ;
111- let content = [
112- readFileSync ( testMainPath ) ,
113- readFileSync ( extraContentPath ) ,
114- ] . join ( '\n' ) ;
115- writeFileSync ( path . join ( 'ember-electron' , 'test-main.js' ) , content ) ;
116-
117- // Copy the lib and resources directories over
118- [ 'lib' , 'resources' ] . forEach ( ( dir ) => {
119- copySync ( path . join ( fixturePath , dir ) , path . join ( 'ember-electron' , dir ) ) ;
111+ function runTests ( ) {
112+ it ( 'tests' , ( ) => {
113+ return expect ( ember ( 'electron:test' ) ) . to . eventually . be . fulfilled ;
120114 } ) ;
121115
122- return expect ( ember ( 'electron:test' ) ) . to . eventually . be . fulfilled ;
123- } ) ;
116+ it ( 'builds' , ( ) => {
117+ return ember ( 'electron:build' ) . then ( ( ) => {
118+ expect ( existsSync ( path . join ( 'electron-out' , 'ember' ) ) ) . to . be . ok ;
119+ } ) ;
120+ } ) ;
121+
122+ it ( 'assembles' , ( ) => {
123+ return ember ( 'electron:assemble' ) . then ( ( ) => {
124+ expect ( existsSync ( path . join ( 'electron-out' , 'project' ) ) ) . to . be . ok ;
125+ } ) ;
126+ } ) ;
127+
128+ it ( 'packages' , ( ) => {
129+ return ember ( 'electron:package' ) . then ( ( ) => {
130+ expect ( existsSync ( path . join ( 'electron-out' , `ee-test-app-${ process . platform } -${ process . arch } ` ) ) ) . to . be . ok ;
131+ } ) ;
132+ } ) ;
133+
134+ it ( 'makes' , ( ) => {
135+ // Only build zip target so we don't fail from missing platform dependencies
136+ // (e.g. rpmbuild)
137+ return ember ( 'electron:make' , '--targets' , 'zip' ) . then ( ( ) => {
138+ expect ( existsSync ( path . join ( 'electron-out' , 'make' ) ) ) . to . be . ok ;
139+ } ) ;
140+ } ) ;
141+
142+ it ( 'extra checks pass' , ( ) => {
143+ let fixturePath = path . resolve ( __dirname , '..' , 'fixtures' , 'ember-test' ) ;
144+
145+ // Append our extra test content to the end of test-main.js
146+ let testMainPath = path . join ( 'ember-electron' , 'test-main.js' ) ;
147+ let extraContentPath = path . join ( fixturePath , 'test-main-extra.js' ) ;
148+ let content = [
149+ readFileSync ( testMainPath ) ,
150+ readFileSync ( extraContentPath ) ,
151+ ] . join ( '\n' ) ;
152+ writeFileSync ( path . join ( 'ember-electron' , 'test-main.js' ) , content ) ;
153+
154+ // Copy the lib and resources directories over
155+ [ 'lib' , 'resources' ] . forEach ( ( dir ) => {
156+ copySync ( path . join ( fixturePath , dir ) , path . join ( 'ember-electron' , dir ) ) ;
157+ } ) ;
158+
159+ return expect ( ember ( 'electron:test' ) ) . to . eventually . be . fulfilled ;
160+ } ) ;
161+ }
124162} ) ;
125163
126164function listenForPrompts ( child ) {
0 commit comments