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

Error: Wrong color in test at index 3 in text (expected 0x104, actual 0x1): cd test/fish_highlight_test #5458

Closed
Mno-hime opened this issue Jan 1, 2019 · 14 comments
Labels
Milestone

Comments

@Mno-hime
Copy link

@Mno-hime Mno-hime commented Jan 1, 2019

I port fish 3.0.0 to OpenIndiana 2018.10 (illumos kernel, an OpenSolaris fork) and I get following errors when I run the test suite in MATE Terminal (TERM=xterm), which runs Bash 4.4.23(1)-release:

Testing syntax highlighting
Error: Wrong color in test at index 3 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
   ^
Error: Wrong color in test at index 4 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
    ^
Error: Wrong color in test at index 5 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
     ^
Error: Wrong color in test at index 6 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
      ^
Error: Wrong color in test at index 7 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
       ^
Error: Wrong color in test at index 8 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
        ^
Error: Wrong color in test at index 9 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
         ^
Error: Wrong color in test at index 10 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
          ^
Error: Wrong color in test at index 11 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
           ^
Error: Wrong color in test at index 12 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
            ^
Error: Wrong color in test at index 13 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
             ^
Error: Wrong color in test at index 14 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
              ^
Error: Wrong color in test at index 15 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
               ^
Error: Wrong color in test at index 16 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                ^
Error: Wrong color in test at index 17 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                 ^
Error: Wrong color in test at index 18 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                  ^
Error: Wrong color in test at index 19 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                   ^
Error: Wrong color in test at index 20 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                    ^
Error: Wrong color in test at index 21 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                     ^
Error: Wrong color in test at index 22 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                      ^
Error: Wrong color in test at index 23 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                       ^
Error: Wrong color in test at index 24 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                        ^
Error: Wrong color in test at index 25 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                         ^
Error: Wrong color in test at index 26 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                          ^

Let me know should you need more information. You can also get OpenIndiana as a Vagrant Box: https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/doc/vagrant.md.

@faho
Copy link
Member

@faho faho commented Jan 1, 2019

Error: Wrong color in test at index 3 in text (expected 0x104, actual 0x1):

The line of code this applies to (from src/fish_tests.cpp):

{L"test/fish_highlight_test/foo", highlight_spec_param | highlight_modifier_valid_path},

This is supposed to be highlighted as a parameter and valid path (usually via underlining).

Instead, it is highlighted as an error.

Compare #5436, in which the issue was a missing less command.

Here, the issue is probably that the "test/fish_highlight_test" directory doesn't exist or isn't readable (cd highlights non-cdable paths as an error).

How are you running the test? Is it possible that it's not set up correctly (i.e. run "fish_tests" from another directory that doesn't include the test directory)?

@Mno-hime
Copy link
Author

@Mno-hime Mno-hime commented Jan 1, 2019

Here, the issue is probably that the "test/fish_highlight_test" directory doesn't exist or isn't readable (cd highlights non-cdable paths as an error).

$ ll -Ra `find . -name fish_highlight_test`
./build/amd64/test/fish_highlight_test:
total 6
drwxr-xr-x   2 newman   other          4 Jan  1 18:38 ./
drwxr-xr-x  12 newman   other         12 Jan  1 18:38 ../
-rw-r--r--   1 newman   other          0 Jan  1 18:38 bar
-rw-r--r--   1 newman   other          0 Jan  1 18:38 foo

How are you running the test? Is it possible that it's not set up correctly (i.e. run "fish_tests" from another directory that doesn't include the test directory)?

As part of the build infrastructure the test target is run from build directory off the source, now I also run it in the source itself with the same result. Also run it in empty directory in the sources:

fish-3.0.0/build $ ../fish_tests

with the same result.

Is there a way for me to gather more information?

@faho
Copy link
Member

@faho faho commented Jan 1, 2019

fish-3.0.0/build $ ../fish_tests

So... that means $PWD is fish-3.0.0/build, so "test/fish_highlight_test" would refer to fish-3.0.0/build/test/fish_highlight_test.

But, apparently it is at:

./build/amd64/test/fish_highlight_test:

