diff --git a/docs/migration_2_to_3.rst b/docs/migration_2_to_3.rst index 94640b913a..22d8fb6ab9 100644 --- a/docs/migration_2_to_3.rst +++ b/docs/migration_2_to_3.rst @@ -24,18 +24,24 @@ As soon as it detects an old-style configuration file, it will convert it to the ./bin/reframe: the syntax of the configuration file 'unittests/resources/settings_old_syntax.py' is deprecated ./bin/reframe: configuration file has been converted to the new syntax here: '/var/folders/h7/k7cgrdl13r996m4dmsvjq7v80000gp/T/tmph5n8u3kf.py' -Alternatively, you can convert any old configuration file using the conversion tool ``tools/convert_config.py``: +Alternatively, you can convert any old configuration file using the conversion tool |convert_config|_: + +.. |convert_config| replace:: :obj:`convert-config` +.. _convert_config: https://github.com/eth-cscs/reframe/blob/master/tools/convert-config .. code-block:: none - $ ./tools/convert-config unittests/resources/settings_old_syntax.py - Conversion successful! The converted file can be found at '/var/folders/h7/k7cgrdl13r996m4dmsvjq7v80000gp/T/tmpz4f6yer4.py'. + $ ./tools/convert-config unittests/resources/settings_old_syntax.py new_config.py + Conversion successful! The converted file can be found at 'new_config.py'. Another important change is that default locations for looking up a configuration file has changed (see `Configuring ReFrame for Your Site `__ for more details). That practically means that if you were relying on ReFrame loading your ``reframe/settings.py`` by default, this is no longer true. You have to move it to any of the default settings locations or set the corresponding command line option or environment variable. +.. note:: + The conversion tool will create a JSON configuration file if the extension of the target file is ``.json``. + Automatic conversion limitations ================================ diff --git a/reframe/core/config.py b/reframe/core/config.py index eaf8c56784..ad1a1a8a50 100644 --- a/reframe/core/config.py +++ b/reframe/core/config.py @@ -530,7 +530,11 @@ def handler_list(handler_config): if newfilename: with open(newfilename, 'w') as fp: - fp.write(contents) + if newfilename.endswith('.json'): + json.dump(converted, fp, indent=4) + else: + fp.write(contents) + else: with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as fp: diff --git a/tools/convert_config.py b/tools/convert_config.py index 87f7e6762e..627ea73ffe 100755 --- a/tools/convert_config.py +++ b/tools/convert_config.py @@ -20,6 +20,9 @@ print(f'{sys.argv[0]}: too few arguments', file=sys.stderr) print(f'Usage: {sys.argv[0]} OLD_CONFIG_FILE [NEW_CONFIG_FILE]', file=sys.stderr) + print(' Use the extension of NEW_CONFIG_FILE to specify\n' + ' python (.py) or json (.json) format.', + file=sys.stderr) sys.exit(1) try: