@@ -1747,39 +1747,65 @@ module.exports = class AtomApplication extends EventEmitter {
1747
1747
}
1748
1748
1749
1749
resolveTestRunnerPath ( testPath ) {
1750
- let packageRoot ;
1751
- if ( FindParentDir == null ) {
1752
- FindParentDir = require ( 'find-parent-dir' ) ;
1750
+ FindParentDir ||= require ( 'find-parent-dir' ) ;
1751
+
1752
+ let packageRoot = FindParentDir . sync ( testPath , 'package.json' ) ;
1753
+
1754
+ if ( ! packageRoot ) {
1755
+ process . stderr . write ( 'Error: Could not find root directory' ) ;
1756
+ process . exit ( 1 ) ;
1753
1757
}
1754
1758
1755
- if ( ( packageRoot = FindParentDir . sync ( testPath , 'package.json' ) ) ) {
1756
- const packageMetadata = require ( path . join ( packageRoot , 'package.json' ) ) ;
1757
- if ( packageMetadata . atomTestRunner ) {
1758
- let testRunnerPath ;
1759
- if ( Resolve == null ) {
1760
- Resolve = require ( 'resolve' ) ;
1761
- }
1762
- if (
1763
- ( testRunnerPath = Resolve . sync ( packageMetadata . atomTestRunner , {
1764
- basedir : packageRoot ,
1765
- extensions : Object . keys ( require . extensions )
1766
- } ) )
1767
- ) {
1768
- return testRunnerPath ;
1769
- } else {
1770
- process . stderr . write (
1771
- `Error: Could not resolve test runner path '${
1772
- packageMetadata . atomTestRunner
1773
- } '`
1774
- ) ;
1775
- process . exit ( 1 ) ;
1776
- }
1759
+ const packageMetadata = require ( path . join ( packageRoot , 'package.json' ) ) ;
1760
+ let atomTestRunner = packageMetadata . atomTestRunner ;
1761
+
1762
+ if ( ! atomTestRunner ) {
1763
+ process . stdout . write ( 'atomTestRunner was not defined, using the deprecated runners/jasmine1-test-runner.' ) ;
1764
+ atomTestRunner = 'runners/jasmine1-test-runner' ;
1765
+ }
1766
+
1767
+ let testRunnerPath ;
1768
+ Resolve ||= require ( 'resolve' ) ;
1769
+
1770
+ // First try to run with local runners (e.g: `./test/runner.js`) or packages (e.g.: `atom-mocha-test-runner`)
1771
+ try {
1772
+ testRunnerPath = Resolve . sync ( atomTestRunner , {
1773
+ basedir : packageRoot ,
1774
+ extensions : Object . keys ( require . extensions )
1775
+ } ) ;
1776
+
1777
+ if ( testRunnerPath ) {
1778
+ return testRunnerPath ;
1777
1779
}
1780
+ } catch {
1781
+ // Nothing to do, try the next strategy
1778
1782
}
1779
1783
1780
- return this . resolveLegacyTestRunnerPath ( ) ;
1784
+ // Then try to use one of the runners defined in Pulsar
1785
+ try {
1786
+ testRunnerPath = Resolve . sync ( `./spec/${ atomTestRunner } ` , {
1787
+ basedir : this . devResourcePath ,
1788
+ extensions : Object . keys ( require . extensions )
1789
+ } ) ;
1790
+
1791
+ if ( testRunnerPath ) {
1792
+ return testRunnerPath ;
1793
+ }
1794
+ } catch {
1795
+ // Nothing to do, try the next strategy
1796
+ }
1797
+
1798
+ // TODO: packages might require __dirname ?
1799
+
1800
+ process . stderr . write (
1801
+ `Error: Could not resolve test runner path '${
1802
+ packageMetadata . atomTestRunner
1803
+ } '`
1804
+ ) ;
1805
+ process . exit ( 1 ) ;
1781
1806
}
1782
1807
1808
+ // TODO: remove?
1783
1809
resolveLegacyTestRunnerPath ( ) {
1784
1810
try {
1785
1811
return require . resolve (
0 commit comments