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

Improved unit tests for FFmpegRunner #1364

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Improved unit tests for FFmpegRunner #1364

wants to merge 26 commits into from

Conversation

tombogle
Copy link
Contributor

@tombogle tombogle commented Nov 8, 2024

With this change, these tests do not:

  • take over display
  • depend on an installed media player
  • leave junk on the screen
  • leave orphaned temp files

This change is Reviewable

@tombogle tombogle requested a review from andrew-polk November 8, 2024 20:24
@tombogle tombogle self-assigned this Nov 8, 2024
…endent on an installed media player, leave junk on the screen, and leave orphaned temp files.
Copy link

github-actions bot commented Nov 8, 2024

LibPalaso Tests

   36 files   -     9     36 suites   - 9   4m 34s ⏱️ - 7m 21s
2 477 tests  - 2 353  2 318 ✅  - 2 281  158 💤  -  73  1 ❌ +1 
6 901 runs   - 7 107  6 531 ✅  - 6 850  369 💤  - 258  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 1642a26. ± Comparison against base commit de37405.

This pull request removes 2353 tests.
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ CloneCopiesAllNeededMembers
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ Equal_ItemsAreEqual_ReturnsTrue
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ Equal_OneFieldDiffers_ReturnsFalse
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ Equal_SecondFieldIsNull_ReturnsFalse
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ Equals_OtherIsNull_ReturnsFalse
SIL.DictionaryServices.Tests.Lift.EmbeddedXmlCollectionCloneableTests ‑ ObjectEquals_OtherIsNull_ReturnsFalse
SIL.DictionaryServices.Tests.Lift.FlagStateCloneableTests ‑ CloneCopiesAllNeededMembers
SIL.DictionaryServices.Tests.Lift.FlagStateCloneableTests ‑ Equal_ItemsAreEqual_ReturnsTrue
SIL.DictionaryServices.Tests.Lift.FlagStateCloneableTests ‑ Equal_OneFieldDiffers_ReturnsFalse
SIL.DictionaryServices.Tests.Lift.FlagStateCloneableTests ‑ Equal_SecondFieldIsNull_ReturnsFalse
…

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @tombogle)

Copy link

github-actions bot commented Nov 14, 2024

Palaso Tests

     3 files  ± 0       3 suites  ±0   15m 12s ⏱️ -38s
 4 885 tests +48   4 652 ✅ +46  233 💤 +2  0 ❌ ±0 
14 118 runs  +96  13 487 ✅ +92  631 💤 +4  0 ❌ ±0 

Results for commit 9b61be8. ± Comparison against base commit 7004a47.

♻️ This comment has been updated with latest results.

Also cleaned up some outdated comments and did minor refactoring.
Copy link
Contributor

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made the tests pass as it's now finding ffmpeg. Left a comment about the TeamCity category comment being inaccurate.

SIL.Media.Tests/AudioPlayerTests.cs Outdated Show resolved Hide resolved
SIL.Media.Tests/FFmpegRunnerTests.cs Show resolved Hide resolved
SIL.Media/FFmpegRunner.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @hahn-kev and @tombogle)

SIL.Media/FFmpegRunner.cs Outdated Show resolved Hide resolved
/// selects the test assemblies using Include="$(RootDir)/output/$(Configuration)/*.Tests.dll" which excludes exes.
/// I have not tried to verify that all of these tests would actually have problems on TeamCity, but it seemed
/// helpful to document in the usual way that they are not, in fact, run there.
/// </summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it is still worth a comment explaining why we are skipping these tests in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this file never explained its dependency. Turns out that with that one test ignored, the only remaining test in the fixture runs just fine without any sound device enabled. So I'll remove the SkipOnTeamCity category. I'm now thinkingnthat doing something like this is the real answer:https://github.com/NathanCheshire/CyderUtils/actions/runs/9733272570/workflow. Then all these tests could run in the CI build.

