Wednesday, July 1, 2020

I probably fixed #3705. How to reproduce the problem locally:

$ export LINO_CACHE_ROOT=/home/luc/lino_cache
$ go apc
$ pm prep
$ dt docs/specs/cosi/apc.rst

The problem was because the apc demo project has a local config dir. When the apc tests were run on travis (i.e. LINO_CACHE_ROOT is set), Lino forgot to add the apc site’s config dir to its list of config dirs. Another problem was that these “non-local site config dirs” (for which apc on travis is the only example) must come before the plugin config dirs.

The confdirs demo project now also has a local config directory. The Introduction to config directories page now does some actual testing. It uses a trick to deactivate the LINO_CACHE_ROOT on Travis CI when running the tests for this page:

>>> import os ; os.environ.pop('LINO_CACHE_ROOT', None) # disable for this doctest

Curious to see whether my trick works. (Edit: yes, it works)

I reviewed docs about config.

I discovered and fixed a bug in the template of the status command that caused it to never say [writeable].

lino repo gets red when book fails

I probably fixed #3706 and tidied up some duplicate functionality.

Running e2e tests locally

I used https://opensource.com/article/20/6/reactjs-tools as a base for the following.

::

$ sudo apt install nodejs npm

Worked.

::

$ cd ~/tmp $ npm start

failed with:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose stack Error: ENOENT: no such file or directory, open '/home/luc/tmp/package.json'

I went to https://create-react-app.dev/docs/getting-started#npx and read that they now tell us to say:

npx create-react-app my-app

But this also fails saying “Command ‘npx’ not found …”.

Yes, they say “(npx comes with npm 5.2+ and higher, see instructions for older npm versions)”. I try what’s there:

$ npm install -g create-react-app

This fails with:

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Okay, let’s trust them:

$ sudo npm install -g create-react-app
/usr/local/bin/create-react-app -> /usr/local/lib/node_modules/create-react-app/index.js
/usr/local/lib
└─┬ create-react-app@3.4.1
  ├─┬ chalk@3.0.0
  │ ├─┬ ansi-styles@4.2.1
  │ │ ├── @types/color-name@1.1.1
  │ │ └─┬ color-convert@2.0.1
  │ │   └── color-name@1.1.4
  │ └─┬ supports-color@7.1.0
  │   └── has-flag@4.0.0
  ├── commander@4.1.0
  ├─┬ cross-spawn@7.0.1
  │ ├── path-key@3.1.1
  │ ├─┬ shebang-command@2.0.0
  │ │ └── shebang-regex@3.0.0
  │ └─┬ which@2.0.2
  │   └── isexe@2.0.0
  ├── envinfo@7.5.0
  ├─┬ fs-extra@8.1.0
  │ ├── graceful-fs@4.2.4
  │ ├── jsonfile@4.0.0
  │ └── universalify@0.1.2
  ├─┬ hyperquest@2.1.3
  │ ├── buffer-from@0.1.2
  │ ├─┬ duplexer2@0.0.2
  │ │ └─┬ readable-stream@1.1.14
  │ │   ├── isarray@0.0.1
  │ │   └── string_decoder@0.10.31
  │ └─┬ through2@0.6.5
  │   ├── readable-stream@1.0.34
  │   └── xtend@4.0.2
  ├─┬ inquirer@7.0.4
  │ ├─┬ ansi-escapes@4.3.1
  │ │ └── type-fest@0.11.0
  │ ├─┬ chalk@2.4.2
  │ │ ├─┬ ansi-styles@3.2.1
  │ │ │ └─┬ color-convert@1.9.3
  │ │ │   └── color-name@1.1.3
  │ │ └─┬ supports-color@5.5.0
  │ │   └── has-flag@3.0.0
  │ ├─┬ cli-cursor@3.1.0
  │ │ └─┬ restore-cursor@3.1.0
  │ │   ├─┬ onetime@5.1.0
  │ │   │ └── mimic-fn@2.1.0
  │ │   └── signal-exit@3.0.3
  │ ├── cli-width@2.2.1
  │ ├─┬ external-editor@3.1.0
  │ │ ├── chardet@0.7.0
  │ │ ├─┬ iconv-lite@0.4.24
  │ │ │ └── safer-buffer@2.1.2
  │ │ └─┬ tmp@0.0.33
  │ │   └── os-tmpdir@1.0.2
  │ ├─┬ figures@3.2.0
  │ │ └── escape-string-regexp@1.0.5
  │ ├── lodash@4.17.15
  │ ├── mute-stream@0.0.8
  │ ├── run-async@2.4.1
  │ ├─┬ rxjs@6.5.5
  │ │ └── tslib@1.13.0
  │ ├─┬ string-width@4.2.0
  │ │ ├── emoji-regex@8.0.0
  │ │ ├── is-fullwidth-code-point@3.0.0
  │ │ └─┬ strip-ansi@6.0.0
  │ │   └── ansi-regex@5.0.0
  │ ├─┬ strip-ansi@5.2.0
  │ │ └── ansi-regex@4.1.0
  │ └── through@2.3.8
  ├── semver@6.3.0
  ├─┬ tar-pack@3.4.1
  │ ├─┬ debug@2.6.9
  │ │ └── ms@2.0.0
  │ ├─┬ fstream@1.0.12
  │ │ ├── inherits@2.0.4
  │ │ └─┬ mkdirp@0.5.5
  │ │   └── minimist@1.2.5
  │ ├─┬ fstream-ignore@1.0.5
  │ │ └─┬ minimatch@3.0.4
  │ │   └─┬ brace-expansion@1.1.11
  │ │     ├── balanced-match@1.0.0
  │ │     └── concat-map@0.0.1
  │ ├─┬ once@1.4.0
  │ │ └── wrappy@1.0.2
  │ ├─┬ readable-stream@2.3.7
  │ │ ├── core-util-is@1.0.2
  │ │ ├── isarray@1.0.0
  │ │ ├── process-nextick-args@2.0.1
  │ │ ├── safe-buffer@5.1.2
  │ │ ├── string_decoder@1.1.1
  │ │ └── util-deprecate@1.0.2
  │ ├─┬ rimraf@2.7.1
  │ │ └─┬ glob@7.1.6
  │ │   ├── fs.realpath@1.0.0
  │ │   ├── inflight@1.0.6
  │ │   └── path-is-absolute@1.0.1
  │ ├─┬ tar@2.2.2
  │ │ └── block-stream@0.0.9
  │ └── uid-number@0.0.6
  ├── tmp@0.1.0
  └─┬ validate-npm-package-name@3.0.0
    └── builtins@1.0.3

