# How to upgrade GoogleTest?

**URL:** https://discourse.itk.org/t/how-to-upgrade-googletest/2477
**Category:** Engineering
**Created:** [December 5, 2019, 4:14pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477 "2019-12-05T16:14:45Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 5, 2019, 4:14pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/1 "2019-12-05T16:14:45Z")

</div>

ITK has quite an old version of GoogleTest. The last update appears to be two years ago, by Francois Budin @fbudin:

> <https://github.com/InsightSoftwareConsortium/ITK/commit/68960a05483bff2cbe339d524e272e557b926c41>

This old version of GoogleTest produces some static analysis warnings (like "warning C26477: Use ‘nullptr’) that are solved by now.

Could ITK’s GoogleTest be upgraded from the old master revision to the latest tagged release, [https://github.com/google/googletest/releases/tag/release-1.10.0](https://github.com/google/googletest/releases/tag/release-1.10.0) ?

I tried so by running `./UpdateFromUpstream.sh` from Windows GitBash, but now my local clone is full of conflicts 😢

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 5, 2019, 4:30pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/2 "2019-12-05T16:30:04Z")

</div>

$ ./UpdateFromUpstream.sh  
Created upstream snapshot branch ‘upstream-googletest’.  
Performing inexact rename detection: 100% (666708/666708), done.  
CONFLICT (file location): googletest/src/gtest-matchers.cc added in upstream-googletest inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/src/gtest-matchers.cc.  
CONFLICT (rename/delete): googletest/include/gtest/internal/gtest-tuple.h.pump deleted in upstream-googletest and renamed to Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-tuple.h.pump in HEAD. Version HEAD of Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-tuple.h.pump left in tree.  
…  
CONFLICT (content): Merge conflict in Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt  
Auto-merging CMakeLists.txt  
CONFLICT (content): Merge conflict in CMakeLists.txt  
Automatic merge failed; fix conflicts and then commit the result.  
error: The branch ‘upstream-googletest’ is not fully merged.  
If you are sure you want to delete it, run ‘git branch -D upstream-googletest’.

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK/Modules/ThirdParty/GoogleTest (master|MERGING)  
$

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [December 5, 2019, 4:45pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/3 "2019-12-05T16:45:31Z")

</div>

@Niels_Dekker thanks for upgrading our Google Test! 👏 🙏

Try running `UpdateFromUpstream.sh` from the top level of the repository, i.e.

```auto
cd ITK
git checkout -b googletest-update
 ./Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh

```

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 5, 2019, 5:02pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/4 "2019-12-05T17:02:44Z")

</div>

Thanks for your encouragement, Matt. Unfortunately, even when following your recipe, I still get:

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (master)  
$ git checkout -b googletest-update  
Switched to a new branch ‘googletest-update’  
M Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (googletest-update)  
$ ./Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh  
Created upstream snapshot branch ‘upstream-googletest’.  
Performing inexact rename detection: 100% (666708/666708), done.  
CONFLICT (file location): googletest/src/gtest-matchers.cc added in upstream-googletest inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/src/gtest-matchers.cc.  
…  
CONFLICT (content): Merge conflict in CMakeLists.txt  
Automatic merge failed; fix conflicts and then commit the result.  
error: The branch ‘upstream-googletest’ is not fully merged.  
If you are sure you want to delete it, run ‘git branch -D upstream-googletest’.

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (googletest-update|MERGING)  
$

Do you have a clue?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 5, 2019, 5:12pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/5 "2019-12-05T17:12:00Z")

</div>

I think @blowekamp was involved with initial addition of Google Test to ITK. He might have more information.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [December 5, 2019, 5:17pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/6 "2019-12-05T17:17:37Z")

</div>

> [@Niels\_Dekker](#):
>
> M Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh

This indicates that this file was modified locally – it may help to start from a fresh Git repository clone.

When I run the script locally, the result is:

```auto
❯ ./Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh
Created upstream snapshot branch 'upstream-googletest'.
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-type-util.h.pump
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-tuple.h.pump
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-tuple.h
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-param-util-generated.h
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/internal/gtest-linked_ptr.h
Removing
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/include/gtest/gtest-param-test.h.pump
Auto-merging
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt
CONFLICT (content): Merge conflict in
Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt
Auto-merging Modules/ThirdParty/GoogleTest/src/itkgoogletest/CMakeLists.txt
CONFLICT (content): Merge conflict in
Modules/ThirdParty/GoogleTest/src/itkgoogletest/CMakeLists.txt
Automatic merge failed; fix conflicts and then commit the result.
error: The branch 'upstream-googletest' is not fully merged.
If you are sure you want to delete it, run 'git branch -D
upstream-googletest'.

```

In this case, there are two files that have merge conflicts, which is reasonable.

What git version do you have? I tested with 2.22.0.

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 5, 2019, 5:47pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/7 "2019-12-05T17:47:23Z")