/// selects the test assemblies using Include="$(RootDir)/output/$(Configuration)/*.Tests.dll" which excludes exes.
/// I have not tried to verify that all of these tests would actually have problems on TeamCity, but it seemed
/// helpful to document in the usual way that they are not, in fact, run there.
/// </summary>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this file never explained its dependency. Turns out that with that one test ignored, the only remaining test in the fixture runs just fine without any sound device enabled. So I'll remove the SkipOnTeamCity category. I'm now thinkingnthat doing something like this is the real answer:https://github.com/NathanCheshire/CyderUtils/actions/runs/9733272570/workflow. Then all these tests could run in the CI build.

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r3, 9 of 9 files at r4, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @hahn-kev and @tombogle)

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 16 of 16 files at r6, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @hahn-kev and @tombogle)


CHANGELOG.md line 82 at r6 (raw file):

- [SIL.Windows.Forms.Archiving] Changed Cancel Button to say Close instead in IMDIArchivingDlg.
- [SIL.Core.Desktop] Renamed GetFromRegistryProgramThatOpensFileType to GetDefaultProgramForFileType.
- [SIL.Media] Made FFmpegRunner able to use version of FFmpeg found on the path.

Does the irrklang upgrade want a line here?

@tombogle
Copy link
Contributor Author

CHANGELOG.md line 82 at r6 (raw file):

Previously, andrew-polk wrote…

Does the irrklang upgrade want a line here?

Done.

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @hahn-kev and @tombogle)

return ffmpeg;
}

private static bool MeetsMinimumVersionRequirement(string ffmpeg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we concerned that this will execute every time (unless an explicit path is set) LocateFFmpeg is called? There's some places where it's called every time rather than using LocateAndRememberFFmpeg

Copy link
Contributor Author

@tombogle tombogle Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it has been that way for over a decade. Changing it would be a very subtle change. It's potentially a breaking change but only in the really bizarre edge case where an app does not install FFmpeg and the user installs it while running the app. In the grand scheme of things re-locating it each time probably isn't a huge performance penalty, but it seems pretty clear that in general this class was set up to check once and then assume the situation would not change. Maybe these methods were ported over from some app that didn't have this concept. I think I'll fix it. within sillsdev, the methods in question are used only in SayMore, unit tests and check (not sure what it was, but its repo is marked as deprecated).

…quiresAudioInputDevice to make it clear what requirement might not be met when tests fail.

In FFmpegRunner, changed methods to use LocateAndRememberFFmpeg instead of LocateFFmpeg.
Made the Windows implementation of ISimpleAudioSession attempt to create an irrKlang-based recorder even if there is no audio output device enabled.
Improved some of the AudioSession unit tests to not require an audio input device if they are only testing playback.
Made AudioRecorderTests fail at the fixture level if an audio input device is not present rather than throwing an obscure exception inside OnHandleCrated.
SIL.Media/FFmpegRunner.cs Outdated Show resolved Hide resolved
… (not sure why installing FFmpeg worked once and now can't be found on the path.)
@tombogle
Copy link
Contributor Author

I see now that there is separate logic for locating FFmpeg and FFprobe, and they are not in sync. I'll finish getting them on the same page tomorrow.

…ation as FFmpeg and also on the system path).

Made FFmpegRunner explicitly a static class (technically a breaking change, though all methods were already static).
Made FFmpegRunner look for FFmpeg on the path before trying to find a version installed for Audacity (which is unlikely to succeed anyway).
Renamed FFmpegRunner.FfmpegMinimumVersion property to MinimumVersion.
Significant refactoring in FFmpegRunner and MediaInfo
Made private utility functions in FFmpegRunner and MediaInfo into local functions so they would not accidentally be called by other methods in those classes.
Added some test cases for MediaInfo.FFprobeFolder setter
@tombogle tombogle force-pushed the improve-tests branch 2 times, most recently from 0eaa2e9 to 2a5390f Compare December 3, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants