Skip to content

Commit

Permalink
[2.0] File not installed if source used previously. (#2441)
Browse files Browse the repository at this point in the history
* fix failure to check sources list

* Update metomi/rose/config_processors/fileinstall.py

Co-authored-by: Oliver Sanders <[email protected]>

* Remove unwanted sorting.

* Update t/rose-app-run/27-fileinstall-when-sourcelist-changed.t

Co-authored-by: Oliver Sanders <[email protected]>
  • Loading branch information
wxtim and oliver-sanders authored Feb 24, 2021
1 parent 4f6aaa5 commit 59c2f6c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
18 changes: 17 additions & 1 deletion metomi/rose/config_processors/fileinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _process(self, conf_tree, nodes, loc_dao, **kwargs):
source.scheme = scheme
break
self.loc_handlers_manager.parse(source, conf_tree)
except ValueError as exc:
except ValueError:
if source.is_optional:
sources.pop(source.name)
for name in source.used_by_names:
Expand Down Expand Up @@ -253,6 +253,22 @@ def _process(self, conf_tree, nodes, loc_dao, **kwargs):
if prev_path != path:
target.is_out_of_date = True
break
# See if any sources have changed names.
if not target.is_out_of_date:
conn = loc_dao.get_conn()
try:
prev_dep_locs = conn.execute(
"SELECT * FROM dep_names WHERE name=?", [target.name]
).fetchall()
prev_dep_locs = [i[1] for i in prev_dep_locs]
prev_dep_locs = [loc_dao.select(i) for i in prev_dep_locs]
if (
[i.name for i in prev_dep_locs] !=
[i.name for i in target.dep_locs]
):
target.is_out_of_date = True
finally:
conn.close()
# See if any sources out of date
if not target.is_out_of_date:
for dep_loc in target.dep_locs:
Expand Down
65 changes: 65 additions & 0 deletions t/rose-app-run/27-fileinstall-when-sourcelist-changed.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (C) 2012-2020 British Crown (Met Office) & Contributors.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test that "rose app-run" compares the current source list properly against
# database file: See https://github.com/metomi/rose/issues/2438
#-------------------------------------------------------------------------------
. $(dirname $0)/test_header
test_init </dev/null
#-------------------------------------------------------------------------------
tests 1
#-------------------------------------------------------------------------------
test_setup
mkdir opt
touch rose-app.conf

# Create two alternative source files:
tee source.1 <<__HERE__
source 1 file
__HERE__
tee source.2 <<__HERE__
source 2 file
__HERE__

# Create two optional configs:
tee opt/rose-app-one.conf <<__HERE__
[command]
default=echo "Hello Magrathea!"
[file:MyTargetFile]
source=source.1
__HERE__
tee opt/rose-app-two.conf <<__HERE__
[command]
default=echo "Hello Magrathea!"
[file:MyTargetFile]
source=source.2
__HERE__

rose app-run -C $PWD -O one -i
rose app-run -C $PWD -O two -i
rose app-run -C $PWD -O one -i
# Before the bugfix rose app-run would think it had already installed source 1.
file_cmp "${TEST_KEY_BASE}-1st-install-output" "MyTargetFile" <<__INSTALLED_FILE__
source 1 file
__INSTALLED_FILE__


test_teardown

0 comments on commit 59c2f6c

Please sign in to comment.