</div>

> [@matt.mccormick](#):
>
> What git version do you have? I tested with 2.22.0.

```
$ git --version
git version 2.22.0.windows.1

```

Going home now, hopefully tomorrow another try!

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 5, 2019, 9:35pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/8 "2019-12-05T21:35:59Z")

</div>

> [@matt.mccormick](#):
>
> > M Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh
> 
> This indicates that this file was modified locally

Sure it is! I changed `upstream_git_branch='master'` to `upstream_git_branch='release-1.10.0'`, in [UpdateFromUpstream.sh](https://github.com/InsightSoftwareConsortium/ITK/blob/v5.1b01/Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh#L6), in order to get [the latest tagged release of GoogleTest](https://github.com/google/googletest/releases/tag/release-1.10.0). Should that work well, or am I doing something wrong?

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [December 5, 2019, 10:06pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/9 "2019-12-05T22:06:26Z")

</div>

> [@Niels\_Dekker](#):
>
> `upstream_git_branch='master'` to `upstream_git_branch='release-1.10.0'`

Maybe try `v1.10.x` to get the [branch](https://github.com/google/googletest/tree/v1.10.x) instead of the tag.

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 6, 2019, 11:39am UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/10 "2019-12-06T11:39:46Z")

</div>

Update: I just made a new fork (removing my old one), did a new clone, and did the two instructions you suggested in GitBash. It still produces merge conflicts. Do you have any more suggestion? It says now:

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (master)  
**$ git checkout -b googletest-update**  
Switched to a new branch ‘googletest-update’

cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (googletest-update)  
**$ ./Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh**  
Created upstream snapshot branch ‘upstream-googletest’.  
Performing inexact rename detection: 100% (666708/666708), done.  
CONFLICT (file location): googletest/src/gtest-matchers.cc added in upstream-googletest inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/src/gtest-matchers.cc.  
…  
Auto-merging Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt  
CONFLICT (content): Merge conflict in Modules/ThirdParty/GoogleTest/src/itkgoogletest/googletest/CMakeLists.txt  
Auto-merging CMakeLists.txt  
CONFLICT (content): Merge conflict in CMakeLists.txt  
Automatic merge failed; fix conflicts and then commit the result.  
error: The branch ‘upstream-googletest’ is not fully merged.  
If you are sure you want to delete it, run ‘git branch -D upstream-googletest’.

**cedekker@2-lkeb-17-nde1 MINGW64 /f/X/Src/I/ITK (googletest-update|MERGING)**

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [December 6, 2019, 12:16pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/11 "2019-12-06T12:16:22Z")

</div>

Those are the conflicts I got too. And the got log indicates those are local changes.

Try doing the update on the old commit where the library was last updated then merging master into the updated branch.

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 6, 2019, 12:30pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/12 "2019-12-06T12:30:18Z")

</div>

Thanks for confirming those conflicts, @blowekamp Sorry but git/shell scripting is not my best talent. Could you please try to get it to work, and make the pull request to upgrade GoogleTest? Or is anyone else volunteering? 😃

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [December 11, 2019, 3:57pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/13 "2019-12-11T15:57:32Z")

</div>

Done:

> <https://github.com/InsightSoftwareConsortium/ITK/pull/1487>

The local changes were to support VS 20012 and CMP00063. I reverted to “their” changes.

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 11, 2019, 4:09pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/14 "2019-12-11T16:09:39Z")

</div>

That’s really great, Bradley! ☀ So how did you avoid (or fix) the git merge conflicts that I got, when i tried to do it?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 11, 2019, 6:04pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/15 "2019-12-11T18:04:52Z")

</div>

> [@blowekamp](#):
>
> I reverted to “their” changes.

Did you not notice this explanation?

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [December 11, 2019, 6:16pm UTC](https://discourse.itk.org/t/how-to-upgrade-googletest/2477/16 "2019-12-11T18:16:36Z")

</div>

> [@dzenanz](#):
>
> Did you not notice this explanation?

I guess I did not read carefully enough 😺 Hopefully future ITK GoogleTest upgrades will be easier than this one! [GoogleTest v1.10.0 by blowekamp · Pull Request #1487 · InsightSoftwareConsortium/ITK · GitHub](https://github.com/InsightSoftwareConsortium/ITK/pull/1487) still says “This branch cannot be rebased due to conflicts”, is that a problem? Well, we’ll see…!
