Sanmill icon indicating copy to clipboard operation
Sanmill copied to clipboard

integration_test: Initial commit (WIP)

Open calcitem opened this issue 3 years ago • 3 comments

Regression testing is required every time a large function is integrated, which is tedious and requires the use of test code to reduce the workload.

Reference

See: https://docs.flutter.dev/testing/integration-tests

TODO

I don't know how to display the test results. After I started the test in VSCode, it never showed that the test passed. I don't know how to do it.

calcitem avatar Nov 21 '21 10:11 calcitem

@check-spelling-bot Report

Unrecognized words, please review:

  • pch
Previously acknowledged words that are now absent ALIGNAS alignof andnetwork appbundle asm autobuild Barlabel Bitboard cafebazaar cmake Codacy codeql constexpr cupertino cwd DANDROID datastore DISCARDABLE enum erver fastlane fdroid FFDEB FFEDF FFFEFEFE FFFFEFD FFFFFAF FFFFFFFF FILEFLAGS FILEFLAGSMASK FILEOS FILESUBTYPE FILEVERSION FPKV fsanitize GAMEBOOK GAMECONTROLLER GAMEITEM GRAPHICSVIEW hhmmss Hori htmlcsscolor HWND iqiyi libsanmill llds llus LPARAM LPTHREAD LPWSTR LUID MANUALLISTVIEW MEMORYSTATUSEX MESSAGEBOX Mixin Monospace msix msvc Mtdf namespace nmake noexcept npos nullptr pgmptr PRODUCTVERSION qgraphicsitems qmake QTDIR rotr SBg SBn SCs SDa SDe Sebastiano ses SFa SFi SFr SGu shlwapi SHu SId sizeof SJa SKn SKo skvf SLv SMk SMs SNb SNl SRo SRu SSk SSl SSq SSr SSv STe sterlund STh stof SUBLANG subosito Subtags SVi SZh TARG TEXTINCLUDE typedef typename vcvarsall VERSIONINFO wchar winbase winres winver XCRASH
Some files were were automatically ignored

These sample patterns would exclude them:

^tests/gtest/pch\.cpp$
^tests/gtest/pch\.h$

You should consider adding them to:

.github/actions/spelling/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:calcitem/Sanmill.git repository on the flutter-integration-test branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
(cat '.github/actions/spelling/excludes.txt' - <<EOF
$should_exclude_patterns
EOF
) |grep .|
sort -f |
uniq > '.github/actions/spelling/excludes.txt.temp' &&
mv '.github/actions/spelling/excludes.txt.temp' '.github/actions/spelling/excludes.txt'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/calcitem/Sanmill/issues/comments/974792916" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  

should_exclude_patterns=$(perl -e '$/=undef;
$_=<>;
exit unless s{(?:You should consider excluding directory paths|You should consider adding them to).*}{}s;
s{.*These sample patterns would exclude them:}{}s;
s{.*\`\`\`([^`]*)\`\`\`.*}{$1}m;
print' < "$comment_body" | grep . || true)

update_files
rm $comment_body
git add -u
If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and adding it to the patterns.txt file.

Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

Alternatively, the bot can do this for you if you reply quoting the following line: @check-spelling-bot apply changes.

github-actions[bot] avatar Nov 21 '21 10:11 github-actions[bot]

I don't know how to display the test results. After I started the test in VSCode, it never showed that the test passed. I don't know how to do it.

I'm very busy rn (thats why the other PRs are stale atm). I don't know why we should test the java/kotlin stuff but as we don't utilize the native code there shouldn't bee anything to test. I'ts probably best to write dart/flutter tests.

I'll have a deeper look and think about this when I have more time (next week maybe)

Leptopoda avatar Nov 21 '21 10:11 Leptopoda

The original code did not test Java codes, but the code for testing Flutter has not run. I had not worked it out for a whole day, I had no choice, so I had to add all the codes in the manual, including Java-related test codes. So I can only push it first and set it to WIP status.

When you have time, we can see how it works. As long as one test case can run, I can add many more test codes.

calcitem avatar Nov 21 '21 10:11 calcitem