Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CR] Test order randomization using a focused set of tests #47791

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b290f88
Give more weary info; calories a bit less
actual-nh Jan 19, 2021
c4ab6b2
Revert calories; prevent summary linewrapping
actual-nh Jan 19, 2021
bdd942b
Start testing for unrealistic weary fluctuations
actual-nh Feb 6, 2021
49fc687
Add further weariness fluctuation testing
actual-nh Feb 10, 2021
7b82317
Adjust weary test output for readability
actual-nh Feb 10, 2021
f37d217
Make earlier commit actually work.
actual-nh Feb 10, 2021
db03ee5
Smooth out weary intake/tracker a bit
actual-nh Feb 11, 2021
028b0f0
Adjust for smoothing weary intake/tracker
actual-nh Feb 11, 2021
45b1139
Temporarily allow expected failures on 2 tests.
actual-nh Feb 12, 2021
ab4ba67
Smoothen weary tracker+intake reductions
actual-nh Feb 18, 2021
c01a661
Check on weary ticks.
actual-nh Feb 18, 2021
5d9dcb2
Make weary.tracker reduction happen every time
actual-nh Feb 20, 2021
c68507b
Adjust tests for smoother weary.tracker
actual-nh Feb 20, 2021
ec5a176
Start testing for unrealistic weary fluctuations
actual-nh Feb 6, 2021
d12b85d
Add further weariness fluctuation testing
actual-nh Feb 10, 2021
5790b15
Smooth out weary intake/tracker a bit
actual-nh Feb 11, 2021
098fa14
Adjust for smoothing weary intake/tracker
actual-nh Feb 11, 2021
fbab5d0
Smoothen weary tracker+intake reductions
actual-nh Feb 18, 2021
20844a8
Make weary.tracker reduction happen every time
actual-nh Feb 20, 2021
18f3520
Adjust tests for smoother weary.tracker
actual-nh Feb 20, 2021
08bb1f3
Allow for 2 fluctuations not fixed yet
actual-nh Feb 21, 2021
e6e294e
Add another clear_avatar() to weary_24h_tests
actual-nh Feb 21, 2021
b2c8072
Test with recent fixes.
actual-nh Feb 23, 2021
0ded893
Remove have_weary_increase()
actual-nh Feb 25, 2021
9d9b20a
Setup for focused, random order tests
actual-nh Feb 27, 2021
a8565b9
Get info, weary.tracker/.intake, test alterations. Merge branch 'catc…
actual-nh Feb 27, 2021
06d3bc6
For comparisons - Merge branch 'master' of https://github.com/CleverR…
actual-nh Feb 27, 2021
850c2cf
Not allow one of the weary test groups to fail
actual-nh Feb 27, 2021
81cecb4
Limit tests, compilations run (latter to compensate for fast-fail: fa…
actual-nh Feb 21, 2021
f145b92
Set max-parallel to 2 in matrix.yml
actual-nh Feb 28, 2021
abec734
Remove two weary fluctuation tests
actual-nh Feb 28, 2021
befc1cd
Remove 2 on_load tests from expanded testing
actual-nh Mar 1, 2021
7b39466
Remove 3 slow tests.
actual-nh Mar 1, 2021
0c07a3e
Merge branch 'master' of https://github.com/CleverRaven/Cataclysm-DDA…
actual-nh Mar 1, 2021
d76d6d5
Attempt to disable LGTM checks from running.
actual-nh Mar 1, 2021
28dba51
Revert "Attempt to disable LGTM checks from running."
actual-nh Mar 1, 2021
3cf807a
Add coreutils to homebrew downloads
actual-nh Mar 1, 2021
be46dbf
Get all durations, plus for weary all output
actual-nh Mar 1, 2021
4d0e2a8
Update before doing alterations - Merge branch 'master' of https://gi…
actual-nh Mar 1, 2021
d4655f5
Set same expected values for init 8 hours digging
actual-nh Mar 1, 2021
4bf025a
Set same expected values for init 8 hours digging
actual-nh Mar 1, 2021
e445990
Change expected values for 12 and 24-hour digging
actual-nh Mar 2, 2021
e42c140
Change expected values for 12 and 24-hour digging
actual-nh Mar 2, 2021
38ce95a
Check on seed vs build environment effects
actual-nh Mar 3, 2021
3f71e4f
Put back in SDL for Linux
actual-nh Mar 3, 2021
79aceff
Fix error resulting in no shared seed on Travis
actual-nh Mar 3, 2021
a851293
Avoiding errors due to branch/patch mismatch - Merge branch 'master' …
actual-nh Mar 5, 2021
d9c0a37
Add more information to debug_weary_info
actual-nh Mar 6, 2021
29935d3
Add stomach, gut kcal info to weary transitions
actual-nh Mar 7, 2021
fde2b48
Make it easier to look through the logs
actual-nh Mar 9, 2021
f366e3c
Get around merge conflicts on github - Merge branch 'master' of https…
actual-nh Mar 9, 2021
3f1fabb
Use commit SHA modulo 1000000000 as seed
actual-nh Mar 9, 2021
998fa1c
See if TRAVIS_COMMIT is the right SHA hash
actual-nh Mar 9, 2021
e11fcc4
Make sure it's floating-point division
actual-nh Mar 16, 2021
a0e00b7
Make sure it's floating-point division
actual-nh Mar 16, 2021
0b693c2
Make sure it's floating-point division
actual-nh Mar 16, 2021
4aa85ad
Make sure it's floating-point division
actual-nh Mar 16, 2021
d052801
Update with newest changes (prevent mismatch): Merge branch 'master' …
actual-nh Mar 17, 2021
cfe3aca
Make sure branch is properly based for testing - Merge branch 'master…
actual-nh Mar 17, 2021
b5641ec
Solve merge conflicts - Merge branch 'master' of https://github.com/C…
actual-nh Apr 1, 2021
139b4c5
Remember to include <cmath> for C++ math funcs
actual-nh Apr 1, 2021
a1aeb0d
Merge branch 'weariness_fluctuations_1' into weariness_order
actual-nh Apr 1, 2021
5a229a8
Didn't notice one conflict.
actual-nh Apr 1, 2021
d0f88b1
Fail-fast on; mayfail for weary; per-run seeds
actual-nh Apr 1, 2021
c26ab47
Remove 2 of 5 github checks - speed up
actual-nh Apr 1, 2021
f275826
Fix not noticing need to change %d to %s...
actual-nh Apr 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .appveyor.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .github/workflows/CBA.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .github/workflows/clang-tidy.yml

This file was deleted.

39 changes: 12 additions & 27 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,28 @@ on:
jobs:
varied_builds:
strategy:
max-parallel: 3
matrix:
include:
- compiler: g++-9
os: ubuntu-latest
- compiler: clang++
os: macos-10.15
cmake: 0
tiles: 0
test-stage: 1
native: linux64
gold: 1
lto: 1
title: GCC 9, Ubuntu, Curses, LTO
tiles: 1
native: osx
title: Clang 12, macOS 10.15, Tiles
- compiler: g++-7
os: ubuntu-latest
cmake: 1
tiles: 1
native: linux64
title: GCC 7, Ubuntu, Tiles, CMake
- compiler: g++-8
os: ubuntu-latest
cmake: 0
tiles: 1
sanitize: address
native: linux64
title: GCC 8, Ubuntu, Tiles, ASan
- compiler: clang++-9
title: GCC 7, Ubuntu, CMake, Tiles
- compiler: g++-9
os: ubuntu-latest
cmake: 0
tiles: 1
sanitize: address,undefined
tiles: 0
test-stage: 1
native: linux64
title: Clang 9, Ubuntu, Tiles, ASan, UBSan
- compiler: clang++
os: macos-10.15
cmake: 0
tiles: 1
native: osx
title: Clang 12, macOS 10.15, Tiles
title: GCC 9, Ubuntu, Curses
name: ${{ matrix.title }}
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -100,7 +85,7 @@ jobs:
- name: install dependencies (mac)
if: runner.os == 'macOS'
run: |
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel coreutils
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: Get Date
Expand Down
36 changes: 19 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ branches:
jobs:
include:
# Initial test stage, if this fails everything else is canceled.
- stage: Test
- stage: Test plus platforms
# Clang is consistently the fastest to build, so use it for the initial test.
env: CLANG=clang++-3.8 TEST_STAGE=1 CXXFLAGS="-Wno-error=unused-command-line-argument -D__extern_always_inline='extern __always_inline'"
name: "Clang 3.8 Make build with curses and style check"
Expand All @@ -65,6 +65,21 @@ jobs:
packages: ["clang-3.8"]
sources: [*apt_sources]

# MXE variant using alternate repository http://mirror.mxe.cc/repos/apt
- env: COMPILER=g++ LDFLAGS="-static-libgcc -static-libstdc++" MXE_TARGET="i686-w64-mingw32.static" WINE="wine" TILES=1 SOUND=1
name: "Mingw-w64 Make cross-compile to Windows with Tiles and Sound"
compiler: gcc
addons: &gcc
apt:
packages: ["wine"]

- env: CLANG=clang++ OSX_MIN=10.13 TILES=1 SOUND=1
name: "Xcode 10.2 Make build with Tiles and sound (macOS)"
os: osx
osx_image: xcode10.2
compiler: clang


# Then build different configurations and targets in parallel.
- stage: "Main Compilers"
env: COMPILER=g++ MODS=--mods=magiclysm LOCALIZE=0
Expand Down Expand Up @@ -96,17 +111,10 @@ jobs:
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

- stage: "Platforms and Tidy"
# MXE variant using alternate repository http://mirror.mxe.cc/repos/apt
env: COMPILER=g++ LDFLAGS="-static-libgcc -static-libstdc++" MXE_TARGET="i686-w64-mingw32.static" WINE="wine" TILES=1 SOUND=1
name: "Mingw-w64 Make cross-compile to Windows with Tiles and Sound"
compiler: gcc
addons: &gcc
apt:
packages: ["wine"]

- env: NATIVE=android COMPILER=gcc
- stage: "Platforms"
env: NATIVE=android COMPILER=gcc
name: "Android build"
if: type != pull_request
language: android
android:
components:
Expand All @@ -118,12 +126,6 @@ jobs:
directories:
- $HOME/.ccache

- env: CLANG=clang++ OSX_MIN=10.13 TILES=1 SOUND=1
name: "Xcode 10.2 Make build with Tiles and sound (macOS)"
os: osx
osx_image: xcode10.2
compiler: clang

# Finally check the compiler variants
- stage: compilers
# GCC 5.4 is default on Xenial
Expand Down
14 changes: 8 additions & 6 deletions build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ then

if [ "$COMPILER" = "clang++-8" -a -n "$GITHUB_WORKFLOW" -a -n "$CATA_CLANG_TIDY" ]
then
# This is a hacky workaround for the fact that the custom clang-tidy we are
# This is a hacky workaround for that the custom clang-tidy we are
# using is built for Travis CI, so it's not using the correct include directories
# for GitHub workflows.
cmake_extra_opts+=("-DCMAKE_CXX_FLAGS=-isystem /usr/include/clang/8.0.0/include")
Expand Down Expand Up @@ -132,7 +132,7 @@ then
set +x
all_cpp_files="$( \
grep '"file": "' build/compile_commands.json | \
sed "s+.*$PWD/++;s+\"$++")"
sed "s+.*$PWD/++;s+\"$++")" # ' (This is for editor formatting)
changed_cpp_files="$( \
./build-scripts/files_changed | grep -F "$all_cpp_files" || true )"
if [ -n "$changed_cpp_files" ]
Expand Down Expand Up @@ -165,8 +165,9 @@ then
make -j$num_jobs
cd ..
# Run regular tests
[ -f "${bin_path}cata_test" ] && parallel --verbose --linebuffer "run_test $(printf %q "${bin_path}")'/cata_test' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
[ -f "${bin_path}cata_test-tiles" ] && parallel --verbose --linebuffer "run_test $(printf %q "${bin_path}")'/cata_test-tiles' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
seed="$(shuf -i 0-1000000000 -n 1)"
[ -f "${bin_path}cata_test" ] && parallel --verbose --tagstring "({1} {2})=>" --linebuffer $WINE ${bin_path}/cata_test --durations yes --use-colour yes --rng-seed $seed $EXTRA_TEST_OPTS {1} {2} ::: "--order decl" "--order rand" ::: "--success [weary]" "-f weary_nutrition_tests.txt"
[ -f "${bin_path}cata_test-tiles" ] && parallel --verbose --tagstring "({})=>" --linebuffer $WINE ${bin_path}/cata_test-tiles --durations yes --use-colour yes --rng-seed $seed $EXTRA_TEST_OPTS {1} {2} ::: "--order decl" "--order rand" ::: "--success [weary]" "-f weary_nutrition_tests.txt"
fi
elif [ "$NATIVE" == "android" ]
then
Expand All @@ -187,10 +188,11 @@ else

