Skip to content
Permalink
Browse files Browse the repository at this point in the history
Execute .profile script at runtime
- Add integration showing that .profile script runs.
- Add unit test for all top-level system files which are not meant to
  be moved into the htdocs directory.
- Move a stray assertion about not moving manifest.yml to the new test.
- Add .profile to the list of files/dirs which should not be moved from
  the toplevel into htdocs/

[#127923697]

Signed-off-by: Sam Smith <sesmith177@gmail.com>
Signed-off-by: Jacques Chester <jchester@pivotal.io>
  • Loading branch information
jchesterpivotal committed Aug 15, 2016
1 parent 7db7701 commit e2db3cc
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions cf_spec/fixtures/php_app_with_profile_script/.profile
@@ -0,0 +1 @@
export PROFILE_SCRIPT_IS_PRESENT_AND_RAN="Hooray for environment variables!"
1 change: 1 addition & 0 deletions cf_spec/fixtures/php_app_with_profile_script/index.php
@@ -0,0 +1 @@
<?php echo phpinfo() ?>
14 changes: 14 additions & 0 deletions cf_spec/integration/profile_d_sets_environment_variables_spec.rb
Expand Up @@ -17,4 +17,18 @@
expect(browser).to have_body('TEST_ENV_VAR')
end
end

context 'deploying a PHP app with .profile script' do
let(:app_name) { 'php_app_with_profile_script' }

it "sets environment variables via .profile script" do
cf_api_output = Machete::CF::API.new.execute

cf_api_version = cf_api_output.match( /API version: (?<version_number>\d+\.\d+\.\d+)/ )['version_number']
minimum_acceptable_cf_api_version = Gem::Version.new('2.57.0')
skip(".profile script functionality not supported before CF API version #{minimum_acceptable_cf_api_version}") if Gem::Version.new(cf_api_version) < minimum_acceptable_cf_api_version
browser.visit_path('/')
expect(browser).to have_body('PROFILE_SCRIPT_IS_PRESENT_AND_RAN')
end
end
end
2 changes: 2 additions & 0 deletions lib/compile_helpers.py
Expand Up @@ -54,6 +54,8 @@ def setup_webdir_if_it_doesnt_exist(ctx):
'^%s/.*$' % os.path.join(ctx['BUILD_DIR'], ctx['LIBDIR']))
fu.where_name_does_not_match(
'^%s/.*$' % os.path.join(ctx['BUILD_DIR'], '.profile.d'))
fu.where_name_does_not_match(
'^%s$' % os.path.join(ctx['BUILD_DIR'], '.profile'))
fu.done()


Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
@@ -0,0 +1 @@
This directory is not a "real" app. It is a fixture intended to support test_system_files_not_moved_into_webdir. That's why all the files and folders are empty.
Empty file.
15 changes: 14 additions & 1 deletion tests/test_compile_helpers.py
Expand Up @@ -120,7 +120,6 @@ def test_setup_if_htdocs_does_not_exist_but_library_does(self):
self.assert_exists(self.build_dir, '.bp-config', 'options.json')
self.assert_exists(self.build_dir, '.bp-config', 'httpd', 'extra',
'httpd-remoteip.conf')
self.assert_exists(self.build_dir, 'manifest.yml')
eq_(4, len(os.listdir(self.build_dir)))
eq_(4, len(os.listdir(os.path.join(self.build_dir, 'htdocs'))))

Expand Down Expand Up @@ -195,6 +194,20 @@ def test_setup_if_custom_webdir_does_not_exist_with_extensions(self):
eq_(4, len(os.listdir(self.build_dir)))
eq_(3, len(os.listdir(os.path.join(self.build_dir, 'public'))))

def test_system_files_not_moved_into_webdir(self):
shutil.copytree('tests/data/app-with-all-possible-system-files-that-should-not-move', self.build_dir)
setup_webdir_if_it_doesnt_exist(utils.FormattedDict({
'BUILD_DIR': self.build_dir,
'WEBDIR': 'htdocs',
'LIBDIR': 'lib'
}))
self.assert_exists(self.build_dir, '.bp')
self.assert_exists(self.build_dir, '.extensions')
self.assert_exists(self.build_dir, '.bp-config')
self.assert_exists(self.build_dir, 'manifest.yml')
self.assert_exists(self.build_dir, '.profile.d')
self.assert_exists(self.build_dir, '.profile')

def test_setup_if_htdocs_with_stand_alone_app(self):
shutil.copytree('tests/data/app-5', self.build_dir)
setup_webdir_if_it_doesnt_exist(utils.FormattedDict({
Expand Down

0 comments on commit e2db3cc

Please sign in to comment.