And here we go:

$ create-react-app my-app
Creating a new React app in /home/luc/tmp/my-app.
You are using npm 3.5.2 so the project will be bootstrapped with an old unsupported version of tools.
Please update to npm 5 or higher for a better, fully supported experience.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

> core-js@2.6.11 postinstall /home/luc/tmp/my-app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

my-app@0.1.0 /home/luc/tmp/my-app
├─┬ react@16.13.1
... (skipping about 1000 lines)
  ├── webpack-manifest-plugin@1.1.0
  └── whatwg-fetch@2.0.2

Success! Created my-app at /home/luc/tmp/my-app
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd my-app
  npm start

Happy hacking!

Note: the project was bootstrapped with an old unsupported version of tools.
Please update to Node >=8.10 and npm >=5 to get supported tools in new projects.

Welcome to React

To get started, edit src/App.js and save to reload.

Questions: Do I want to get a newer version of npm? And if yes, how can I get it?

But all this was not necessary for Lino. Tonis helped me to get started for reproducing a series of failures in the book on travis.

In the book repo we have a series of e2e tests to be run with cypress. There is no react in the book at the moment, but cypress doesn’t need react, we use it in the book to test the extjs front end. Installing npm and then cypress as done by the .travis.json file works straightforward.

The test_confirmation_callback.js file contains 3 tests. I can run them interactively using:

./node_modules/cypress/bin/cypress open

I must still make sure to run runserver in a separate terminal, and that I can run the avanti1 tests only when avanti1 is running, and the min1 tests only when min1 is running.

When running the tests, we observed the problem that the type() method on a input field doesn’t work as expected. Here is the source code:

cy.get('.l-InsertFormPanel input[name="first_name"]').type("Alfred").wait(20);

The type() method does not insert all the characters, only the first “A”.

The type() method is documented here It inserts the specified text into the DOM element. Each keypress is delayed 10ms by default in order to simulate how a very fast user types. Text passed to .type() may include special character sequences. Maybe this causes problem? So I tried to disable this feature:

cy.get('.l-InsertFormPanel input[name="first_name"]').type("Alfred", {parseSpecialCharSequences:false}).wait(20);

No change. I tried also with {delay:100} (i.e. simulate a slow typing with 100 instead of the default 10 ms delay after each key). That seems to give better results, but still not perfect. Some part of the text is always eaten away. Actually not even always because once I saw the test case pass successfully. But at the next run it failed again.

I am afraid that the problem is because ExtJS probably handles DOM events specially.

‘AnswersByResponseRow’ object has no attribute ‘save_existing_instance’

I opened #3707 in response to an exception on avanti production site. I managed to reproduce their problem and then to fix it. Actually there were two bugs (in lino_xl.lib.polls).

  • Added a new method lino.core.requests.BaseRequest.clear_cached_status(). And tickets.LinksByTicket.get_table_summary() now uses this method instead of manually setting _status = None.

  • Fixed a bug in AnswersByResponseEditor that caused remarks to always be stored next to the first question of a poll.

  • It was not possible to edit the “My remark” field in AnswersByResponseEditor. Lino then raised above error message.

This last bug was quite subtle. I finally “just” had to move the definition of save_existing_instance() from lino.core.model.Model to lino.core.fields.TableRow. En passant I did some py2to3 conversions and translated two German captions.