export ASAN_OPTIONS=detect_odr_violation=1
export UBSAN_OPTIONS=print_stacktrace=1
parallel --verbose --linebuffer "run_test './tests/cata_test' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
seed="$(shuf -i 0-1000000000 -n 1)"
parallel --verbose --tagstring "({1} {2})=>" --linebuffer $WINE ./tests/cata_test --durations yes --use-colour yes --rng-seed $seed $EXTRA_TEST_OPTS {1} {2} ::: "--order decl" "--order rand" ::: "--success [weary]" "-f weary_nutrition_tests.txt"
if [ -n "$MODS" ]
then
parallel --verbose --linebuffer "run_test './tests/cata_test --user-dir=modded '$(printf %q "${MODS}") {} 'Mods-('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
parallel --verbose --tagstring "(Mods {1} {2})=>" --linebuffer $WINE ./tests/cata_test --user-dir=modded $MODS --durations yes --use-colour yes --rng-seed $seed $EXTRA_TEST_OPTS {1} {2} ::: "--order decl" "--order rand" ::: "--success [weary]" "-f weary_nutrition_tests.txt"
fi

if [ -n "$TEST_STAGE" ]
Expand Down
20 changes: 11 additions & 9 deletions src/activity_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "options.h"
#include "string_formatter.h"

