Commit Graph

44 Commits

Author SHA1 Message Date
jjspace 09a719b8fb
run prettier v3 2024-09-20 11:24:24 -04:00
Sanjeet Suhag aaf6bd8a5c Adds engine and widgets workspaces 2022-11-01 15:39:57 -04:00
Peter Gagliardi 897427bd0e Control test canvas size from cli or query string 2022-08-16 16:43:37 -04:00
Gabby Getz 355dd42838 Updated build process 2022-05-24 08:54:14 -04:00
Gabby Getz 700aac4035 Change helper function import 2022-04-13 12:58:28 -04:00
Gabby Getz a0400260ba Add browser runner 2022-04-13 10:24:27 -04:00
Eli Bogomolny 7fa0d1c1ce Delete files 2022-03-09 15:58:41 -05:00
Matthew Amato 2fd0e8f7e4 Format all code with prettier 2020-04-16 20:31:36 -04:00
Matthew Amato aabd27a760 Migrate Cesium to ES6 Modules
See https://github.com/AnalyticalGraphicsInc/cesium/pull/8224 for details.

eslint
There are a handful of new .eslintrc.json files, mostly to identify the files that are still AMD modules (Sandcastle/Workers). These are needed because you can't change the parser type with a comment directive (since the parser is the thing reading the file). We can finally detect unusued modules! So those have all been cleaned up as well.

requirejs -> rollup & clean-css
requirejs, almond, and karma-requirejs have all been removed. We now use rollup for building and minifying (via uglify) JS code and clean-css for css. These changes are fairly straight-forward and just involve calling rollup instead of requirejs in the build process.

Overall build time is significantly faster. CI is ~11 minutes compared to ~17 in master. Running makeZipFile on my machine takes 69 seconds compared to 112 seconds in master. There's probably plenty of room for additional optimization here too.

We wrote an published a small npm module, rollup-plugin-strip-pragma, for stripping the requirejs pragmas we use out of the release builds. This is maintained in the Tools/rollup-plugin-strip-pragma directory.

As for what we produce. The built version of Cesium is now a UMD module. So it should work anywhere that hasn't made the jump to ES6 yet. For users that were already using the "legacy" combined/minified approach, nothing changes.

One awesome thing about roll-up is that it compiles all of the workers at once and automatically detects shared codes and generates separate bundles under the hood. This means the size of our worker modules shrink dramatically and Cesium itself will load them much faster. The total minified/gzipped size of all workers in master is 2.6 MB compared to 225 KB in this branch! This should be most noticeable on demos like Geometry & Appearances which load lots of workers for the various geometry typs.

roll-up is also used to build Cesium Viewer, which is now an ES6 app.

We use clean-css via gulp and it is also a straightforward change from requirejs that requires no special mention.

Workers
While the spec allows for ES6 Web Workers, no browser actually supports them yet. That means we needed a way to get our workers into non-ES6 form. Thankfully, roll-up can generate AMD modules, which means we now have a build step to compile our Worker source code back into AMD and use the existing TaskProcessor to load and execute them. This build step is part of the standard build task and is called createWorkers. During development, these "built" workers are un-optimized so you can still debug them and read the code.

Since there is a build step, that means if you are changing code that affects a worker, you need to re-run build, or you can use the build-watch task to do it automatically.

The ES6 versions of Worker code has moved into Source/WorkersES6 and we build the workers into their "old home" of Source/Workers. cesiumWorkerBootstrapper and transferTypedArrayTest which were already non-AMD ES5 scripts remain living in the Workers directory.

Surprisingly little was changed about TaskProcessor or the worker system in general, especially considering that I thought this would be one of the major hurdles.

ThirdParty
A lot of our ThirdParty either already had a hand-written wrapper for AMD (which I updated to ES6) or had UMD which created problems when importing the same code in both Node and the browser. I basically had to update the wrapper of every third-party library to fix these problems. In some cases I updated the library version itself (Autolinker, topojson). Nothing to be too concerned about, but future clean-up would be using npm versions of these libraries and auto-generating the wrappers as needed so we don't hand-edit things.

