Skip to content

Commit

Permalink
Better fix for cmake macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfouca authored and rfiorella committed Jun 13, 2024
1 parent dbe98a8 commit 27b797b
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions scripts/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2686,21 +2686,20 @@ def query_var(self, var_name, env, var):
with open(macros_file_name, "w") as macros_file:
for key in var:
macros_file.write("set({} {})\n".format(key, var[key]))
for key in env:
macros_file.write("set({} {})\n".format(key, env[key]))

macros_file.write(self.cmake_string)
with open(cmakelists_name, "w") as cmakelists:
cmakelists.write(self._cmakelists_template.format(var_name))

environment = os.environ.copy()
environment.update(env)
os_ = MACHINE.get_value("OS")
# cmake will not work on cray systems without this flag
if os_ == "CNL":
cmake_args = "-DCMAKE_SYSTEM_NAME=Catamount"
else:
cmake_args = ""

run_cmd_assert_result(self.parent, "cmake %s . 2>&1" % cmake_args, from_dir=temp_dir)
run_cmd_assert_result(self.parent, "cmake %s . 2>&1" % cmake_args, from_dir=temp_dir, env=environment)

with open(output_name, "r") as output:
query_result = output.read().strip()
Expand Down Expand Up @@ -3197,10 +3196,10 @@ def test_remove_dependency_issues(self):

tester = self.xml_to_tester(xml2+xml1)

tester.assert_variable_equals("SCC", "icc", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPICXX", "mpifoo", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPIFC", "mpiffoo", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPICC", "mpicc", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("SCC", "icc", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPICXX", "mpifoo", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPIFC", "mpiffoo", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPICC", "mpicc", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})

def test_override_with_machine_and_same_attributes(self):
"""Test that machine-specific conditional overrides with the same attribute work correctly."""
Expand All @@ -3216,11 +3215,11 @@ def test_override_with_machine_and_same_attributes(self):

tester = self.xml_to_tester(xml1+xml2)

tester.assert_variable_equals("MPIFC", "mpif90", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPIFC", "mpif90", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})

tester = self.xml_to_tester(xml2+xml1)

tester.assert_variable_equals("MPIFC", "mpif90", env={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})
tester.assert_variable_equals("MPIFC", "mpif90", var={"COMPILER":self.test_compiler, "MPILIB":self.test_mpilib})

def test_appends_not_overriden(self):
"""Test that machine-specific base value changes don't interfere with appends."""
Expand All @@ -3242,15 +3241,15 @@ def test_appends_not_overriden(self):

tester = self.xml_to_tester(xml1+xml2)

tester.assert_variable_equals("FFLAGS", "-base2", env={"COMPILER": self.test_compiler})
tester.assert_variable_equals("FFLAGS", "-base2 -debug2", env={"COMPILER": self.test_compiler, "DEBUG": "TRUE"})
tester.assert_variable_equals("FFLAGS", "-base2 -debug1", env={"COMPILER": self.test_compiler, "DEBUG": "FALSE"})
tester.assert_variable_equals("FFLAGS", "-base2", var={"COMPILER": self.test_compiler})
tester.assert_variable_equals("FFLAGS", "-base2 -debug2", var={"COMPILER": self.test_compiler, "DEBUG": "TRUE"})
tester.assert_variable_equals("FFLAGS", "-base2 -debug1", var={"COMPILER": self.test_compiler, "DEBUG": "FALSE"})

tester = self.xml_to_tester(xml2+xml1)

tester.assert_variable_equals("FFLAGS", "-base2", env={"COMPILER": self.test_compiler})
tester.assert_variable_equals("FFLAGS", "-base2 -debug2", env={"COMPILER": self.test_compiler, "DEBUG": "TRUE"})
tester.assert_variable_equals("FFLAGS", "-base2 -debug1", env={"COMPILER": self.test_compiler, "DEBUG": "FALSE"})
tester.assert_variable_equals("FFLAGS", "-base2", var={"COMPILER": self.test_compiler})
tester.assert_variable_equals("FFLAGS", "-base2 -debug2", var={"COMPILER": self.test_compiler, "DEBUG": "TRUE"})
tester.assert_variable_equals("FFLAGS", "-base2 -debug1", var={"COMPILER": self.test_compiler, "DEBUG": "FALSE"})

def test_multilevel_specificity(self):
"""Check that settings with multiple levels of machine-specificity can be resolved."""
Expand Down Expand Up @@ -3279,9 +3278,9 @@ def test_multilevel_specificity(self):
testers.append(self.xml_to_tester(xml3+xml2+xml1))

for tester in testers:
tester.assert_variable_equals("MPIFC", "mpif90", env={"COMPILER": self.test_compiler, "MPILIB": self.test_mpilib, "DEBUG": "TRUE"})
tester.assert_variable_equals("MPIFC", "mpif03", env={"COMPILER": self.test_compiler, "MPILIB": self.test_mpilib, "DEBUG": "FALSE"})
tester.assert_variable_equals("MPIFC", "mpifc", env={"COMPILER": self.test_compiler, "MPILIB": "NON_MATCHING_MPI", "DEBUG": "FALSE"})
tester.assert_variable_equals("MPIFC", "mpif90", var={"COMPILER": self.test_compiler, "MPILIB": self.test_mpilib, "DEBUG": "TRUE"})
tester.assert_variable_equals("MPIFC", "mpif03", var={"COMPILER": self.test_compiler, "MPILIB": self.test_mpilib, "DEBUG": "FALSE"})
tester.assert_variable_equals("MPIFC", "mpifc", var={"COMPILER": self.test_compiler, "MPILIB": "NON_MATCHING_MPI", "DEBUG": "FALSE"})

def test_remove_dependency_issues(self):
"""Check that overridden settings don't cause inter-variable dependencies."""
Expand Down

0 comments on commit 27b797b

Please sign in to comment.