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

synthutils test is broken #4404

Open
walterbender opened this issue Feb 13, 2025 · 13 comments
Open

synthutils test is broken #4404

walterbender opened this issue Feb 13, 2025 · 13 comments

Comments

@walterbender
Copy link
Member

Description

The changes to the volume code changes and seems to have broken the unit test

@walterbender
Copy link
Member Author

@falgun143 can you please investigate

@falgun143
Copy link
Contributor

@walterbender sure. @omsuneri can I work on this ?

@omsuneri
Copy link
Member

omsuneri commented Feb 14, 2025

@falgun143 yaa you can but follow the guide while changing any test

@omsuneri
Copy link
Member

@falgun143 I ll suggest you to first investigate the changes you did in #4396 and try to resolve from there without changing the actual test cases
Cause it's very difficult and poor idea to change every failing test case after any pr merges
Either changing the pr makes more sense

@Harshit-7373
Copy link

@walterbender Not only synthutils test is broken but their are many other tests failing.

  1. 3 test suites are failing out of 46.
  2. 10 tests are failed out of 682.

@omsuneri
Copy link
Member

omsuneri commented Feb 18, 2025

Thanks @Harshit-7373 for pointing it out but volumeaction.js test is resolved in the #4422 also the errors with synthutils.js i m resolving right now will be raising a PR for the same soon

@Harshit-7373
Copy link

@omsuneri I guess that PR is not merged yet because i am still getting error. Can you tell me something about it?

@omsuneri
Copy link
Member

@omsuneri I guess that PR is not merged yet because i am still getting error. Can you tell me something about it?

yes its under review will be merged soon.

@falgun143
Copy link
Contributor

@omsuneri what are the other test files you are working on?

@omsuneri
Copy link
Member

omsuneri commented Feb 18, 2025

@falgun143 you can take turtle-singer.js failing as i m not resolving it also try to add some more edge case tests

@falgun143
Copy link
Contributor

@omsuneri alright I will take turtle-singer.js and write some checks in the .js files in which I made changes.

@omsuneri
Copy link
Member

@falgun143 sure also dont try to alter the root file functions as well

@omsuneri omsuneri mentioned this issue Feb 18, 2025
4 tasks
@falgun143
Copy link
Contributor

@walterbender, the reason why the synthutils test passes—apart from volume blocks—is purely luck. There is a disconnect between what we are calculating and what we are testing.
1.
Code Snippet:

Image

BUGS:

Image

Image

We are calculating values for the flute but testing for the piano. As a result, Tone.gainToDb() gets called twice:

First, from this line:
setVolume("turtle1", "flute", 80);

2nd from thisSecond, from this calculation:
const expectedDb = Tone.gainToDb(nv / 100);

And now the Tone.gainToDb() will recieve two values and if in this function . expect(Tone.gainToDb).toHaveBeenCalledWith(0.96);
we pass in any of the two values which Tone.gainToDv recieved the test will pass. So to avoid this we have test and calulate for the same instrument.

2.

Image
Similarly we are passing in guitar as agrs, And expecting instruments[turtle]["electronic synth"]).toBeInstanceOf(Tone.PolySynth)
and the reason this test works is that the createDefaultSynth() function, which runs earlier, has already set instruments[turtle]["electronic synth"].

Image
I have added a few checks in my .js file to improve the robustness of the code. I will also make changes to synthutils.test.js and turtle.test.js.

I will raise a PR soon—I was a bit busy over the last 6 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants