diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-11-05 21:31:55 -0500 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2018-11-06 16:37:50 -0500 |
commit | a173dbf7724b71771fac51e2fcf316b5bfa59848 (patch) | |
tree | c89fed8521c456cbb5b287170bba9aea3a5dc08f | |
parent | 425133fd0faad6de0d99a7ef6b7882f7091a6c05 (diff) | |
download | meson-a173dbf7724b71771fac51e2fcf316b5bfa59848.zip meson-a173dbf7724b71771fac51e2fcf316b5bfa59848.tar.gz meson-a173dbf7724b71771fac51e2fcf316b5bfa59848.tar.bz2 |
Add reconfigure/wipe unit test
-rwxr-xr-x | run_unittests.py | 36 | ||||
-rw-r--r-- | test cases/unit/46 reconfigure/main.c | 4 | ||||
-rw-r--r-- | test cases/unit/46 reconfigure/meson.build | 9 | ||||
-rw-r--r-- | test cases/unit/46 reconfigure/meson_options.txt | 4 |
4 files changed, 53 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index 5574b5f..d63a961 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -25,6 +25,7 @@ import shutil import sys import unittest import platform +import pickle from itertools import chain from unittest import mock from configparser import ConfigParser @@ -2778,6 +2779,41 @@ recommended as it is not supported on some platforms''') self.wipe() self.init(testdir, extra_args=['-Dstart_native=true']) + def test_reconfigure(self): + testdir = os.path.join(self.unit_test_dir, '46 reconfigure') + self.init(testdir, extra_args=['-Dopt1=val1']) + self.setconf('-Dopt2=val2') + + # Set an older version to force a reconfigure from scratch + filename = os.path.join(self.privatedir, 'coredata.dat') + with open(filename, 'rb') as f: + obj = pickle.load(f) + obj.version = '0.47.0' + with open(filename, 'wb') as f: + pickle.dump(obj, f) + + out = self.init(testdir, extra_args=['--reconfigure', '-Dopt3=val3']) + self.assertRegex(out, 'WARNING:.*Regenerating configuration from scratch') + self.assertRegex(out, 'opt1 val1') + self.assertRegex(out, 'opt2 val2') + self.assertRegex(out, 'opt3 val3') + self.assertRegex(out, 'opt4 default4') + self.build() + self.run_tests() + + # Create a file in builddir and verify wipe command removes it + filename = os.path.join(self.builddir, 'something') + open(filename, 'w').close() + self.assertTrue(os.path.exists(filename)) + out = self.init(testdir, extra_args=['--wipe', '-Dopt4=val4']) + self.assertFalse(os.path.exists(filename)) + self.assertRegex(out, 'opt1 val1') + self.assertRegex(out, 'opt2 val2') + self.assertRegex(out, 'opt3 val3') + self.assertRegex(out, 'opt4 val4') + self.build() + self.run_tests() + class FailureTests(BasePlatformTests): ''' Tests that test failure conditions. Build files here should be dynamically diff --git a/test cases/unit/46 reconfigure/main.c b/test cases/unit/46 reconfigure/main.c new file mode 100644 index 0000000..25927f5 --- /dev/null +++ b/test cases/unit/46 reconfigure/main.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/unit/46 reconfigure/meson.build b/test cases/unit/46 reconfigure/meson.build new file mode 100644 index 0000000..6eaac5d --- /dev/null +++ b/test cases/unit/46 reconfigure/meson.build @@ -0,0 +1,9 @@ +project('test-reconfigure', 'c') + +message('opt1 ' + get_option('opt1')) +message('opt2 ' + get_option('opt2')) +message('opt3 ' + get_option('opt3')) +message('opt4 ' + get_option('opt4')) + +exe = executable('test1', 'main.c') +test('test1', exe) diff --git a/test cases/unit/46 reconfigure/meson_options.txt b/test cases/unit/46 reconfigure/meson_options.txt new file mode 100644 index 0000000..728f7b7 --- /dev/null +++ b/test cases/unit/46 reconfigure/meson_options.txt @@ -0,0 +1,4 @@ +option('opt1', type : 'string', value : 'default1') +option('opt2', type : 'string', value : 'default2') +option('opt3', type : 'string', value : 'default3') +option('opt4', type : 'string', value : 'default4') |