-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
really run all tests and fix broken tests #5123
Conversation
new THREE.MeshBasicMaterial({color: 0xffff00}) | ||
); | ||
meshWithMaterialArray = new THREE.Mesh( | ||
new THREE.Sphere(2), | ||
new THREE.SphereGeometry(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THREE.Sphere
exists but the arguments are center vec3 and radius number in latest threejs... I spend really too much time to find that the cryptic error was because of this lol. THREE.SphereGeometry
first arg is radius number.
@@ -147,7 +147,7 @@ suite('camera system', function () { | |||
assert.ok(cameraEl.getAttribute('camera').active); | |||
assert.ok(cameraSystem.setActiveCamera.calledOnce); | |||
assert.equal(cameraSystem.activeCameraEl, cameraEl); | |||
cameraSystem.setActiveCamera.reset(); | |||
cameraSystem.setActiveCamera.resetHistory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sinon api changed. I already did a similar change in other files when I did #5091
tests/karma.conf.js
Outdated
FILES.push('tests/extras/**/*.test.js'); | ||
FILES.push('tests/shaders/**/*.test.js'); | ||
FILES.push('tests/systems/**/*.test.js'); | ||
FILES.push('tests/utils/**/*.test.js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem with this is that if we add a new directory we have to manually update this list. I anticipate frustration :) Any insight why the previous was no longer working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that with karma-browserify before or after the big update of all the test stack in #5091, it also ran only 355 tests. After the switch to karma-webpack, it would only run 16 tests (corresponding to the core directory it seems), so I changed to use glob in https://github.com/aframevr/aframe/pull/5116/files#diff-728e6c3454f7b441786065d02f09e5cefeadfc2c007bf03b44d03f43dfc1a8c5 to run again 355 tests, but that's not actually all the tests. It's been like that for years it seems.
I thought first this had probably something to do with the way karma preprocess test files, and/or the difference how karma-browserify and karma-webpack inject additional files to the list, and the order maybe, but looking at the code I couldn't find really what's going on.
https://github.com/nikku/karma-browserify/blob/17967164c91e4d5644cca26bd8f84e3674434351/lib/bro.js#L84-L121
https://github.com/ryanclark/karma-webpack/blob/f90487b0ca4c342b546e78b4dbad6fc7f50638d8/lib/karma-webpack/preprocessor.js#L17-L53
https://github.com/ryanclark/karma-webpack/blob/f90487b0ca4c342b546e78b4dbad6fc7f50638d8/lib/karma-webpack/framework.js#L4-L32
https://karma-runner.github.io/latest/config/files.html
I did some debugging with only the FILES.push('tests/**/*.test.js');
pattern.
I put some console.log before the return in
https://github.com/karma-runner/karma/blob/f2d0663105eba0b9ea7f281230546282a46015ad/lib/file-list.js#L117-L151
if (p.pattern === '/home/vincentfretin/workspace/aframe/tests/**/*.test.js') {
console.log("included", Object.keys(included).length);
console.log("lookup", Object.keys(lookup).length);
}
When I run I get all the test files
included 93
lookup 109
but only 16 tests are run.
find tests/ -name "*test.js"|wc -l
87 files
I also added a console.log in karma.js where it serves all the scripts, each test.js is bundled with webpack and included in a script tag. I get the 95 files included with a script tag there.
If now I use
glob.sync('tests/**/*.test.js').forEach(function (filename) {
FILES.push(filename);
});
I get the same 95 files included as scripts in the same order but I get 355 tests. No idea what's going on here...
If I use
FILES.push('tests/components/**/*.test.js');
FILES.push('tests/core/**/*.test.js');
FILES.push('tests/extras/**/*.test.js');
FILES.push('tests/shaders/**/*.test.js');
FILES.push('tests/systems/**/*.test.js');
FILES.push('tests/utils/**/*.test.js');
I have 95 files included, but in a different order, and I get 509 tests.
It's probably an issue with karma-mocha/mocha really, it seems we actually have several asynchronous tests that are not properly written with a done()
so they actually fail between tests and come back wrongly green, and if there is an error between tests, mocha stops executing tests, see karma-runner/karma-mocha#227
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can perhaps do this to avoid listing the directories by hand?
glob.sync('tests/*/').forEach(function (dirname) {
FILES.push(dirname + '**/*.test.js');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. nevermind. It's the order... mmmh. We will have similar issues in the future as we add tests and will have to fiddle with the order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests folders are a one-to-one mapping of the folders in src. I don't think we will be adding a folder anytime soon. But sure to be future proof we can do as you suggested but I'll include ignoring assets, coverage, node folders to avoid warnings:
27 09 2022 09:20:58.769:WARN [filelist]: Pattern "/home/vincentfretin/workspace/aframe/tests/assets/**/*.test.js" does not match any file.
27 09 2022 09:20:58.769:WARN [filelist]: Pattern "/home/vincentfretin/workspace/aframe/tests/coverage/**/*.test.js" does not match any file.
27 09 2022 09:20:58.769:WARN [filelist]: Pattern "/home/vincentfretin/workspace/aframe/tests/node/**/*.test.js" does not match any file.
This is currently working the same:
var excluded_folders = ['assets', 'coverage', 'node'];
glob.sync('tests/*/').forEach(function (dirname) {
if (excluded_folders.indexOf(dirname) !== -1) return;
FILES.push(dirname + '**/*.test.js');
});
The real fix would be to fix the tests so we are not dependent of the order that's for sure, but I couldn't find the bad test.
There is actually a lot more tests! But I had to use suite.skip or test.skip for some tests to make all the tests runs for now
I get With
so it's changing the order of test execution, it currently crashes at
|
|
d755317
to
264dc77
Compare
There is a progress: |
264dc77
to
87e6936
Compare
✔ 1096 tests completed remaining failing tests are one raycaster test and I don't understand why it's failing, and the a-assets test suite that stops running all next tests because of an "ERROR: 'An uncaught promise rejection occurred between tests'" so we probably need to fix the code itself, but I see there is also #5033 pending. |
✔ 1118 tests completed There are still 5 skipped tests of a-assets related to error and timeout and one for raycaster we need to figure out. |
My last commit fixes the issues I had with a-assets test suite, I may also have fixed the #5032 issue that #5033 was fixing @diarmidmackenzie ? I need to test some real cases for this issue, maybe add the console warning like you did in your PR? ✔ 1122 tests completed There is still the raycaster test that bother me. |
I also have sometimes the error
but from my understanding the test looks ok, model-loaded listener is registered before setting the model. If I reexecute again I have
The 2s limit to run the test that load a big obj model may just not be enough in this particular case. |
I increased the mocha timeout from the default 2s to 3s, hopefully it will fix the random issue with the above test. |
…sing but gave an error TypeError: Cannot read properties of undefined (reading 'Component')
…ardown that make the test fail the second time
I fixed the raycaster test. I think this is ready to merge. |
Thank you x 1000 |
I'm still not sure how karma file pattern works to find the tests but
npm run test:chrome
was running actually only the tests from the tests/components/ directory.
This was the equivalent of
TEST_FILE=components npm run test:chrome
355 tests
With the changes, specifying each directory, it finds all the tests now:
npm run test:chrome
511 tests, 2 skipped
I fixed the broken tests.