We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Build pFUnit on some other machines
We should build pFUnit on some other machines so we can run unit tests there:

- cheyenne
- hobart

Instructions for building pFUnit are:

1. Download pFUnit from
   http://sourceforge.net/projects/pfunit/files/latest/download

2. Set the PFUNIT environment variable. For example::

     ```
     export PFUNIT=/glade/p/cesmdata/cseg/tools/pFUnit/pFUnit3.2.8_cheyenne_Intel17.0.1_MPI_openMP
     ```

3. Build pFUnit:

```
     mkdir build
     cd build
     cmake -DMPI=YES -DOPENMP=YES ..
     make -j 4
```

4. Run pFUnit's own unit tests:

```
     make tests
```

   Note: this didn't work on yellowstone. Instead, I had to do it by hand:

```
     DAV_CORES=4 execca
     mpirun.lsf tests/tests.x
```

5. Install pFUnit on your system:

```
     make install INSTALL_DIR=$PFUNIT
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/lib/CIME/BuildTools/cmakemacroswriter.py`
Content:
```
1 """Classes used to write build system files.
2 
3 The classes here are used to write out settings for use by Makefile and CMake
4 build systems. The two relevant classes are CMakeMacroWriter and
5 MakeMacroWriter, which encapsulate the information necessary to write CMake and
6 Makefile formatted text, respectively. See the docstrings for those classes for
7 more.
8 """
9 
10 # This is not the most useful check.
11 # pylint: disable=invalid-name
12 
13 from CIME.BuildTools.macrowriterbase import MacroWriterBase
14 from CIME.XML.standard_module_setup import *
15 logger = logging.getLogger(__name__)
16 
17 
18 class CMakeMacroWriter(MacroWriterBase):
19 
20     """Macro writer for the CMake format.
21 
22     For details on the provided methods, see MacroWriterBase, which this
23     class inherits from.
24     """
25 
26     def __init__(self, output):
27         """Initialize a CMake macro writer.
28 
29         Arguments:
30         output - File-like object (probably an io.TextIOWrapper), which
31                  will be written to.
32         """
33         super(CMakeMacroWriter, self).__init__(output)
34         # This counter is for avoiding name conflicts in temporary
35         # variables used for shell commands.
36         self._var_num = 0
37 
38     def environment_variable_string(self, name):
39         """Return an environment variable reference.
40 
41         >>> import io
42         >>> s = io.StringIO()
43         >>> CMakeMacroWriter(s).environment_variable_string("foo")
44         '$ENV{foo}'
45         """
46         return "$ENV{" + name + "}"
47 
48     def shell_command_strings(self, command):
49         # pylint: disable=line-too-long
50         """Return strings used to get the output of a shell command.
51 
52         >>> import io
53         >>> s = io.StringIO()
54         >>> set_up, inline, tear_down = CMakeMacroWriter(s).shell_command_strings("echo bar")
55         >>> set_up
56         'execute_process(COMMAND echo bar OUTPUT_VARIABLE CIME_TEMP_SHELL0 OUTPUT_STRIP_TRAILING_WHITESPACE)'
57         >>> inline
58         '${CIME_TEMP_SHELL0}'
59         >>> tear_down
60         'unset(CIME_TEMP_SHELL0)'
61         """
62         # pylint: enable=line-too-long
63         # Create a unique variable name, then increment variable number
64         # counter so that we get a different value next time.
65         var_name = "CIME_TEMP_SHELL" + str(self._var_num)
66         self._var_num += 1
67         set_up = "execute_process(COMMAND " + command + \
68                  " OUTPUT_VARIABLE " + var_name + \
69                  " OUTPUT_STRIP_TRAILING_WHITESPACE)"
70         tear_down = "unset(" + var_name + ")"
71         return (set_up, "${" + var_name + "}", tear_down)
72 
73     def variable_string(self, name):
74         """Return a string to refer to a variable with the given name.
75 
76         >>> import io
77         >>> s = io.StringIO()
78         >>> CMakeMacroWriter(s).variable_string("foo")
79         '${foo}'
80         """
81         return "${" + name + "}"
82 
83     def set_variable(self, name, value):
84         """Write out a statement setting a variable to some value.
85 
86         >>> import io
87         >>> s = io.StringIO()
88         >>> CMakeMacroWriter(s).set_variable("foo", "bar")
89         >>> s.getvalue()
90         u'set(foo "bar")\\n'
91         """
92         self.write_line("set(" + name + ' "' + value + '")')
93 
94     def start_ifeq(self, left, right):
95         """Write out a statement to start a conditional block.
96 
97         >>> import io
98         >>> s = io.StringIO()
99         >>> CMakeMacroWriter(s).start_ifeq("foo", "bar")
100         >>> s.getvalue()
101         u'if("foo" STREQUAL "bar")\\n'
102         """
103         self.write_line('if("' + left + '" STREQUAL "' + right + '")')
104         self.indent_right()
105 
106     def end_ifeq(self):
107         """Write out a statement to end a block started with start_ifeq.
108 
109         >>> import io
110         >>> s = io.StringIO()
111         >>> writer = CMakeMacroWriter(s)
112         >>> writer.start_ifeq("foo", "bar")
113         >>> writer.set_variable("foo2", "bar2")
114         >>> writer.end_ifeq()
115         >>> s.getvalue()
116         u'if("foo" STREQUAL "bar")\\n  set(foo2 "bar2")\\nendif()\\n'
117         """
118         self.indent_left()
119         self.write_line("endif()")
120
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scripts/lib/CIME/BuildTools/cmakemacroswriter.py b/scripts/lib/CIME/BuildTools/cmakemacroswriter.py
--- a/scripts/lib/CIME/BuildTools/cmakemacroswriter.py
+++ b/scripts/lib/CIME/BuildTools/cmakemacroswriter.py
@@ -89,7 +89,8 @@
         >>> s.getvalue()
         u'set(foo "bar")\\n'
         """
-        self.write_line("set(" + name + ' "' + value + '")')
+        value_transformed = self._transform_value(value)
+        self.write_line("set(" + name + ' "' + value_transformed + '")')
 
     def start_ifeq(self, left, right):
         """Write out a statement to start a conditional block.
@@ -117,3 +118,22 @@
         """
         self.indent_left()
         self.write_line("endif()")
+
+    def _transform_value(self, value):
+        """Some elements need their values transformed in some way for CMake to handle them properly.
+        This method does those transformations.
+
+        Args:
+        - value (str): value of element
+
+        Returns transformed value
+        """
+
+        # Not all variables need leading & trailing whitespace removed, but some
+        # do. In particular, compiler variables (MPICC, MPICXX, MPIFC, SCC,
+        # SCXX, SFC) are only handled correctly if leading & trailing whitespace
+        # is removed. It doesn't seem to hurt to remove whitespace from all
+        # variables.
+        value_transformed = value.strip()
+
+        return value_transformed

{"golden_diff": "diff --git a/scripts/lib/CIME/BuildTools/cmakemacroswriter.py b/scripts/lib/CIME/BuildTools/cmakemacroswriter.py\n--- a/scripts/lib/CIME/BuildTools/cmakemacroswriter.py\n+++ b/scripts/lib/CIME/BuildTools/cmakemacroswriter.py\n@@ -89,7 +89,8 @@\n         >>> s.getvalue()\n         u'set(foo \"bar\")\\\\n'\n         \"\"\"\n-        self.write_line(\"set(\" + name + ' \"' + value + '\")')\n+        value_transformed = self._transform_value(value)\n+        self.write_line(\"set(\" + name + ' \"' + value_transformed + '\")')\n \n     def start_ifeq(self, left, right):\n         \"\"\"Write out a statement to start a conditional block.\n@@ -117,3 +118,22 @@\n         \"\"\"\n         self.indent_left()\n         self.write_line(\"endif()\")\n+\n+    def _transform_value(self, value):\n+        \"\"\"Some elements need their values transformed in some way for CMake to handle them properly.\n+        This method does those transformations.\n+\n+        Args:\n+        - value (str): value of element\n+\n+        Returns transformed value\n+        \"\"\"\n+\n+        # Not all variables need leading & trailing whitespace removed, but some\n+        # do. In particular, compiler variables (MPICC, MPICXX, MPIFC, SCC,\n+        # SCXX, SFC) are only handled correctly if leading & trailing whitespace\n+        # is removed. It doesn't seem to hurt to remove whitespace from all\n+        # variables.\n+        value_transformed = value.strip()\n+\n+        return value_transformed\n", "issue": "Build pFUnit on some other machines\nWe should build pFUnit on some other machines so we can run unit tests there:\r\n\r\n- cheyenne\r\n- hobart\r\n\r\nInstructions for building pFUnit are:\r\n\r\n1. Download pFUnit from\r\n   http://sourceforge.net/projects/pfunit/files/latest/download\r\n\r\n2. Set the PFUNIT environment variable. For example::\r\n\r\n     ```\r\n     export PFUNIT=/glade/p/cesmdata/cseg/tools/pFUnit/pFUnit3.2.8_cheyenne_Intel17.0.1_MPI_openMP\r\n     ```\r\n\r\n3. Build pFUnit:\r\n\r\n```\r\n     mkdir build\r\n     cd build\r\n     cmake -DMPI=YES -DOPENMP=YES ..\r\n     make -j 4\r\n```\r\n\r\n4. Run pFUnit's own unit tests:\r\n\r\n```\r\n     make tests\r\n```\r\n\r\n   Note: this didn't work on yellowstone. Instead, I had to do it by hand:\r\n\r\n```\r\n     DAV_CORES=4 execca\r\n     mpirun.lsf tests/tests.x\r\n```\r\n\r\n5. Install pFUnit on your system:\r\n\r\n```\r\n     make install INSTALL_DIR=$PFUNIT\r\n```\n", "before_files": [{"content": "\"\"\"Classes used to write build system files.\n\nThe classes here are used to write out settings for use by Makefile and CMake\nbuild systems. The two relevant classes are CMakeMacroWriter and\nMakeMacroWriter, which encapsulate the information necessary to write CMake and\nMakefile formatted text, respectively. See the docstrings for those classes for\nmore.\n\"\"\"\n\n# This is not the most useful check.\n# pylint: disable=invalid-name\n\nfrom CIME.BuildTools.macrowriterbase import MacroWriterBase\nfrom CIME.XML.standard_module_setup import *\nlogger = logging.getLogger(__name__)\n\n\nclass CMakeMacroWriter(MacroWriterBase):\n\n    \"\"\"Macro writer for the CMake format.\n\n    For details on the provided methods, see MacroWriterBase, which this\n    class inherits from.\n    \"\"\"\n\n    def __init__(self, output):\n        \"\"\"Initialize a CMake macro writer.\n\n        Arguments:\n        output - File-like object (probably an io.TextIOWrapper), which\n                 will be written to.\n        \"\"\"\n        super(CMakeMacroWriter, self).__init__(output)\n        # This counter is for avoiding name conflicts in temporary\n        # variables used for shell commands.\n        self._var_num = 0\n\n    def environment_variable_string(self, name):\n        \"\"\"Return an environment variable reference.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).environment_variable_string(\"foo\")\n        '$ENV{foo}'\n        \"\"\"\n        return \"$ENV{\" + name + \"}\"\n\n    def shell_command_strings(self, command):\n        # pylint: disable=line-too-long\n        \"\"\"Return strings used to get the output of a shell command.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> set_up, inline, tear_down = CMakeMacroWriter(s).shell_command_strings(\"echo bar\")\n        >>> set_up\n        'execute_process(COMMAND echo bar OUTPUT_VARIABLE CIME_TEMP_SHELL0 OUTPUT_STRIP_TRAILING_WHITESPACE)'\n        >>> inline\n        '${CIME_TEMP_SHELL0}'\n        >>> tear_down\n        'unset(CIME_TEMP_SHELL0)'\n        \"\"\"\n        # pylint: enable=line-too-long\n        # Create a unique variable name, then increment variable number\n        # counter so that we get a different value next time.\n        var_name = \"CIME_TEMP_SHELL\" + str(self._var_num)\n        self._var_num += 1\n        set_up = \"execute_process(COMMAND \" + command + \\\n                 \" OUTPUT_VARIABLE \" + var_name + \\\n                 \" OUTPUT_STRIP_TRAILING_WHITESPACE)\"\n        tear_down = \"unset(\" + var_name + \")\"\n        return (set_up, \"${\" + var_name + \"}\", tear_down)\n\n    def variable_string(self, name):\n        \"\"\"Return a string to refer to a variable with the given name.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).variable_string(\"foo\")\n        '${foo}'\n        \"\"\"\n        return \"${\" + name + \"}\"\n\n    def set_variable(self, name, value):\n        \"\"\"Write out a statement setting a variable to some value.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).set_variable(\"foo\", \"bar\")\n        >>> s.getvalue()\n        u'set(foo \"bar\")\\\\n'\n        \"\"\"\n        self.write_line(\"set(\" + name + ' \"' + value + '\")')\n\n    def start_ifeq(self, left, right):\n        \"\"\"Write out a statement to start a conditional block.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).start_ifeq(\"foo\", \"bar\")\n        >>> s.getvalue()\n        u'if(\"foo\" STREQUAL \"bar\")\\\\n'\n        \"\"\"\n        self.write_line('if(\"' + left + '\" STREQUAL \"' + right + '\")')\n        self.indent_right()\n\n    def end_ifeq(self):\n        \"\"\"Write out a statement to end a block started with start_ifeq.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> writer = CMakeMacroWriter(s)\n        >>> writer.start_ifeq(\"foo\", \"bar\")\n        >>> writer.set_variable(\"foo2\", \"bar2\")\n        >>> writer.end_ifeq()\n        >>> s.getvalue()\n        u'if(\"foo\" STREQUAL \"bar\")\\\\n  set(foo2 \"bar2\")\\\\nendif()\\\\n'\n        \"\"\"\n        self.indent_left()\n        self.write_line(\"endif()\")\n", "path": "scripts/lib/CIME/BuildTools/cmakemacroswriter.py"}], "after_files": [{"content": "\"\"\"Classes used to write build system files.\n\nThe classes here are used to write out settings for use by Makefile and CMake\nbuild systems. The two relevant classes are CMakeMacroWriter and\nMakeMacroWriter, which encapsulate the information necessary to write CMake and\nMakefile formatted text, respectively. See the docstrings for those classes for\nmore.\n\"\"\"\n\n# This is not the most useful check.\n# pylint: disable=invalid-name\n\nfrom CIME.BuildTools.macrowriterbase import MacroWriterBase\nfrom CIME.XML.standard_module_setup import *\nlogger = logging.getLogger(__name__)\n\n\nclass CMakeMacroWriter(MacroWriterBase):\n\n    \"\"\"Macro writer for the CMake format.\n\n    For details on the provided methods, see MacroWriterBase, which this\n    class inherits from.\n    \"\"\"\n\n    def __init__(self, output):\n        \"\"\"Initialize a CMake macro writer.\n\n        Arguments:\n        output - File-like object (probably an io.TextIOWrapper), which\n                 will be written to.\n        \"\"\"\n        super(CMakeMacroWriter, self).__init__(output)\n        # This counter is for avoiding name conflicts in temporary\n        # variables used for shell commands.\n        self._var_num = 0\n\n    def environment_variable_string(self, name):\n        \"\"\"Return an environment variable reference.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).environment_variable_string(\"foo\")\n        '$ENV{foo}'\n        \"\"\"\n        return \"$ENV{\" + name + \"}\"\n\n    def shell_command_strings(self, command):\n        # pylint: disable=line-too-long\n        \"\"\"Return strings used to get the output of a shell command.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> set_up, inline, tear_down = CMakeMacroWriter(s).shell_command_strings(\"echo bar\")\n        >>> set_up\n        'execute_process(COMMAND echo bar OUTPUT_VARIABLE CIME_TEMP_SHELL0 OUTPUT_STRIP_TRAILING_WHITESPACE)'\n        >>> inline\n        '${CIME_TEMP_SHELL0}'\n        >>> tear_down\n        'unset(CIME_TEMP_SHELL0)'\n        \"\"\"\n        # pylint: enable=line-too-long\n        # Create a unique variable name, then increment variable number\n        # counter so that we get a different value next time.\n        var_name = \"CIME_TEMP_SHELL\" + str(self._var_num)\n        self._var_num += 1\n        set_up = \"execute_process(COMMAND \" + command + \\\n                 \" OUTPUT_VARIABLE \" + var_name + \\\n                 \" OUTPUT_STRIP_TRAILING_WHITESPACE)\"\n        tear_down = \"unset(\" + var_name + \")\"\n        return (set_up, \"${\" + var_name + \"}\", tear_down)\n\n    def variable_string(self, name):\n        \"\"\"Return a string to refer to a variable with the given name.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).variable_string(\"foo\")\n        '${foo}'\n        \"\"\"\n        return \"${\" + name + \"}\"\n\n    def set_variable(self, name, value):\n        \"\"\"Write out a statement setting a variable to some value.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).set_variable(\"foo\", \"bar\")\n        >>> s.getvalue()\n        u'set(foo \"bar\")\\\\n'\n        \"\"\"\n        value_transformed = self._transform_value(value)\n        self.write_line(\"set(\" + name + ' \"' + value_transformed + '\")')\n\n    def start_ifeq(self, left, right):\n        \"\"\"Write out a statement to start a conditional block.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> CMakeMacroWriter(s).start_ifeq(\"foo\", \"bar\")\n        >>> s.getvalue()\n        u'if(\"foo\" STREQUAL \"bar\")\\\\n'\n        \"\"\"\n        self.write_line('if(\"' + left + '\" STREQUAL \"' + right + '\")')\n        self.indent_right()\n\n    def end_ifeq(self):\n        \"\"\"Write out a statement to end a block started with start_ifeq.\n\n        >>> import io\n        >>> s = io.StringIO()\n        >>> writer = CMakeMacroWriter(s)\n        >>> writer.start_ifeq(\"foo\", \"bar\")\n        >>> writer.set_variable(\"foo2\", \"bar2\")\n        >>> writer.end_ifeq()\n        >>> s.getvalue()\n        u'if(\"foo\" STREQUAL \"bar\")\\\\n  set(foo2 \"bar2\")\\\\nendif()\\\\n'\n        \"\"\"\n        self.indent_left()\n        self.write_line(\"endif()\")\n\n    def _transform_value(self, value):\n        \"\"\"Some elements need their values transformed in some way for CMake to handle them properly.\n        This method does those transformations.\n\n        Args:\n        - value (str): value of element\n\n        Returns transformed value\n        \"\"\"\n\n        # Not all variables need leading & trailing whitespace removed, but some\n        # do. In particular, compiler variables (MPICC, MPICXX, MPIFC, SCC,\n        # SCXX, SFC) are only handled correctly if leading & trailing whitespace\n        # is removed. It doesn't seem to hurt to remove whitespace from all\n        # variables.\n        value_transformed = value.strip()\n\n        return value_transformed\n", "path": "scripts/lib/CIME/BuildTools/cmakemacroswriter.py"}]}