Skip to content

Commit

Permalink
Fix update_baseline.sh to restore the original branch after updating …
Browse files Browse the repository at this point in the history
…the baseline. (#2565)
  • Loading branch information
domchen authored Nov 5, 2024
1 parent 0082e48 commit e8a4f6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions autotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ WORKSPACE=$(pwd)

cd $WORKSPACE

make_dir result
make_dir build

./update_baseline.sh 1
if test $? -ne 0; then
exit 1
fi
cp -r $WORKSPACE/test/baseline $WORKSPACE/result

make_dir result
make_dir build
cd build

cmake -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -g -O0" -DPAG_USE_SWIFTSHADER=ON -DPAG_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug ../
Expand Down
5 changes: 2 additions & 3 deletions test/src/utils/Baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ void Baseline::saveData() {
outMD5File << std::setw(4) << outputMD5 << std::endl;
outMD5File.close();
CreateFolder(cacheVersionPath);
std::ofstream outVersionFile(cacheVersionPath);
outVersionFile << std::setw(4) << baselineVersions << std::endl;
outVersionFile.close();
std::filesystem::copy(baselineVersionPath, cacheVersionPath,
std::filesystem::copy_options::overwrite_existing);
}
#else
std::filesystem::remove(outMD5Path);
Expand Down
7 changes: 6 additions & 1 deletion update_baseline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
fi
echo "~~~~~~~~~~~~~~~~~~~Update Baseline Start~~~~~~~~~~~~~~~~~~~~~"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT_COMMIT=$(git rev-parse HEAD)
STASH_LIST_BEFORE=$(git stash list)
git stash push --quiet
STASH_LIST_AFTER=$(git stash list)
Expand Down Expand Up @@ -59,7 +60,11 @@

cd ..

git switch $CURRENT_BRANCH --quiet
if [[ $CURRENT_BRANCH == "HEAD" ]]; then
git checkout $CURRENT_COMMIT --quiet
else
git switch $CURRENT_BRANCH --quiet
fi
if [[ $STASH_LIST_BEFORE != "$STASH_LIST_AFTER" ]]; then
git stash pop --index --quiet
fi
Expand Down

0 comments on commit e8a4f6d

Please sign in to comment.