See that "amd64"? That means the path the test is highlighting indeed does not exist, because that doesn't have the "amd64/" component.

@faho
Copy link
Member

@faho faho commented Jan 1, 2019

Is there a way for me to gather more information?

Basically, the most important bit is this: From the directory from where you are running the tests, after you have run them, as the user running the tests, does cd test/fish_highlight_test work?

If it doesn't, the highlighting is correct and the test setup went wrong. If it does, the highlighting is wrong.

@Mno-hime
Copy link
Author

@Mno-hime Mno-hime commented Jan 1, 2019

I am sorry we are conflating two situations. The first one in your comment comes from my run in the sources, where I created 'build' directory. The other one is our build environment.

Anyway, this is how it looks when 'test' target is run in out build env:

[fish_3.0.0] {build-userland} newman:~/ws/oi-userland/components/shell/fish $ gmake test
(cd /export/home/newman/ws/oi-userland/components/shell/fish/build/amd64 ; \
	/usr/bin/env  \
	/usr/gnu/bin/make \
	 test)
make[1]: Entering directory '/export/home/newman/ws/oi-userland/components/shell/fish/build/amd64'
  FISH_BUILD_VERSION = '3.0.0'
  DESTDIR = '/export/home/newman/ws/oi-userland/components/shell/fish/build/amd64/test/root/'
  LN_S = 'ln -s'
  FISH_VERSION = ''
  CXX = '/usr/gcc/6/bin/g++'
  CXXFLAGS = '-m64 -O3  -fno-exceptions -Wextra -Wno-missing-field-initializers -pthread -I/usr/include/pcre '
  MKDIR_P = '/usr/gnu/bin/mkdir -p'
  SED = '/usr/gnu/bin/sed'
  AWK = 'gawk'
  doxygen  user_doc
  prefix = '.'
  sysconfdir = '/etc'
  docdir = './share/doc/fish'
  extra_completionsdir = './share/fish/vendor_completions.d'
  extra_functionsdir = './share/fish/vendor_functions.d'
  extra_confdir = './share/fish/vendor_conf.d'
  HAVE_GETTEXT = '1'
Installing translations...
Installing online user documentation
  datadir = './share'
  mandir = '/usr/share/man'
 Installing fish
 Installing fish_indent
 Installing fish_key_reader
Creating sysconfdir tree
Creating datadir tree
Creating placeholder vendor/'extra_' directories
Installing pkgconfig file
Installing the fish completion library...
Installing fish functions
Installing man pages
Installing helper tools
Installing more man pages
Installing miscellaneous helper resources
  CPPFLAGS = '-D_UNICODE=1 -DLOCALEDIR="./share/locale" -DPREFIX=L"." -DDATADIR=L"./share" -DSYSCONFDIR=L"/etc" -DBINDIR=L"/usr/bin" -DDOCDIR=L"./share/doc/fish" -iquote. -iquote./src/ -DFISH_BUILD_VERSION="3.0.0"'
  CXX      obj/fish_tests.o
  CXX LD   fish_tests
/usr/gnu/bin/mkdir -p test/data test/home
env XDG_DATA_HOME=test/data XDG_CONFIG_HOME=test/home ./fish_tests
Testing low-level functionality
Testing utility functions
Testing wcstring_tok
Testing str_to_num
Testing syntax highlighting
Error: Wrong color in test at index 3 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
   ^
Error: Wrong color in test at index 4 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
    ^
Error: Wrong color in test at index 5 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
     ^
Error: Wrong color in test at index 6 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
      ^
Error: Wrong color in test at index 7 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
       ^
Error: Wrong color in test at index 8 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
        ^
Error: Wrong color in test at index 9 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
         ^
Error: Wrong color in test at index 10 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
          ^
Error: Wrong color in test at index 11 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
           ^
Error: Wrong color in test at index 12 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
            ^
Error: Wrong color in test at index 13 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
             ^
Error: Wrong color in test at index 14 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
              ^
Error: Wrong color in test at index 15 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
               ^
