Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: lib/naclports/tests/test_binary_package.py

Issue 1279413002: Remove execute bit from binaries install in the toolchain (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Native Client Authors. All rights reserved. 1 # Copyright 2014 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from mock import Mock, patch, call 5 from mock import Mock, patch, call
6 import textwrap 6 import textwrap
7 7
8 import common 8 import common
9 from naclports import binary_package 9 from naclports import binary_package
10 10
11 11
12 # pylint: disable=no-self-use 12 # pylint: disable=no-self-use
13 class TestBinaryPackage(common.NaclportsTest): 13 class TestBinaryPackage(common.NaclportsTest):
14 14
15 @patch('os.rename') 15 @patch('os.rename')
16 @patch('os.makedirs') 16 @patch('os.makedirs')
17 @patch('os.path.isdir', Mock(return_value=False)) 17 @patch('os.path.isdir', Mock(return_value=False))
18 def testInstallFile(self, makedirs_mock, rename_mock): 18 def testInstallFile(self, makedirs_mock, rename_mock):
19 binary_package.InstallFile('fname', 'location1', 'location2') 19 mock_file = common.MockFileObject()
20 makedirs_mock.assert_called_once_with('location2') 20 with patch('__builtin__.open', Mock(return_value=mock_file)):
21 rename_mock.assert_has_calls([call('location1/fname', 'location2/fname')]) 21 binary_package.InstallFile('fname', 'location1', 'location2')
22 makedirs_mock.assert_called_once_with('location2')
23 rename_mock.assert_has_calls([call('location1/fname', 'location2/fname')])
22 24
23 def testRelocateFile(self): 25 def testRelocateFile(self):
24 # Only certain files should be relocated. A file called 'testfile' 26 # Only certain files should be relocated. A file called 'testfile'
25 # for example, should not be touched. 27 # for example, should not be touched.
26 with patch('__builtin__.open', Mock(), create=True) as open_mock: 28 with patch('__builtin__.open', Mock(), create=True) as open_mock:
27 binary_package.RelocateFile('testfile', 'newroot') 29 binary_package.RelocateFile('testfile', 'newroot')
28 open_mock.assert_not_called() 30 open_mock.assert_not_called()
29 31
30 @patch('naclports.binary_package.BinaryPackage.VerifyArchiveFormat', Mock()) 32 @patch('naclports.binary_package.BinaryPackage.VerifyArchiveFormat', Mock())
31 @patch('naclports.binary_package.BinaryPackage.GetPkgInfo') 33 @patch('naclports.binary_package.BinaryPackage.GetPkgInfo')
32 @patch('naclports.util.GetInstallStamp', 34 @patch('naclports.util.GetInstallStamp',
33 Mock(return_value='stamp_dir/stamp_file')) 35 Mock(return_value='stamp_dir/stamp_file'))
34 def testWriteStamp(self, mock_get_info): 36 def testWriteStamp(self, mock_get_info):
35 fake_binary_pkg_info = textwrap.dedent('''\ 37 fake_binary_pkg_info = textwrap.dedent('''\
36 NAME=foo 38 NAME=foo
37 VERSION=1.0 39 VERSION=1.0
38 BUILD_CONFIG=release 40 BUILD_CONFIG=release
39 BUILD_ARCH=arm 41 BUILD_ARCH=arm
40 BUILD_TOOLCHAIN=newlib 42 BUILD_TOOLCHAIN=newlib
41 BUILD_SDK_VERSION=38 43 BUILD_SDK_VERSION=38
42 BUILD_NACLPORTS_REVISION=1414 44 BUILD_NACLPORTS_REVISION=1414
43 ''') 45 ''')
44 mock_get_info.return_value = fake_binary_pkg_info 46 mock_get_info.return_value = fake_binary_pkg_info
45 pkg = binary_package.BinaryPackage('foo') 47 pkg = binary_package.BinaryPackage('foo')
46 mock_stamp_file = common.MockFileObject() 48 mock_stamp_file = common.MockFileObject()
47 with patch('__builtin__.open', Mock(return_value=mock_stamp_file), 49 with patch('__builtin__.open', Mock(return_value=mock_stamp_file),
48 create=True): 50 create=True):
49 pkg.WriteStamp() 51 pkg.WriteStamp()
50 mock_stamp_file.write.assert_called_once_with(fake_binary_pkg_info) 52 mock_stamp_file.write.assert_called_once_with(fake_binary_pkg_info)
OLDNEW
« no previous file with comments | « lib/naclports/source_package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698