Sandcastle
Sandcastle is eternal and manages to live another day in it's ancient requirejs/dojo 1.x form. Sandcastle now automatically uses the ES6 version of Cesium if it is available and fallsback to the ES5 unminified version if it is now. The built version of Sandcastle always uses CesiumUnminified, just like master. This means Sandcastle still works in IE11 if you run the combine step first (or use the relase zip)

Removed Cesium usage from Sandcastle proper, since it wasn't really needed
Generate a VERSION propertyin the gallery index since Cesium is no longer being included.
Remove requirejs from Sandcastle bucket
Update bucket to use the built version of Cesium if it is available by fallbackto the ES6 version during development.
Standalone.html was also updated
There's a bit of room for further clean-up here, but I think this gets us into master. I did not rename bucket-requirejs.html because I'm pretty sure it would break previously shared demos. We can put in some backwards compatible code later on if we want. (But I'd rather just see a full Sandcastle rewrite).

Specs
Specs are now all ES6, except for TestWorkers, which remain standard JS worker modules. This means you can no longer run the unbuilt unit tests in IE11. No changes for Chrome and Firefox.

Since the specs use ES6 modules and built Cesium is an ES5 UMD, I added a build-specs build step which generates a combined ES5 version of the specs which rely on Cesium as a global variable. We then inject these files into jasmine instead of the standard specs and everything works exactly as it did before. SpecRunner.html has been updated to inject the correct version of the script depending on the build/release query parameters.

The Specs must always use Cesium by importing Source/Cesium.js, this is so we can replace it with the built Cesium as describe above.

There's a bunch of room for clean-up here, such as unifying our two copies of jasmine into a single helper file, but I didn't want to start doing that clean-up as part of this already overly big PR. The important thing is that we can still test the built version and still test on IE/Edge as needed.

I also found and fixed two bugs that were causing failing unit tests, one in BingMapsImageryProviderSpec.js (which was overwriting createImage andnot setting it back) and ShadowVolumeAppearance.js (which had a module level caching bug). I think these may have been the cause of random CI failures in master as well, but only time will tell.

For coverage, we had to switch to karma-coverage-istanbul-instrumenter for native ES6 support, but that's it.

Finally, I updated appveryor to build Cesium and run the built tests under IE. We still don't fail the build for IE, but we should probably fix that if we want to keep it going.

NodeJS
When NODE_ENV is production, we now require in the minified CesiumJS directly, which works great because it's now a UMD module. Otherwise, we use the excellant esmpackage to load individual modules, it was a fairly straightforward swap from our old requirejs usage. We could probably drop esm too if we don't care about debugging or if we provie source maps at some point.
2019-10-03 11:51:23 -04:00
hpinkos 1a8e2dd5a7 update node modules 2019-09-19 11:04:04 -04:00
Matthew Amato d0af657b50 Get rid of defineSuite
Cesium traditionally had a custom `defineSuite` function that wrapped
both the `define` used for importing requrejs modules and the `describe`
used to define a jasmine test block.

In order to move to ES6, we need to get rid of this helper function and
just use separate`define`/`describe` calls. Then, when we move to ES6,
the describe calls will stay as-is and the define call will be replaced
with ES6 module imports.

Since we also overloaded describe calls for category support, this was
an easy change to make and has zero functional changes.

To make the diff easy, I left indentation as-is.  When we move to ES6,
the indentation will actually go back to being correct.
2019-08-31 16:09:04 -04:00
Brandon Barker 6b04fed9ef fix eslint 2019-08-22 15:36:09 -04:00
Brandon Barker c43c7efa51 Fix unit tests 2019-08-22 15:30:15 -04:00
Matthew Amato 79b8d261ac Bump Jasmine timeout to hopefully make CI more stable.. 2019-04-04 09:06:59 -04:00
Matthew Amato 6e0911e110 Remove all double quote usage from JS code
99% of this PR was automatically fixed with eslint, I simply removed the
`"quotes": "off"` from Sandcastle and Specs which was ignoring the
standard rule of using single quotes.

Also added some Sandcastle generated files to .eslintignore.
2018-07-24 13:28:31 -04:00
hpinkos 3b4fd70bc6 wrap fit for running tests in karma 2018-03-16 16:03:10 -04:00
Matthew Amato 2a67108a65 Enable eslint `no-multiple-empty-lines`
Also use eslint to auto-fix them.
2018-03-04 21:25:50 -05:00
Matthew Amato c635584938 Fix release tests
Cleans up #5466 which had some incomplete tests causing release builds to
fail. Also simplified the tests to check frozen state instead of relying on
exception handling.

Also removed some uneeded `/*global defineSuite*/` statements I found while
in the code
2017-10-23 13:39:40 -04:00
Sean Lilley 3e33ad5148 Cleanup 2017-01-23 17:03:04 -05:00
Patrick Cozzi 4912f4992d Start of webglstub parameter 2016-12-01 14:34:57 -05:00
ggetz 9bcaf8e546 Factored out webgl validation to global 2016-02-05 13:42:18 -05:00
Matthew Amato b1525402e5 Tweaks. 2015-12-22 17:12:37 -05:00
ggetz ff78dfff31 Fixed config issues and some test failures 2015-12-22 11:34:37 -05:00
Scott Hunter 0333e2fe77 Fix TestWorkers in TaskProcessorSpec.
Recent changes (well, over a year ago) to RequireJS broke the way we were locating the Source directory in both normal and combined test modes. Instead, we now configure RequireJS with an additional path "Source" which always points to the Source directory, regardless of mode.

This path should not be used from other specs, because it will bypass the stubs in the combined test mode. It is specifically intended for the TaskProcessor specs, because the TestWorkers need to always load using the individual modules in Source.
2015-10-23 16:49:22 -04:00
Kevin Ring 77ccc3905f Restore timeout to 5 seconds. 2015-02-23 11:05:55 +11:00
Kevin Ring b0929902e9 Fix jshint warnings. 2015-02-18 11:46:48 +11:00
Kevin Ring 4b11585575 Two spec improvements.
Clear category=none when focusing a spec, so the spec actually runs.

Fix Primitive's "failed geometry rejects promise and throws on next update" test by hackily checking for the "built=true" parameter.
2015-02-18 11:37:57 +11:00
Kevin Ring 4a326c70e9 Clean up old files. 2015-02-17 16:12:00 +11:00
Kevin Ring 2030cd0a2c Modify jasmine-html rather than supplying our own.
I'm torn on this, but I think it's the right approach.
2015-02-17 16:07:09 +11:00
Kevin Ring 3b18cca078 Don't lose parameters when focusing specs. 2015-02-17 15:52:45 +11:00
Kevin Ring b661f1c36f Add support for release=true and not=categories 2015-02-17 14:52:46 +11:00
Kevin Ring abdd429de4 Support testing against built Cesium. 2015-02-17 13:47:23 +11:00
Kevin Ring 6b4a5ff6ea Support running specs against built Cesium.
It sort of works.
2015-02-16 16:37:07 +11:00
Kevin Ring 857632ce17 Basic support for categories. 2015-02-11 23:57:09 +11:00
Kevin Ring 7fb8b4cf0e Fork Jasmine's HTML reporter.
No changes yet.
2015-02-11 16:14:42 +11:00
Kevin Ring 3c70c461ae More test fixes.
Everything is passing at this point, except for three tests that also fail in master on this system.
2015-02-11 15:10:19 +11:00
Kevin Ring f777b90d6a Fail more quickly and provide more info when promises reject. 2015-01-04 21:41:40 +11:00
Kevin Ring 94fecff605 Fix remaining test failures. 2015-01-01 22:01:37 +11:00
Kevin Ring adae60f91d More promisey async tests. 2014-12-29 22:28:24 +11:00
Kevin Ring 2b84473ce4 Fix lots of test failures. 2014-12-29 15:12:43 +11:00
Kevin Ring a90aa25424 Actually run all the tests. 2014-12-03 17:48:42 +11:00
Kevin Ring 6c0563af4c Lots of spec fixes.
Only two test failures now, but runs and waitsFor are stubbed out.  Also, only 2825 specs total are being run at all. hmmm.
2014-12-01 17:11:34 +11:00
Kevin Ring b7e630e755 Down to 286 failures. 2014-12-01 16:08:21 +11:00
Kevin Ring f6d3e88f9a Make tests run under Jasmine 2.1.2.
There are 1947 failures, but hey.
2014-12-01 15:59:07 +11:00