#include <cmath>
#include <limits>

int activity_tracker::weariness() const
Expand All @@ -28,22 +29,23 @@ void activity_tracker::try_reduce_weariness( int bmr, bool sleeping )

const float recovery_mult = get_option<float>( "WEARY_RECOVERY_MULT" );

if( low_activity_ticks >= 6 ) {
if( low_activity_ticks >= 1 ) {
int reduction = tracker;
// 1/20 of whichever's bigger
// 1/120 of whichever's bigger
if( bmr > reduction ) {
reduction = bmr * recovery_mult;
reduction = std::floor( bmr * recovery_mult * low_activity_ticks / 6.0f );
} else {
reduction *= recovery_mult;
reduction = std::ceil( reduction * recovery_mult * low_activity_ticks / 6.0f );
}
low_activity_ticks -= 6;
low_activity_ticks = 0;

tracker -= reduction;
tracker -= std::max( reduction, 1 );
}

if( tick_counter >= 12 ) {
intake *= 1 - recovery_mult;
tick_counter -= 12;
// If happens to be no reduction, character is not (as) hypoglycemic
if( tick_counter >= 3 ) {
intake *= std::pow( 1 - recovery_mult, 0.25f );
tick_counter -= 3;
}

// Normalize values, make sure we stay above 0
Expand Down
2 changes: 1 addition & 1 deletion src/activity_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class activity_tracker
bool activity_reset = true;
int num_events = 1;

public:
// Weariness metadata.
int tracker = 0;
int intake = 0;
// Semi-consecutive 5 minute ticks of low activity (or 2.5 if we're sleeping).
int low_activity_ticks = 0;
// How many ticks since we've decreased intake.
int tick_counter = 0;
public:
// Logs activity level. If called multiple times in one turn, will preserve the highest.
void log_activity( float new_level );
// Informs the tracker that a new turn has started.
Expand Down
Loading