Error: Wrong color in test at index 16 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                ^
Error: Wrong color in test at index 17 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                 ^
Error: Wrong color in test at index 18 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                  ^
Error: Wrong color in test at index 19 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                   ^
Error: Wrong color in test at index 20 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                    ^
Error: Wrong color in test at index 21 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                     ^
Error: Wrong color in test at index 22 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                      ^
Error: Wrong color in test at index 23 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                       ^
Error: Wrong color in test at index 24 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                        ^
Error: Wrong color in test at index 25 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                         ^
Error: Wrong color in test at index 26 in text (expected 0x104, actual 0x1):
cd test/fish_highlight_test
                          ^
Testing parser two-token lookahead
Fuzzing parser (node size: 20)
0 / 5...done (2)
1 / 5...done (21)
2 / 5...done (401)
3 / 5...done (8001)
4 / 5...done (160001)
All fuzzed in 0.576248 seconds!
Testing parser correctness
Parse tests complete
Testing new parser ad hoc tests
Testing new parser error reporting
Testing error messages
Testing escaping and unescaping
Testing escaping with quotes
Testing formatting functions
Testing wide/narrow string conversion
Testing convert_nulls
Testing tokenizer
Test correct tokenization
Testing iothreads
    (392.80 msec, with max of 64 threads)
Testing parser
Testing block nesting
Testing detection of invalid use of builtin commands
Testing basic evaluation
Testing recursion detection
Testing empty function name
Testing eval_args
Testing Ctrl-C cancellation. If this hangs, that's a bug!
Testing indents
Testing utf8
Testing future feature flags
Testing escape_sequences
Testing escaping strings as pcre2 literals
Testing LRU cache
Testing parameter expansion
Testing fuzzy string matching
Testing ifind
Testing ifind with fuzzy logic
Testing abbreviations
Testing test builtin
Testing fish_wcstod
Testing path functions
Testing pager navigation
Testing pager layout
Testing word motion
Testing is_potential_path
Testing colors
Testing complete
Testing input
Testing line iterator
Testing universal variables
Testing universal variable output
Testing universal variable parsing
Testing universal variable legacy parsing
Testing universal callbacks
Testing universal format detection
Testing universal Ok to save
Testing universal notifiers with strategy 2
Testing completion insertions
Testing scenarios that should produce no autosuggestions
Testing autosuggestion combining
Testing history
Testing history merge
Testing history race conditions
Testing history_sample_fish_1_x
Testing history_sample_fish_2_0
Testing bash import
Testing history_sample_corrupt1
Testing builtin_string
Testing illegal command exit code
/export/home/newman/ws/oi-userland/components/shell/fish/build/amd64/test/temp
Testing maybe_t
Testing path normalization
Encountered 24 errors in low-level tests
make[1]: *** [Makefile:374: test_low_level] Error 1
make[1]: Leaving directory '/export/home/newman/ws/oi-userland/components/shell/fish/build/amd64'
gmake: *** [/export/home/newman/ws/oi-userland/make-rules/configure.mk:227: /export/home/newman/ws/oi-userland/components/shell/fish/build/amd64/.tested] Error 2

The directory from which test is run is /export/home/newman/ws/oi-userland/components/shell/fish/build/amd64, so:

[fish_3.0.0] {build-userland} newman:~/ws/oi-userland/components/shell/fish $ cd build/amd64/test/fish_highlight_test
[fish_3.0.0] {build-userland} newman:~/ws/oi-userland/components/shell/fish/build/amd64/test/fish_highlight_test $ ls -Rla
.:
total 6
drwxr-xr-x   2 newman   other          4 Jan  1 20:24 ./
drwxr-xr-x  12 newman   other         12 Jan  1 20:24 ../
-rw-r--r--   1 newman   other          0 Jan  1 20:24 bar
-rw-r--r--   1 newman   other          0 Jan  1 20:24 foo

Basically, the most important bit is this: From the directory from where you are running the tests, after you have run them, as the user running the tests, does cd test/fish_highlight_test work?

If it doesn't, the highlighting is correct and the test setup went wrong. If it does, the highlighting is wrong.

Hence the latter?

@faho
Copy link
Member

@faho faho commented Jan 1, 2019

Okay, did you try that in fish, or a different shell?

What is your $CDPATH? Because I can get the highlighting test to fail in this manner if I set $CDPATH to something that doesn't include a component that is either "." or "", though in that case that is how fish behaves, so the highlighting is correct.

