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' => '526332db5456847c316cad7dc6d496f8',
  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 ' . date('Y-m-d'), $contents);
  339. $this->assertContains("version: '8.x-1.18-beta1+1-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. );
  472. $this->drush('pm-download', array('cck_signup'), $options);
  473. // Build a make file.
  474. $config = $this->getMakefile('contrib-destination');
  475. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  476. $this->drush('make', array($makefile, '.'), $config['options']);
  477. // Verify that the manually downloaded module still exists.
  478. $this->assertFileExists(UNISH_SANDBOX . '/sites/all/modules/contrib/cck_signup/README.txt');
  479. }
  480. function testMakeNoPatchTxt() {
  481. $this->runMakefileTest('no-patch-txt');
  482. }
  483. function testMakeNoRecursion() {
  484. $config = $this->getMakefile('recursion');
  485. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  486. $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'norecursion';
  487. $this->drush('make', array('--no-core', '--no-recursion', $makefile, $install_directory));
  488. $this->assertNotContains("ctools", $this->getOutput(), "Make with --no-recursion does not recurse into drupal_forum to download ctools.");
  489. }
  490. /**
  491. * Test no-core and working-copy in options array.
  492. */
  493. function testMakeOptionsArray() {
  494. // Use the goptions-array.make file.
  495. $config = $this->getMakefile('options-array');
  496. $makefile_path = dirname(__FILE__) . '/makefiles';
  497. $makefile = $makefile_path . '/' . $config['makefile'];
  498. $install_directory = UNISH_SANDBOX . '/options-array';
  499. $this->drush('make', array($makefile, $install_directory));
  500. // Test cck_signup .git/HEAD file.
  501. $this->assertFileExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  502. $contents = file_get_contents($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  503. $this->assertContains('2fe932c', $contents);
  504. // Test context_admin .git/HEAD file.
  505. $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  506. $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  507. $this->assertContains('eb9f05e', $contents);
  508. }
  509. /**
  510. * Test per project working-copy option.
  511. */
  512. function testMakeOptionsProject() {
  513. // Use the options-project.make file.
  514. $config = $this->getMakefile('options-project');
  515. $makefile_path = dirname(__FILE__) . '/makefiles';
  516. $options = array('no-core' => NULL);
  517. $makefile = $makefile_path . '/' . $config['makefile'];
  518. $install_directory = UNISH_SANDBOX . '/options-project';
  519. $this->drush('make', array($makefile, $install_directory), $options);
  520. // Test context_admin .git/HEAD file.
  521. $this->assertFileExists($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  522. $contents = file_get_contents($install_directory . '/sites/all/modules/context_admin/.git/HEAD');
  523. $this->assertContains('eb9f05e', $contents);
  524. // Test cck_signup .git/HEAD file does not exist.
  525. $this->assertFileNotExists($install_directory . '/sites/all/modules/cck_signup/.git/HEAD');
  526. // Test caption_filter .git/HEAD file.
  527. $this->assertFileExists($install_directory . '/sites/all/modules/contrib/caption_filter/.git/HEAD');
  528. $contents = file_get_contents($install_directory . '/sites/all/modules/contrib//caption_filter/.git/HEAD');
  529. $this->assertContains('c9794cf', $contents);
  530. }
  531. function testMakePatch() {
  532. $this->runMakefileTest('patch');
  533. }
  534. function testMakeRecursion() {
  535. $this->runMakefileTest('recursion');
  536. }
  537. function testMakeRecursionOverride() {
  538. // Silently skip file extraction test if unzip is not installed.
  539. exec('which unzip', $output, $whichUnzipErrorCode);
  540. if (!$whichUnzipErrorCode) {
  541. $this->runMakefileTest('recursion-override');
  542. }
  543. else {
  544. $this->markTestSkipped('unzip command not available.');
  545. }
  546. }
  547. function testMakeSubtree() {
  548. // Silently skip subtree test if unzip is not installed.
  549. exec('which unzip', $output, $whichUnzipErrorCode);
  550. if (!$whichUnzipErrorCode) {
  551. $config = $this->getMakefile('subtree');
  552. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  553. $install_directory = UNISH_SANDBOX . DIRECTORY_SEPARATOR . 'subtree';
  554. $this->drush('make', array('--no-core', $makefile, $install_directory));
  555. $files['nivo-slider'] = array(
  556. 'exists' => array(
  557. 'jquery.nivo.slider.js',
  558. 'jquery.nivo.slider.pack.js',
  559. 'license.txt',
  560. 'nivo-slider.css',
  561. 'README',
  562. ),
  563. 'notexists' => array(
  564. '__MACOSX',
  565. 'nivo-slider',
  566. ),
  567. );
  568. $files['fullcalendar'] = array(
  569. 'exists' => array(
  570. 'fullcalendar.css',
  571. 'fullcalendar.js',
  572. 'fullcalendar.min.js',
  573. 'fullcalendar.print.css',
  574. 'gcal.js',
  575. ),
  576. 'notexists' => array(
  577. 'changelog.txt',
  578. 'demos',
  579. 'fullcalendar',
  580. 'GPL-LICENSE.txt',
  581. 'jquery',
  582. 'MIT-LICENSE.txt',
  583. ),
  584. );
  585. $basedir = $install_directory . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'libraries';
  586. foreach ($files as $lib => $details) {
  587. $dir = $basedir . DIRECTORY_SEPARATOR . $lib;
  588. if (!empty($details['exists'])) {
  589. foreach ($details['exists'] as $file) {
  590. $this->assertFileExists($dir . DIRECTORY_SEPARATOR . $file);
  591. }
  592. }
  593. if (!empty($details['notexists'])) {
  594. foreach ($details['notexists'] as $file) {
  595. $this->assertFileNotExists($dir . DIRECTORY_SEPARATOR . $file);
  596. }
  597. }
  598. }
  599. }
  600. else {
  601. $this->markTestSkipped('unzip command not available.');
  602. }
  603. }
  604. function testMakeSvn() {
  605. // Silently skip svn test if svn is not installed.
  606. exec('which svn', $output, $whichSvnErrorCode);
  607. if (!$whichSvnErrorCode) {
  608. $this->runMakefileTest('svn');
  609. }
  610. else {
  611. $this->markTestSkipped('svn command not available.');
  612. }
  613. }
  614. /**
  615. * Translations can change arbitrarily, so these test for the existence of .po
  616. * files, rather than trying to match a build hash.
  617. */
  618. function testMakeTranslations() {
  619. $config = $this->getMakefile('translations');
  620. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  621. $install_directory = UNISH_SANDBOX . '/translations';
  622. $this->drush('make', array($makefile, $install_directory), $config['options']);
  623. $po_files = array(
  624. 'sites/all/modules/token/translations/pt-br.po',
  625. 'sites/all/modules/token/translations/es.po',
  626. );
  627. foreach ($po_files as $po_file) {
  628. $this->assertFileExists($install_directory . '/' . $po_file);
  629. }
  630. }
  631. /**
  632. * Translations can change arbitrarily, so these test for the existence of .po
  633. * files, rather than trying to match a build hash.
  634. */
  635. function testMakeTranslationsInside() {
  636. $config = $this->getMakefile('translations-inside');
  637. $makefile = $this->makefile_path . '/' . $config['makefile'];
  638. $install_directory = UNISH_SANDBOX . '/translations-inside';
  639. $this->drush('make', array($makefile, $install_directory));
  640. $po_files = array(
  641. 'profiles/default/translations/pt-br.po',
  642. 'profiles/default/translations/es.po',
  643. 'sites/all/modules/token/translations/pt-br.po',
  644. 'sites/all/modules/token/translations/es.po',
  645. 'modules/system/translations/pt-br.po',
  646. 'modules/system/translations/es.po',
  647. );
  648. foreach ($po_files as $po_file) {
  649. $this->assertFileExists($install_directory . '/' . $po_file);
  650. }
  651. }
  652. /**
  653. * Translations can change arbitrarily, so these test for the existence of .po
  654. * files, rather than trying to match a build hash.
  655. */
  656. function testMakeTranslationsInside7() {
  657. $config = $this->getMakefile('translations-inside7');
  658. $makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
  659. $install_directory = UNISH_SANDBOX . '/translations-inside7';
  660. $this->drush('make', array($makefile, $install_directory));
  661. $po_files = array(
  662. 'profiles/minimal/translations/pt-br.po',
  663. 'profiles/minimal/translations/es.po',
  664. 'profiles/testing/translations/pt-br.po',
  665. 'profiles/testing/translations/es.po',
  666. 'profiles/standard/translations/pt-br.po',
  667. 'profiles/standard/translations/es.po',
  668. 'sites/all/modules/token/translations/pt-br.po',
  669. 'sites/all/modules/token/translations/es.po',
  670. 'modules/system/translations/pt-br.po',
  671. 'modules/system/translations/es.po',
  672. );
  673. foreach ($po_files as $po_file) {
  674. $this->assertFileExists($install_directory . '/' . $po_file);
  675. }
  676. }
  677. /**
  678. * Test that a distribution can be used as a "core" project.
  679. */
  680. function testMakeUseDistributionAsCore() {
  681. $this->runMakefileTest('use-distribution-as-core');
  682. }
  683. /**
  684. * Test that files without a core attribute are correctly identified.
  685. */
  686. public function testNoCoreMakefileParsing() {
  687. require __DIR__ . '/../commands/make/make.utilities.inc';
  688. // INI.
  689. $data = file_get_contents(__DIR__ . '/makefiles/no-core.make');
  690. $parsed = _make_determine_format($data);
  691. $this->assertEquals('ini', $parsed['format']);
  692. $this->assertEquals(42, $parsed['projects']['foo']['version']);
  693. // YAML.
  694. $data = file_get_contents(__DIR__ . '/makefiles/no-core.make.yml');
  695. $parsed = _make_determine_format($data);
  696. $this->assertEquals('yaml', $parsed['format']);
  697. $this->assertEquals(42, $parsed['projects']['foo']['version']);
  698. }
  699. }