makeTest.php

  1. 8.0.x tests/makeTest.php
  2. 6.x tests/makeTest.php
  3. 7.x tests/makeTest.php
  4. 5.x tests/makeTest.php
  5. master tests/makeTest.php

Namespace

Unish

Classes

Namesort descending Description
makeMakefileCase Make makefile tests. @group make @group slow

File

tests/makeTest.php
View source
  1. <?php
  2. namespace Unish;
  3. /**
  4. * Make makefile tests.
  5. * @group make
  6. * @group slow
  7. */
  8. class makeMakefileCase extends CommandUnishTestCase {
  9. /**
  10. * Path to test make files.
  11. */
  12. protected $makefile_path;
  13. /**
  14. * Initialize $makefile_path.
  15. */
  16. function __construct() {
  17. $this->makefile_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'makefiles';
  18. }
  19. /**
  20. * Run a given makefile test.
  21. *
  22. * @param $test
  23. * The test makefile to run, as defined by $this->getMakefile();
  24. */
  25. private function runMakefileTest($test) {
  26. $default_options = array(
  27. 'test' => NULL,
  28. 'md5' => 'print',
  29. );
  30. $config = $this->getMakefile($test);
  31. $options = array_merge($config['options'], $default_options);
  32. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  33. $return = !empty($config['fail']) ? self::EXIT_ERROR : self::EXIT_SUCCESS;
  34. $this->drush('make', array($makefile), $options, NULL, NULL, $return);
  35. // Check the log for the build hash if this test should pass.
  36. if (empty($config['fail'])) {
  37. $output = $this->getOutput();
  38. $this->assertContains($config['md5'], $output, $config['name'] . ' - build md5 matches expected value: ' . $config['md5']);
  39. }
  40. }
  41. function getMakefile($key) {
  42. static $tests;
  43. $tests = $this->listMakefileTests();
  44. return $tests[$key];
  45. }
  46. function listMakefileTests() {
  47. $tests = array(
  48. 'bzr' => array(
  49. 'name' => 'Bzr',
  50. 'makefile' => 'bzr.make',
  51. 'build' => TRUE,
  52. 'md5' => '272e2b9bb27794c54396f2f03c159725',
  53. 'options' => array(),
  54. ),
  55. 'bz2' => array(
  56. 'name' => 'bzip2',
  57. 'makefile' => 'bz2.make',
  58. 'build' => TRUE,
  59. 'md5' => '5ec081203131a1a3277c8b23f9ddb995',
  60. 'options' => array('no-core' => NULL),
  61. ),
  62. 'bz2-singlefile' => array(
  63. 'name' => 'bzip2 single file',
  64. 'makefile' => 'bz2-singlefile.make',
  65. 'build' => TRUE,
  66. 'md5' => '4f9d57f6caaf6ece0526d867327621cc',
  67. 'options' => array('no-core' => NULL),
  68. ),
  69. 'contrib-destination' => array(
  70. 'name' => 'Contrib-destination attribute',
  71. 'makefile' => 'contrib-destination.make',
  72. 'build' => TRUE,
  73. 'md5' => '2aed36201ede1849ce43d9b7d6f7e9e1',
  74. 'options' => array('no-core' => NULL, 'contrib-destination' => '.'),
  75. ),
  76. 'defaults' => array(
  77. 'name' => 'Test defaults array.',
  78. 'makefile' => 'defaults.make',
  79. 'build' => TRUE,
  80. 'md5' => 'e6c0d6b37cd8573cbd188742b95a274e',
  81. 'options' => array('no-core' => NULL, 'contrib-destination' => '.'),
  82. ),
  83. 'file' => array(
  84. 'name' => 'File extraction',
  85. 'makefile' => 'file.make',
  86. 'build' => TRUE,
  87. 'md5' => '4e9883d6f9f6572af287635689c2545d',
  88. 'options' => array('no-core' => NULL),
  89. ),
  90. 'file-extract' => array(
  91. 'name' => 'Extract archives',
  92. 'makefile' => 'file-extract.make',
  93. 'build' => TRUE,
  94. 'md5' => 'b43d271ab3510eb33c1e300c78893458',
  95. // @todo This test often fails with concurrency set to more than one.
  96. 'options' => array('no-core' => NULL, 'concurrency' => 1),
  97. ),
  98. 'get' => array(
  99. 'name' => 'Test GET retrieval of projects',
  100. 'makefile' => 'get.make',
  101. 'build' => TRUE,
  102. 'md5' => '4bf18507da89bed601548210c22a3bed',
  103. 'options' => array('no-core' => NULL),
  104. ),
  105. 'git' => array(
  106. 'name' => 'GIT integration',
  107. 'makefile' => 'git.make',
  108. 'build' => TRUE,
  109. 'md5' => '4c80d78b50c89b5ba11a997bafec2b43',
  110. 'options' => array('no-core' => NULL, 'no-gitinfofile' => NULL),
  111. ),
  112. 'git-simple' => array(
  113. 'name' => 'Simple git integration',
  114. 'makefile' => 'git-simple.make',
  115. 'build' => TRUE,
  116. 'md5' => '0147681209adef163a8ac2c0cff2a07e',
  117. 'options' => array('no-core' => NULL, 'no-gitinfofile' => NULL),
  118. ),
  119. 'git-simple-8' => array(
  120. 'name' => 'Simple git integration for D8',
  121. 'makefile' => 'git-simple-8.make',
  122. 'build' => TRUE,
  123. 'options' => array('no-core' => NULL),
  124. ),
  125. 'gzip' => array(
  126. 'name' => 'gzip',
  127. 'makefile' => 'gzip.make',
  128. 'build' => TRUE,
  129. 'md5' => '25b514df18a87b655437388af083e22c',
  130. 'options' => array('no-core' => NULL),
  131. ),
  132. 'ignore-checksums' => array(
  133. 'name' => 'Ignore invalid checksum/s',
  134. 'makefile' => 'md5-fail.make',
  135. 'build' => TRUE,
  136. 'md5' => 'f76ec174a775ce67f8e9edcb02336ef2',
  137. 'options' => array('no-core' => NULL, 'ignore-checksums' => NULL),
  138. ),
  139. 'include' => array(
  140. 'name' => 'Including files and property overrides',
  141. 'makefile' => 'include.make',
  142. 'build' => TRUE,
  143. 'md5' => 'e2e230ec5eccaf5618050559ab11510d',
  144. 'options' => array(),
  145. ),
  146. 'includes-git' => array(
  147. 'name' => 'Including makefiles from remote repositories',
  148. 'makefile' => 'includes-main.make',
  149. 'build' => TRUE,
  150. 'options' => array(),
  151. ),
  152. 'limit-libraries' => array(
  153. 'name' => 'Limit libraries downloaded',
  154. 'makefile' => 'limited-projects-libraries.make',
  155. 'build' => TRUE,
  156. 'md5' => 'cb0da4465d86eb34cafb167787862eb6',
  157. 'options' => array('no-core' => NULL, 'libraries' => 'drush_make'),
  158. ),
  159. 'limit-libraries-multiple' => array(
  160. 'name' => 'Limit multiple libraries downloaded',
  161. 'makefile' => 'limited-projects-libraries.make',
  162. 'build' => TRUE,
  163. 'md5' => '7c10e6fc65728a77a2b0aed4ec2a29cd',
  164. 'options' => array('no-core' => NULL, 'libraries' => 'drush_make,token'),
  165. ),
  166. 'limit-projects' => array(
  167. 'name' => 'Limit projects downloaded',
  168. 'makefile' => 'limited-projects-libraries.make',
  169. 'build' => TRUE,
  170. 'md5' => '3149650120e541d7d0fa577eef0ee9a3',
  171. 'options' => array('no-core' => NULL, 'projects' => 'boxes'),
  172. ),
  173. 'limit-projects-multiple' => array(
  174. 'name' => 'Limit multiple projects downloaded',
  175. 'makefile' => 'limited-projects-libraries.make',
  176. 'build' => TRUE,
  177. 'md5' => 'ef8996c4d6c6f0d229e2237c73860071',
  178. 'options' => array('no-core' => NULL, 'projects' => 'boxes,admin_menu'),
  179. ),
  180. 'md5-fail' => array(
  181. 'name' => 'Failed MD5 validation test',
  182. 'makefile' => 'md5-fail.make',
  183. 'build' => FALSE,
  184. 'md5' => FALSE,
  185. 'options' => array('no-core' => NULL),
  186. 'fail' => TRUE,
  187. ),
  188. 'md5-succeed' => array(
  189. 'name' => 'MD5 validation',
  190. 'makefile' => 'md5-succeed.make',
  191. 'build' => TRUE,
  192. 'md5' => 'f76ec174a775ce67f8e9edcb02336ef2',
  193. 'options' => array('no-core' => NULL),
  194. ),
  195. 'no-patch-txt' => array(
  196. 'name' => 'Test --no-patch-txt option',
  197. 'makefile' => 'patches.make',
  198. 'build' => TRUE,
  199. 'md5' => '59267a04f98374ed5b0b75e90cefcd9c',
  200. 'options' => array('no-core' => NULL, 'no-patch-txt' => NULL),
  201. ),
  202. 'options-array' => array(
  203. 'name' => 'Test global options array',
  204. 'makefile' => 'options-array.make',
  205. 'build' => TRUE,
  206. 'options' => array(),
  207. ),
  208. 'options-project' => array(
  209. 'name' => 'Test per-project options array',
  210. 'makefile' => 'options-project.make',
  211. 'build' => TRUE,
  212. 'options' => array(),
  213. ),
  214. 'patch' => array(
  215. 'name' => 'Test patching and writing of PATCHES.txt file',
  216. 'makefile' => 'patches.make',
  217. 'build' => TRUE,
  218. 'md5' => '536ee287344c24f47e0808622d7d091b',
  219. 'options' => array('no-core' => NULL),
  220. ),
  221. 'recursion' => array(
  222. 'name' => 'Recursion',
  223. 'makefile' => 'recursion.make',
  224. 'build' => TRUE,
  225. 'md5' => 'cd095bd6dadb2f0d3e81f85f13685372',
  226. 'options' => array(
  227. 'no-core' => NULL,
  228. 'contrib-destination' => 'profiles/drupal_forum',
  229. ),
  230. ),
  231. 'recursion-override' => array(
  232. 'name' => 'Recursion overrides',
  233. 'makefile' => 'recursion-override.make',
  234. 'build' => TRUE,
  235. 'md5' => 'a13c3d5d416be9fa78569514844b96a2',
  236. 'options' => array(
  237. 'no-core' => NULL,
  238. ),
  239. ),
  240. 'subtree' => array(
  241. 'name' => 'Use subtree from downloaded archive',
  242. 'makefile' => 'subtree.make',
  243. 'build' => TRUE,
  244. 'md5' => 'db3770d8b4c9ce77510cbbcc566da9b8',
  245. 'options' => array('no-core' => NULL),
  246. ),
  247. 'svn' => array(
  248. 'name' => 'SVN',
  249. 'makefile' => 'svn.make',
  250. 'build' => TRUE,
  251. 'md5' => '0cb28a15958d7fc4bbf8bf6b00bc6514',
  252. 'options' => array('no-core' => NULL),
  253. ),
  254. 'translations' => array(
  255. 'name' => 'Translation downloads',
  256. 'makefile' => 'translations.make',
  257. 'options' => array(
  258. 'translations' => 'es,pt-br',
  259. 'no-core' => NULL,
  260. ),
  261. ),
  262. 'translations-inside' => array(
  263. 'name' => 'Translation downloads inside makefile',
  264. 'makefile' => 'translations-inside.make',
  265. ),
  266. 'translations-inside7' => array(
  267. 'name' => 'Translation downloads inside makefile, core 7.x',
  268. 'makefile' => 'translations-inside7.make',
  269. ),
  270. 'use-distribution-as-core' => array(
  271. 'name' => 'Use distribution as core',
  272. 'makefile' => 'use-distribution-as-core.make',
  273. 'build' => TRUE,
  274. 'md5' => '643a603025a20d498eb583a1e7970bad',
  275. 'options' => array(),
  276. ),
  277. );
  278. // Replicate ini tests for YAML format.
  279. foreach ($tests as $id => $test) {
  280. $id_yaml = $id . '-yaml';
  281. $tests[$id_yaml] = $test;
  282. $tests[$id_yaml]['name'] = $tests[$id]['name'] . '(in YAML format)';
  283. $tests[$id_yaml]['makefile'] = $tests[$id]['makefile'] . '.yml';
  284. }
  285. return $tests;
  286. }
  287. /************************************************************************
  288. * *
  289. * List of make tests (in alphabetical order, for easier navigation.) *
  290. * *
  291. ************************************************************************/
  292. /**
  293. * Test .info file writing and the use of a git reference cache for
  294. * git downloads.
  295. */
  296. function testInfoFileWritingGit() {
  297. // Use the git-simple.make file.
  298. $config = $this->getMakefile('git-simple');
  299. $options = array('no-core' => NULL);
  300. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  301. $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-build'), $options);
  302. // Test cck_signup.info file.
  303. $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/cck_signup/cck_signup.info');
  304. $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/cck_signup/cck_signup.info');
  305. $this->assertContains('; Information added by drush on 2011-07-27', $contents);
  306. $this->assertContains('version = "2fe932c"', $contents);
  307. $this->assertContains('project = "cck_signup"', $contents);
  308. // Verify that a reference cache was created.
  309. $cache_dir = UNISH_CACHE . DIRECTORY_SEPARATOR . 'cache';
  310. $this->assertFileExists($cache_dir . '/git/cck_signup-' . md5('http://git.drupal.org/project/cck_signup.git'));
  311. // Test context_admin.info file.
  312. $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/context_admin/context_admin.info');
  313. $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/context_admin/context_admin.info');
  314. $this->assertContains('; Information added by drush on 2011-10-27', $contents);
  315. $this->assertContains('version = "eb9f05e"', $contents);
  316. $this->assertContains('project = "context_admin"', $contents);
  317. // Verify git reference cache exists.
  318. $this->assertFileExists($cache_dir . '/git/context_admin-' . md5('http://git.drupal.org/project/context_admin.git'));
  319. // Text caption_filter .info rewrite.
  320. $this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/caption_filter/caption_filter.info');
  321. $contents = file_get_contents(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/caption_filter/caption_filter.info');
  322. $this->assertContains('; Information added by drush on 2011-09-20', $contents);
  323. $this->assertContains('version = "7.x-1.2+0-dev"', $contents);
  324. $this->assertContains('project = "caption_filter"', $contents);
  325. }
  326. /**
  327. * Test .info file writing and the use of a git reference cache for
  328. * git downloads.
  329. */
  330. function testInfoYamlFileWritingGit() {
  331. // Use the Drupal 8 .make file.
  332. $config = $this->getMakefile('git-simple-8');
  333. $options = array('no-core' => NULL);
  334. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  335. $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-build'), $options);
  336. $this->assertFileExists(UNISH_SANDBOX . '/test-build/modules/honeypot/honeypot.info.yml');
  337. $contents = file_get_contents(UNISH_SANDBOX . '/test-build/modules/honeypot/honeypot.info.yml');
  338. $this->assertContains('# Information added by drush on 2015-09-03', $contents);
  339. $this->assertContains("version: '8.x-1.x-dev'", $contents);
  340. $this->assertContains("project: 'honeypot'", $contents);
  341. }
  342. function testMakeBzr() {
  343. // Silently skip bzr test if bzr is not installed.
  344. exec('which bzr', $output, $whichBzrErrorCode);
  345. if (!$whichBzrErrorCode) {
  346. $this->runMakefileTest('bzr');
  347. }
  348. else {
  349. $this->markTestSkipped('bzr command is not available.');
  350. }
  351. }
  352. function testMakeBZ2() {
  353. // Silently skip bz2 test if bz2 is not installed.
  354. exec('which bzip2', $output, $whichBzip2ErrorCode);
  355. if (!$whichBzip2ErrorCode) {
  356. $this->runMakefileTest('bz2');
  357. }
  358. else {
  359. $this->markTestSkipped('bzip2 command not available.');
  360. }
  361. }
  362. function testMakeBZ2SingleFile() {
  363. // Silently skip bz2 test if bz2 is not installed.
  364. exec('which bzip2', $output, $whichBzip2ErrorCode);
  365. if (!$whichBzip2ErrorCode) {
  366. $this->runMakefileTest('bz2-singlefile');
  367. }
  368. else {
  369. $this->markTestSkipped('bzip2 command not available.');
  370. }
  371. }
  372. function testMakeContribDestination() {
  373. $this->runMakefileTest('contrib-destination');
  374. }
  375. /** @group make.yml */
  376. function testMakeContribDestinationYaml() {
  377. $this->runMakefileTest('contrib-destination-yaml');
  378. }
  379. function testMakeDefaults() {
  380. $this->runMakefileTest('defaults');
  381. }
  382. /** @group make.yml */
  383. function testMakeDefaultsYaml() {
  384. $this->runMakefileTest('defaults-yaml');
  385. }
  386. function testMakeFile() {
  387. $this->runMakefileTest('file');
  388. }
  389. function testMakeFileExtract() {
  390. // Silently skip file extraction test if unzip is not installed.
  391. exec('which unzip', $output, $whichUnzipErrorCode);
  392. if (!$whichUnzipErrorCode) {
  393. $this->runMakefileTest('file-extract');
  394. }
  395. else {
  396. $this->markTestSkipped('unzip command not available.');
  397. }
  398. }
  399. function testMakeGet() {
  400. $this->runMakefileTest('get');
  401. }
  402. function testMakeGit() {
  403. $this->runMakefileTest('git');
  404. }
  405. function testMakeGitSimple() {
  406. $this->runMakefileTest('git-simple');
  407. }
  408. function testMakeGZip() {
  409. // Silently skip gzip test if either gzip or unzip is not installed.
  410. exec('which gzip', $output, $whichGzipErrorCode);
  411. if (!$whichGzipErrorCode) {
  412. exec('which unzip', $output, $whichUnzipErrorCode);
  413. if (!$whichUnzipErrorCode) {
  414. $this->runMakefileTest('gzip');
  415. }
  416. else {
  417. $this->markTestSkipped('unzip command not available.');
  418. }
  419. }
  420. else {
  421. $this->markTestSkipped('gzip command not available.');
  422. }
  423. }
  424. function testMakeIgnoreChecksums() {
  425. $this->runMakefileTest('ignore-checksums');
  426. }
  427. function testMakeInclude() {
  428. $this->runMakefileTest('include');
  429. }
  430. /** @group make.yml */
  431. function testMakeIncludeYaml() {
  432. $this->runMakefileTest('include-yaml');
  433. }
  434. /**
  435. * Test git support on includes directive.
  436. */
  437. function testMakeIncludesGit() {
  438. $config = $this->getMakefile('includes-git');
  439. $options = array();
  440. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  441. $this->drush('make', array($makefile, UNISH_SANDBOX . '/test-git-includes'), $options);
  442. // Verify that core and example main module were downloaded.
  443. $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/README.txt');
  444. $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/sites/all/modules/contrib/apachesolr/README.txt');
  445. // Verify that module included in sub platform was downloaded.
  446. $this->assertFileExists(UNISH_SANDBOX . '/test-git-includes/sites/all/modules/contrib/jquery_update/README.txt');
  447. }
  448. function testMakeLimitProjects() {
  449. $this->runMakefileTest('limit-projects');
  450. $this->runMakefileTest('limit-projects-multiple');
  451. }
  452. function testMakeLimitLibraries() {
  453. $this->runMakefileTest('limit-libraries');
  454. $this->runMakefileTest('limit-libraries-multiple');
  455. }
  456. function testMakeMd5Fail() {
  457. $this->runMakefileTest('md5-fail');
  458. }
  459. function testMakeMd5Succeed() {
  460. $this->runMakefileTest('md5-succeed');
  461. }
  462. /**
  463. * Test that make_move_build() doesn't wipe out directories that it shouldn't.
  464. */
  465. function testMakeMoveBuild() {
  466. // Manually download a module.
  467. $options = array(
  468. 'default-major' => 6, // The makefile used below is core = "6.x".
  469. 'destination' => UNISH_SANDBOX . '/sites/all/modules/contrib',
  470. 'yes' => NULL,
  471. 'dev' => NULL,
  472. );
  473. $this->drush('pm-download', array('cck_signup'), $options);
  474. // Build a make file.
  475. $config = $this->getMakefile('contrib-destination');
  476. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  477. $this->drush('make', array($makefile, '.'), $config['options']);
  478. // Verify that the manually downloaded module still exists.
  479. $this->assertFileExists(UNISH_SANDBOX . '/sites/all/modules/contrib/cck_signup/README.txt');
  480. }
  481. function testMakeNoPatchTxt() {
  482. $this->runMakefileTest('no-patch-txt');
  483. }
  484. function testMakeNoRecursion() {
  485. $config = $this->getMakefile('recursion');
  486. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  487. $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'norecursion';
  488. $this->drush('make', array('--no-core', '--no-recursion', $makefile, $install_directory));
  489. $this->assertNotContains("ctools", $this->getOutput(), "Make with --no-recursion does not recurse into drupal_forum to download ctools.");
  490. }
  491. /**
  492. * Test no-core and working-copy in options array.
  493. */
  494. function testMakeOptionsArray() {
  495. // Use the goptions-array.make file.
  496. $config = $this->getMakefile('options-array');
  497. $makefile_path = dirname(__FILE__) . '/makefiles';
  498. $makefile = $makefile_path . '/' . $config['makefile'];
  499. $install_directory = UNISH_SANDBOX . '/options-array';
  500. $this->drush('make', array($makefile, $install_directory));
  501. // Test cck_signup .git/HEAD file.
  502. $this->assertFileExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  503. $contents = file_get_contents($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  504. $this->assertContains('2fe932c', $contents);
  505. // Test context_admin .git/HEAD file.
  506. $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  507. $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  508. $this->assertContains('eb9f05e', $contents);
  509. }
  510. /**
  511. * Test per project working-copy option.
  512. */
  513. function testMakeOptionsProject() {
  514. // Use the options-project.make file.
  515. $config = $this->getMakefile('options-project');
  516. $makefile_path = dirname(__FILE__) . '/makefiles';
  517. $options = array('no-core' => NULL);
  518. $makefile = $makefile_path . '/' . $config['makefile'];
  519. $install_directory = UNISH_SANDBOX . '/options-project';
  520. $this->drush('make', array($makefile, $install_directory), $options);
  521. // Test context_admin .git/HEAD file.
  522. $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  523. $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  524. $this->assertContains('eb9f05e', $contents);
  525. // Test cck_signup .git/HEAD file does not exist.
  526. $this->assertFileNotExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  527. // Test caption_filter .git/HEAD file.
  528. $this->assertFileExists($install_directory . '/sites/all/modules/contrib/caption_filter/.git/HEAD');
  529. $contents = file_get_contents($install_directory . '/sites/all/modules/contrib//caption_filter/.git/HEAD');
  530. $this->assertContains('c9794cf', $contents);
  531. }
  532. function testMakePatch() {
  533. $this->runMakefileTest('patch');
  534. }
  535. function testMakeRecursion() {
  536. $this->runMakefileTest('recursion');
  537. }
  538. function testMakeRecursionOverride() {
  539. // @todo This is skipped for now since the test relies on sourceforge.
  540. // It can be replaced if a suitable module that installs projects (not
  541. // libraries, which aren't properly overridable).
  542. $this->markTestSkipped('skipping recursion-override test');
  543. return;
  544. // Silently skip file extraction test if unzip is not installed.
  545. exec('which unzip', $output, $whichUnzipErrorCode);
  546. if (!$whichUnzipErrorCode) {
  547. $this->runMakefileTest('recursion-override');
  548. }
  549. else {
  550. $this->markTestSkipped('unzip command not available.');
  551. }
  552. }
  553. function testMakeSubtree() {
  554. // Silently skip subtree test if unzip is not installed.
  555. exec('which unzip', $output, $whichUnzipErrorCode);
  556. if (!$whichUnzipErrorCode) {
  557. $config = $this->getMakefile('subtree');
  558. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  559. $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'subtree';
  560. $this->drush('make', array('--no-core', $makefile, $install_directory));
  561. $files['nivo-slider'] = array(
  562. 'exists' => array(
  563. 'jquery.nivo.slider.js',
  564. 'jquery.nivo.slider.pack.js',
  565. 'license.txt',
  566. 'nivo-slider.css',
  567. 'README',
  568. ),
  569. 'notexists' => array(
  570. '__MACOSX',
  571. 'nivo-slider',
  572. ),
  573. );
  574. $files['fullcalendar'] = array(
  575. 'exists' => array(
  576. 'fullcalendar.css',
  577. 'fullcalendar.js',
  578. 'fullcalendar.min.js',
  579. 'fullcalendar.print.css',
  580. 'gcal.js',
  581. ),
  582. 'notexists' => array(
  583. 'changelog.txt',
  584. 'demos',
  585. 'fullcalendar',
  586. 'GPL-LICENSE.txt',
  587. 'jquery',
  588. 'MIT-LICENSE.txt',
  589. ),
  590. );
  591. $basedir = $install_directory . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'libraries';
  592. foreach ($files as $lib => $details) {
  593. $dir = $basedir . DIRECTORY_SEPARATOR . $lib;
  594. if (!empty($details['exists'])) {
  595. foreach ($details['exists'] as $file) {
  596. $this->assertFileExists($dir . DIRECTORY_SEPARATOR . $file);
  597. }
  598. }
  599. if (!empty($details['notexists'])) {
  600. foreach ($details['notexists'] as $file) {
  601. $this->assertFileNotExists($dir . DIRECTORY_SEPARATOR . $file);
  602. }
  603. }
  604. }
  605. }
  606. else {
  607. $this->markTestSkipped('unzip command not available.');
  608. }
  609. }
  610. function testMakeSvn() {
  611. return $this->markTestSkipped('svn support is deprecated.');
  612. // Silently skip svn test if svn is not installed.
  613. exec('which svn', $output, $whichSvnErrorCode);
  614. if (!$whichSvnErrorCode) {
  615. $this->runMakefileTest('svn');
  616. }
  617. else {
  618. $this->markTestSkipped('svn command not available.');
  619. }
  620. }
  621. /**
  622. * Translations can change arbitrarily, so these test for the existence of .po
  623. * files, rather than trying to match a build hash.
  624. */
  625. function testMakeTranslations() {
  626. $config = $this->getMakefile('translations');
  627. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  628. $install_directory = UNISH_SANDBOX . '/translations';
  629. $this->drush('make', array($makefile, $install_directory), $config['options']);
  630. $po_files = array(
  631. 'sites/all/modules/token/translations/pt-br.po',
  632. 'sites/all/modules/token/translations/es.po',
  633. );
  634. foreach ($po_files as $po_file) {
  635. $this->assertFileExists($install_directory . '/' . $po_file);
  636. }
  637. }
  638. /**
  639. * Translations can change arbitrarily, so these test for the existence of .po
  640. * files, rather than trying to match a build hash.
  641. */
  642. function testMakeTranslationsInside() {
  643. $config = $this->getMakefile('translations-inside');
  644. $makefile = $this->makefile_path . '/' . $config['makefile'];
  645. $install_directory = UNISH_SANDBOX . '/translations-inside';
  646. $this->drush('make', array($makefile, $install_directory));
  647. $po_files = array(
  648. 'profiles/default/translations/pt-br.po',
  649. 'profiles/default/translations/es.po',
  650. 'sites/all/modules/token/translations/pt-br.po',
  651. 'sites/all/modules/token/translations/es.po',
  652. 'modules/system/translations/pt-br.po',
  653. 'modules/system/translations/es.po',
  654. );
  655. foreach ($po_files as $po_file) {
  656. $this->assertFileExists($install_directory . '/' . $po_file);
  657. }
  658. }
  659. /**
  660. * Translations can change arbitrarily, so these test for the existence of .po
  661. * files, rather than trying to match a build hash.
  662. */
  663. function testMakeTranslationsInside7() {
  664. $config = $this->getMakefile('translations-inside7');
  665. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  666. $install_directory = UNISH_SANDBOX . '/translations-inside7';
  667. $this->drush('make', array($makefile, $install_directory));
  668. $po_files = array(
  669. 'profiles/minimal/translations/pt-br.po',
  670. 'profiles/minimal/translations/es.po',
  671. 'profiles/testing/translations/pt-br.po',
  672. 'profiles/testing/translations/es.po',
  673. 'profiles/standard/translations/pt-br.po',
  674. 'profiles/standard/translations/es.po',
  675. 'sites/all/modules/token/translations/pt-br.po',
  676. 'sites/all/modules/token/translations/es.po',
  677. 'modules/system/translations/pt-br.po',
  678. 'modules/system/translations/es.po',
  679. );
  680. foreach ($po_files as $po_file) {
  681. $this->assertFileExists($install_directory . '/' . $po_file);
  682. }
  683. }
  684. /**
  685. * Test that a distribution can be used as a "core" project.
  686. */
  687. function testMakeUseDistributionAsCore() {
  688. $this->runMakefileTest('use-distribution-as-core');
  689. }
  690. /**
  691. * Test that files without a core attribute are correctly identified.
  692. */
  693. public function testNoCoreMakefileParsing() {
  694. require_once __DIR__ . '/../commands/make/make.utilities.inc';
  695. // INI.
  696. $data = file_get_contents(__DIR__ . '/makefiles/no-core.make');
  697. $parsed = _make_determine_format($data);
  698. $this->assertEquals('ini', $parsed['format']);
  699. $this->assertEquals(42, $parsed['projects']['foo']['version']);
  700. // YAML.
  701. $data = file_get_contents(__DIR__ . '/makefiles/no-core.make.yml');
  702. $parsed = _make_determine_format($data);
  703. $this->assertEquals('yaml', $parsed['format']);
  704. $this->assertEquals(42, $parsed['projects']['foo']['version']);
  705. }
  706. }