Which would basically make this a duplicate of #4484.

@Mno-hime
Copy link
Author

@Mno-hime Mno-hime commented Jan 1, 2019

I tried in Bash.

As far as I see, CDPATH is not set in my environment:

$ echo "<$CDPATH>"
<>

@faho
Copy link
Member

@faho faho commented Jan 2, 2019

Okay, so I've installed the vagrant thing, and I can reproduce the test failure.

Additionally, I also get failures for some other directory tests:

Testing is_potential_path
Error: Test failed on line 2121: is_potential_path(L"al", wds, PATH_REQUIRE_DIR)
Error: Test failed on line 2131: is_potential_path(L"test/is_potential_path_test/al", wds, PATH_REQUIRE_DIR)
Error: Test failed on line 2138: is_potential_path(L"/usr", wds, PATH_REQUIRE_DIR)
# ....
Testing autosuggestion combining
line 2722: complete() for cd returned the wrong expected string for command cd test/autosuggest_test/start/
  actual: unique2/
expected: unique2/unique3/
Error: Test failed on line 2624 (from 2722): suggestion.completion == expected
line 2750: complete() for cd returned the wrong expected string for command cd ~haha
  actual: ha/
expected: ha/path1/path2/
Error: Test failed on line 2624 (from 2750): suggestion.completion == expected
line 2751: complete() for cd returned the wrong expected string for command cd ~hahaha/
  actual: path1/
expected: path1/path2/
Error: Test failed on line 2624 (from 2751): suggestion.completion == expected

However, actually running the freshly compiled fish, it highlights cd test/fish_highlight_test correctly (i.e. as an argument with underlining to denote a valid path).

@faho
Copy link
Member

@faho faho commented Jan 2, 2019

Okay, so the cd test actually also tests is_potential_path.

And what those failures all have in common, and what separates them from the tests that apparently succeed, is that they all have paths that don't end in "/" and PATH_REQUIRE_DIR set. Which means they all take the path that features this nice bit of code:

            } else if ((dir = wopendir(dir_name))) {
                // Check if we're case insensitive.
                const bool do_case_insensitive =
                    fs_is_case_insensitive(dir_name, dirfd(dir), case_sensitivity_cache);

                wcstring matched_file;

                // We opened the dir_name; look for a string where the base name prefixes it Don't
                // ask for the is_dir value unless we care, because it can cause extra filesystem
                // access.
                wcstring ent;
                bool is_dir = false;
                while (wreaddir_resolving(dir, dir_name, ent, require_dir ? &is_dir : NULL)) {

In which we have wopendir, fs_is_case_insensitive and wreaddir_resolving. One of those is most likely failing.

@faho
Copy link
Member

@faho faho commented Jan 2, 2019

Okay, inside wreaddir_resolving, readdir_r is failing. It returns 0 and sets the out pointer to NULL.

Apparently readdir_r has been known to be bad on Solaris for some time, e.g. rust uses plain readdir there (rust-lang/rust#31078 (comment)).

We might want to re-check switching away from it - #4183.

faho added a commit to faho/fish-shell that referenced this issue Jan 2, 2019
It's deprecated in glibc, and does not work properly on Solaris.

Fixes fish-shell#5458.
@Mno-hime
Copy link
Author

@Mno-hime Mno-hime commented Jan 2, 2019

Can't help much with readdir_r, but folks at #illumos at freenode should be able to.

@faho
Copy link
Member

@faho faho commented Jan 2, 2019

@Mno-hime: Please try b5bc1b2. That should make the low_level tests work.

Though then you'll see a bunch of new failures, which is because it's only then attempting the script tests.

@Mno-hime
Copy link
Author

@Mno-hime Mno-hime commented Jan 2, 2019

It works, @faho. Thank you!

@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Jan 21, 2019

@faho thanks for this fix! If it's not too much trouble can you cherry-pick into 3.0.1 and verify your fix there?

faho added a commit to faho/fish-shell that referenced this issue Jan 21, 2019
It's deprecated in glibc, and does not work properly on Solaris.

Fixes fish-shell#5458.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants